PDA

View Full Version : VBA Macro For Column Header & Deleting Column



Weezer
09-19-2010, 07:36 PM
Hello everyone!

Ok I have 2 problems with my macro. When I import data from a SQL table, all the data is imported correctly into the worksheet, but one column gets added for no reason, I thought this was an extra column, but the column heading is supposed to actually be a cell value under another column. Is there a way I can just make that column header a cell value under the desired column by specifying it to do it?

My 2nd problem is related to another worksheet. Again when the Macro is run, it imports the data fine into the worksheet but at the start there is a column which is blank and it shouldn't be there. Is there a way to skip this column or stop this column from being populated, instead of manually deleting the column every time. I know I can specify the column name and have it deleted, but I want to write code to dynamically delete a blank column, just to be on the safer side.

I know that these aren't major tasks but I'm having trouble coding the Macro to function this way. I have tried a couple of things but I don't get the result that I am looking for.:banghead: Please help me if you guys can.

Thanks. :thumb

Bob Phillips
09-20-2010, 12:38 AM
Your SQL code must be creating it so you need to amend that. Without seeing the SQL it is hard to be more specific.