Peace all,
how to change range set by the loop with mathematics (Forx =1 To 151 Step 50) in the code below, instead look for range with a cell value in cell G1 upto G20.
for instance cell value in G1 = 51 .. Now goto row 51 and apply the rest of the code to perform from there. and loop it for the cell reference in G2.G3.G4.... so on.
thanks.
how to change range set by the loop with mathematics (Forx =1 To 151 Step 50) in the code below, instead look for range with a cell value in cell G1 upto G20.
for instance cell value in G1 = 51 .. Now goto row 51 and apply the rest of the code to perform from there. and loop it for the cell reference in G2.G3.G4.... so on.
thanks.
Code:
Sub Delete()
Dim x As Long
Dim y As Long
Dim z As Long
Dim lr As Long
Dim cellrow As Range
For x = 1 To 151 Step 50
Cells(x, 1).Select
Set cellrow = Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 255))
z = Application.WorksheetFunction.CountA(cellrow)
lr = Range(Cells(x, 1), Cells(x, 1).End(xlDown)).Count
If z = 0 Then
For y = 1 To lr
Set cellrow = cellrow.Resize(y)
cellrow.Select ' Checking resize
z = Application.WorksheetFunction.CountA(cellrow)
If z > 0 Then
Set cellrow = cellrow.Resize(y - 1)
cellrow.Delete shift:=xlShiftUp
y = lr
End If
Next y
End If
Next x
End Sub