Sql data loading blank row errors - sql

I have an Excel file that contains some data that needs loading into my sql script. I have gotten most of it done but I am coming up against a problem due to the spreadsheet. The spreadsheet has data in rows that is implicit from the one above it (see the picture below).
Does anyone have any idea of how I can do this? Links to other pages would be welcome,I just wouldn't know how to start searching for this.

Quick way to fill the blanks in Excel:
Select the table
Hit F5
Click Special
Tick "Blanks" and hit OK
All blank cells in the table are now selected. Without changing the selection,
type a = sign
hit the up arrow key on your keyboard.
Hold down Ctrl and hit Enter
Now all previously blank cells contain a formula that references the cell right above. Copy the table and paste it over itself with Paste Special > Values to replace the formulas with the values.
Far less key strokes than writing a macro, and faster in the processing, too.

Related

Highlight Every other row that contains information in column A vba

I was hoping you guys could help me figure something out. I am trying to get excel to highlight every other row that contains any information in column A
so it would look like this:
I haven't been able to make any proper headway into this but I was hoping you guys might be able to give me some basic direction.
You can do this without VBA, just use conditional formatting.
Mark the Range, go to Conditional formatting, add a new rule with rule type "Use a formula to determine which cells to format" and enter
=AND($A1<>"",MOD(ROW(),2)=1)
(depending on the regional setting, you might have to exchange the "," with ";" - same syntax as a regular formula)
Then, click the "Format" button and select a fill color.
Convert a range into a table in Excel:
You can make your range of data into a table (including auto-formatting):
Select (highlight) the cells (including the heading if there is one).
Hit Ctrl+T.
Hit Enter.
There are several ways you can then customize your table, such as the options on the ribbon.
More Information:
Office.com : Create or delete an Excel table
Office.com : Overview of Excel tables
Several other tutorials and examples on Google Search.

Setting an specific format for an Excel Column with VBA

I am currently working with a macro that gathers data (code identifier) from a source with a print screen and pastes it to excel.
Problem is, every time a data point (identifier) is a value with an "E" included, excel interprets as a scientific notation and changes the original value.
Is there a way to make excel set the column in which I have those values to text before pasting, or for it to paste the whole content as text automatically?
Thanks for the help.

Unable to move / delete rows in shared workbook - Not enough resources

this one's a bit of a painful one so thank you for your help and patience with me.
We have an Excel spreadsheet that we use as a master file for our website products. As such there are quite a few sheets and quite a few products on each running along side some macros to provide some extra functionality (turning entered data into HTML for product page, etc).
My issue is that one of our most used spreadsheets has become a trouble in that it has some phantom formatting all the way down to the millionth-and-something row and all the way across, causing the last cell to be the very last cell possible.
The issue that has finally popped up as a result is that we can no longer move rows in, out or around the sheet (a required functionality) as it results in an 'out of resources error'.
I've tried:
Highlight all rows below used range to right-click> delete - Results in runtime error (from macro)
Highlighting large chunks of rows and using Clear All - Resulted in the 38MB file bloating to 380MB
Deleting a chunk of rows at a time - Maxed out at 1,000 before it caused Excel to crash
Moving to new spreadsheet - Broke all our macros (which I did not write and am not proficient enough to fix on a new sheet)
Disabling macros and trying the above options, only marginally more efficient but still out of resources
I'm at my wits end on this one and, while we can continue with most day-to-day functions, we will soon be completely unable to use this particular sheet as we need it at all.
I'm wondering if there might be a way to run a VBA script to remove these rows, potentially one by one? I've tried running a short script that went something like rows[960,1000000].Delete (forgive my terrible VBA markup), but this also resulted in not enough resources errors.
I'm wondering if there's anything like:
row = 960;
while(row<=1048576){row.Delete};
Continuing, the runtime error debug points me to the below if statement within the macro:
If Target.Count > 1 Then Exit Sub
Where Target is the variable passed to the sub.
Which strikes me as very odd because my (limited) understanding of VBA and IF's in general simply recognizes that 'if my selection is larger than 1 (row?), do not run this code..
Thanks again in advance.
Use this method only if you don't have any links into or out of the sheet that will get broken. Also might have Sql connections that might get broken. Might need to disable macros. There are many possible problems with this approach. Use at your own risk.
Note the exact "Name" and "(Name)" of the sheet; Look in the VBA code window at the properties for the sheet. "Name" is the name displayed on the worksheet tab. "(Name)" is the code name visible only in the properties window.
Make a list of range names on the sheet.
Copy the data to a new sheet.
Copy any macros to the new sheet.
Delete the old sheet.
Rename the "Name" and "(Name)" of the new sheet the same as the old one.
Recreate range names.
A better method if you don't have too many formats:
Disable macros and set calculation to manual. This avoids recalculating while doing your delete operation.
Select entire sheet and clear formats.
Delete all rows below your data.
Redo your formatting. Select entire column (not just used area) to apply format if applicable.
It is important to remove formatting on the entire sheet from A1 to the end. Otherwise you'll get the bloat you mentioned. Just that step may solve your problem. If not then proceed with removing all the rows below the data. This should not cause file size bloat.

Excel Vlookup Missing data unless re-typed or select and enter?

Google has not found the solution i need so i thought i would try the genius on here to the never ending Excel issue I'm having.
Running a banking reconciliation workbook and slowly adding bits of VBA together to automate some of the tasks, one I'm working on now is finding large quantities of money and renaming their Identifier from a bank statement to same ID in our cashbook to they are found and will balance out.
To do this I'm running a IF(Vlookup()) returning a yes or no on the cash value and then reordering them once they are found so i can line them up and match them correctly.
The main issue I've got here is the vlookup is ignoring some values which i can see and saying no not found and i messed around figuring out why and until i clicked to edit the cell and then pressed enter not changing the amount and all of a sudden found and it only finds it in the vlookup if i click the cell and press enter.
I have tried Formatting, changing calculation to automate and tweaked the vlookup to include a +0 as well as changing the exact match to approximate and it still won't find it, i even tried trimming and checked the Len for whitespace and both equal the same.
Currently trying a for loop to select a cell and change it to itself so it mimics the select and enter but it runs slow and crashes.
Anyone got a decent idea of fixing this miss when searching
This often happens to me when pasting data from somewhere. It may have been pasted as text but then when you edit and press enter it changes to numeric.
The solution is to use =VALUE() to change the numbers to numeric.
Or when you paste the data from another source choose paste special as text.
VLOOKUP works strangely when is asked to do an approximate match with the look-up table unsorted by the look-up column.
If you're sure that an exact match should be enforced in your look-up column, try something along the lines of:
VLOOKUP(<lookup_value>, <table_array>, <col_index_num>, FALSE)
where <lookup_value>, <table_array>, <col_index_num> should be replaced with the values that you use in your look-up.

Formatting when copying SQL data and pasting in Excel

I want to copy a sql result set and paste it in Excel. But the data I paste in to the spreadsheet doesn't want to recognize Excel formatting. So if I change a column to currency, it doesn't do anything. But...if I double click on a cell, THEN it applies the currency format. But only to that cell.
How can I make it automatically recognize the Excel format?
I must be something I'm missing. Hopefully somebody can help. :-)
After you input the data into the columns in Excel, highlight all cells, then select the Data tab in the top ribbon. In the data tab click on Text to Columns, in the pop-up window select Delimited, then uncheck all of the boxes in Step 2 on that pop-up and select Finish. It will force all of the cells to update to your formatting.
Have you tried <edit><paste special> and then paste the data as text? Otherwise you're copying data AND formatting, which might be the problem.
You can right click on the SQL Grid and pick the the Save Results As option and save as csv. Open the csv in excel copy the content and paste in your destination Excel worksheet.
Seconding the <edit><paste special>, but another useful feature is <Text to Columns>. So if you paste your data as text, if it does not automatically appear in columns, use the Text to Columns to turn it into columns, then any formatting you apply should work.
Change your excel column format into text and then paste special -> TEXT