PDA

View Full Version : How to delete columns using VBA excel?



anasleco
12-06-2011, 04:39 AM
Hi everybody, i have a "beginer" question, i have an excel file with a lot of sheets, and every sheets contain at least one table but in different position, what i wanna do is delete all empty columns before the tables on each sheet, in order to have all the start on the same "B" column.

i tried to tinker a small macro but it doesnt work :

Sub DeleteColumns()

Worksheets(2).Activate
Worksheets(2).Range("B1:B100").Select
If Sum(Selection).Value = 0 Then
Column("B").EntireColumn.Delete
Else

End Sub

Thank you for your help.

GTO
12-06-2011, 04:58 AM
Greetings,

I see that you just joined. Please read Here (http://www.excelguru.ca/node/7)

Cross-Posted at http://www.mrexcel.com/forum/showthread.php?t=596908

Mark

anasleco
12-06-2011, 05:07 AM
Greetings,

I see that you just joined. Please read

Cross-Posted at

Mark
Ok, i get it, thanks for point in it, what should i do now, delete this post?

GTO
12-06-2011, 05:25 AM
Ok, i get it, thanks for point in it, what should i do now, delete this post?

No. Sorry about saying the same thing twice, I am tired and heading off to bed, so basically posted the same thing, for other members who may consider answering as well.

As mentioned in your other thread, I certainly 'sinned' far worse when I first joined here. My intent is simply to give you the heads-up, for as mentioned so elequently by Ken Puls, cross-posting prematurely and/or without advisement simply burns bridges, so-to-speak.

Just IMHO, I would stick with the first thread (date/time-wise) I posted, and/or advise in both thread when solved.

Happy coding:thumb

Mark

Aflatoon
12-06-2011, 06:17 AM
Also posted, and solved, here (http://www.excelforum.com/excel-programming/804427-how-to-delete-columns-using-vba-excel.html).