Loop table rows until certain value or empty cell - excel macro

Hi,
I am trying to create an excel macro using a VBA. I need to get and process data from table rows.
How can I loop table rows one by one until the specific value or empty cell is found ?
0
give a positive ratinggive a negative rating
To loop table rows until the certain value or empty cell, you can use the Excel macros below. The macros allow to work with ActiveCell, so you can get also other cell values from each table row.

First, you have to activate the sheet, where table is located and select the ActiveCell, where a processing will start.

Loop table rows until the certain value:

Dim other_cell_value_1 As String
Dim other_cell_value_2 As String

Worksheets("Sheet1").Activate
Worksheets("Sheet1").Range("A2").Select

Do Until ActiveCell.Value = "Abc"

other_cell_value_1 = ThisWorkbook.Worksheets("Sheet1").Cells(ActiveCell.Row, 2).Value
other_cell_value_2 = ThisWorkbook.Worksheets("Sheet1").Cells(ActiveCell.Row, 3).Value

' Insert your code here

ActiveCell.Offset(1, 0).Select
Loop

Loop table rows until the empty cell:

Dim other_cell_value_1 As String
Dim other_cell_value_2 As String

Worksheets("Sheet1").Activate
Worksheets("Sheet1").Range("A2").Select

Do Until IsEmpty(ActiveCell)

other_cell_value_1 = ThisWorkbook.Worksheets("Sheet1").Cells(ActiveCell.Row, 2).Value
other_cell_value_2 = ThisWorkbook.Worksheets("Sheet1").Cells(ActiveCell.Row, 3).Value

' Insert your code here

ActiveCell.Offset(1, 0).Select
Loop
Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2025 AnswerTabsTermsContact us