Dec 17, 2001 #1 Jcan Programmer Jul 16, 2001 25 US Hi, how can i step through an excel column using VBA without going through the thousands of empty cells in which there is no data? Thanks a latte Jcan
Hi, how can i step through an excel column using VBA without going through the thousands of empty cells in which there is no data? Thanks a latte Jcan
Dec 19, 2001 #2 JustinEzequiel Programmer Jul 30, 2001 1,192 PH by 'the thousands of empty cells in which there is no data' I am assuming you mean the cells at the bottom of the worksheet after your data. If I am wrong, please ignore the rest. You can limit your looping by using the 'UsedRange' property of the WorkSheet object. E.g., Dim oRange As Range Dim oSheet As Worksheet Dim oColumn As Range Dim oCell As Range Dim i As Long Set oSheet = ActiveWorkbook.ActiveSheet Set oRange = oSheet.UsedRange Set oSheet = Nothing Set oColumn = oRange.Columns(3)'replace 3 with whatever Set oRange = Nothing For i = 1 To oColumn.Rows.Count Set oCell = oColumn.Rows(i) Debug.Print i, oCell.Text Set oCell = Nothing Next i Set oColumn = Nothing ' excuse the 'round-about' method but I wanted to use Intellisense Upvote 0 Downvote
by 'the thousands of empty cells in which there is no data' I am assuming you mean the cells at the bottom of the worksheet after your data. If I am wrong, please ignore the rest. You can limit your looping by using the 'UsedRange' property of the WorkSheet object. E.g., Dim oRange As Range Dim oSheet As Worksheet Dim oColumn As Range Dim oCell As Range Dim i As Long Set oSheet = ActiveWorkbook.ActiveSheet Set oRange = oSheet.UsedRange Set oSheet = Nothing Set oColumn = oRange.Columns(3)'replace 3 with whatever Set oRange = Nothing For i = 1 To oColumn.Rows.Count Set oCell = oColumn.Rows(i) Debug.Print i, oCell.Text Set oCell = Nothing Next i Set oColumn = Nothing ' excuse the 'round-about' method but I wanted to use Intellisense