0

I want to make excel VBA code to select range of cells and every time the condition found it change the range by increasing the cell number .

for example: First time the condition excuted copy the Range("AA1:AB1").Value Range("BA1:BB1") Next time the condition excuted copy the Range("AA2:AB2").Value Range("BA2:BB2")

Sub insertR()
Dim x As Integer
n = 1

    For n = 1 To 800
          If Range("AA:AB"& n).Value = "Ready" Then
            Range("AA&n:BB&n").Copy Range("BA&n:BB&n")
           n = n + 1
        End If
        
    Next n
        
End Sub
  • 2
    A `For ... Next` statement will increment the value of the variable being looped. No need to include `n = n + 1` That said, you have given us some code and what you want to accomplished, but not explained the problem you are facing – cybernetic.nomad May 01 '23 at 19:42
  • 1
    You can only use the value of a single cell `= "Ready"` . My guess: `If Range("AA" & n).Value = "Ready" And Range("AB" & n).Value = "Ready" Then`, `Range("AA" & n & ":BB" & n).Copy Range("BA" & n & ":BB" & n)`. – BigBen May 01 '23 at 19:45

0 Answers0