petegrant89
New Member
- Joined
- Jun 28, 2011
- Messages
- 21
Hello,
I am very new to programming macros. I am trying to write one that will search a column (Column A, for example), and check to see if two consecutive rows contain the same value. In this case, column A will be populated with either "2012" or "2013"; if there are two "2012" rows in a row, I need the macro to execute another macro (Macro1). If there are two "2013" rows in a row, I need the macro to execute yet another macro (Macro2). I will paste what I managed to achieve down below, the problem is that if the condition (two Consecutive 2012 or 2013 rows) is met in Row 1, it stops searching the rest of the document. Any help with this would be greatly appreciated.
Sub test()
For x = 1 To 8000
If Range("A1") = "2012" And Range("A1") = Range("A2") Then
Application.Run "Book1!Macro1"
Else
End If
If Range("A1") = "2013" And Range("A1") = Range("A1") Then
Application.Run "Book1!Macro2"
Else
End If
Next x
End Sub
I am very new to programming macros. I am trying to write one that will search a column (Column A, for example), and check to see if two consecutive rows contain the same value. In this case, column A will be populated with either "2012" or "2013"; if there are two "2012" rows in a row, I need the macro to execute another macro (Macro1). If there are two "2013" rows in a row, I need the macro to execute yet another macro (Macro2). I will paste what I managed to achieve down below, the problem is that if the condition (two Consecutive 2012 or 2013 rows) is met in Row 1, it stops searching the rest of the document. Any help with this would be greatly appreciated.
Sub test()
For x = 1 To 8000
If Range("A1") = "2012" And Range("A1") = Range("A2") Then
Application.Run "Book1!Macro1"
Else
End If
If Range("A1") = "2013" And Range("A1") = Range("A1") Then
Application.Run "Book1!Macro2"
Else
End If
Next x
End Sub