ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to select columns in loop (https://www.excelbanter.com/excel-programming/321079-re-how-select-columns-loop.html)

Tom Ogilvy

How to select columns in loop
 
When a row is deleted, it is deleted for all columns.

If you want anything other than that, you can do it with one command

ActiveSheet.Cells.SpecialCells(xlblanks).Delete

If you have more than 8192 discontiguous areas, then you might need a work
around.

--
Regards,
Tom Ogilvy


"JH" wrote in message
...
Dear experts,

please I need to help with following problem:

I 've got in a worksheet 10 columns. Start A1.
I'd like to remove empty cells in each column.
to remove empty cells I use following:

Sub delEmptyrow()
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r

End Sub

this work fine but just for one column
I don't know how to select each column separately in loop in order to use
"my Sub"

actually, how to replace this notation range("A:A")

thanks

JH








JH

How to select columns in loop
 
Thanks you

:)

JH




"Tom Ogilvy" wrote:

When a row is deleted, it is deleted for all columns.

If you want anything other than that, you can do it with one command

ActiveSheet.Cells.SpecialCells(xlblanks).Delete

If you have more than 8192 discontiguous areas, then you might need a work
around.

--
Regards,
Tom Ogilvy


"JH" wrote in message
...
Dear experts,

please I need to help with following problem:

I 've got in a worksheet 10 columns. Start A1.
I'd like to remove empty cells in each column.
to remove empty cells I use following:

Sub delEmptyrow()
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r

End Sub

this work fine but just for one column
I don't know how to select each column separately in loop in order to use
"my Sub"

actually, how to replace this notation range("A:A")

thanks

JH










All times are GMT +1. The time now is 05:23 PM.

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