ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to delete columns (https://www.excelbanter.com/excel-programming/274234-macro-delete-columns.html)

Luong

Macro to delete columns
 
Hello,

I have a macro to import text file data into an Excel
spreadsheet. Sometimes, several columns imported have
blank data and can be random columns. I would like to
write a macro to do the followings:
1) From column A-M, If any column along row cell 9 is
blank, then delete the entire columns with blank data.

Thanks for any help.

Laura Cook[_3_]

Macro to delete columns
 
Sub DeleteBlanks()
Range("A9:M9").SpecialCells(xlCellTypeBlanks).Enti reColumn.Delete
End Sub

--
HTH,
Laura Cook
Appleton, WI


"Luong" wrote in message
...
Hello,

I have a macro to import text file data into an Excel
spreadsheet. Sometimes, several columns imported have
blank data and can be random columns. I would like to
write a macro to do the followings:
1) From column A-M, If any column along row cell 9 is
blank, then delete the entire columns with blank data.

Thanks for any help.




Luong

Macro to delete columns
 
Laura,

Never mind my earlier reply, I got it. Thanks

-----Original Message-----
Hello Laura,

Thanks for the tip, but I have one problem.
The some unwanted columns might have some data in one of
the row (example row 10 or 45). Not all the unwanted
columns have blank data all the way down.
That's why I like to use row 9, which is a title row. So
if row 9 (on column A to M) is blank, then delete the
entire column.

I hope this will help in what I am trying to achieve.
Thanks again.

-----Original Message-----
Sub DeleteBlanks()
Range("A9:M9").SpecialCells

(xlCellTypeBlanks).EntireColumn.Delete
End Sub

--
HTH,
Laura Cook
Appleton, WI


"Luong" wrote in message
...
Hello,

I have a macro to import text file data into an Excel
spreadsheet. Sometimes, several columns imported have
blank data and can be random columns. I would like to
write a macro to do the followings:
1) From column A-M, If any column along row cell 9 is
blank, then delete the entire columns with blank data.

Thanks for any help.



.

.


Laura Cook[_3_]

Macro to delete columns
 
You're welcome, glad I could help.

--
Laura Cook
Appleton, WI


"Luong" wrote in message
...
Laura,

Never mind my earlier reply, I got it. Thanks

-----Original Message-----
Hello Laura,

Thanks for the tip, but I have one problem.
The some unwanted columns might have some data in one of
the row (example row 10 or 45). Not all the unwanted
columns have blank data all the way down.
That's why I like to use row 9, which is a title row. So
if row 9 (on column A to M) is blank, then delete the
entire column.

I hope this will help in what I am trying to achieve.
Thanks again.

-----Original Message-----
Sub DeleteBlanks()
Range("A9:M9").SpecialCells

(xlCellTypeBlanks).EntireColumn.Delete
End Sub

--
HTH,
Laura Cook
Appleton, WI


"Luong" wrote in message
...
Hello,

I have a macro to import text file data into an Excel
spreadsheet. Sometimes, several columns imported have
blank data and can be random columns. I would like to
write a macro to do the followings:
1) From column A-M, If any column along row cell 9 is
blank, then delete the entire columns with blank data.

Thanks for any help.


.

.





All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com