I have a bunch of nested If statements (vba, not native excel) that are giving me some trouble. the spot that is giving me a hard time is when I need to add an Else If. Here is my code:
The code that is bold, obviously, is the part I'm having trouble with. It doesn't like the way it is written, as it gives me an error before I even run the code and immediately after I enter it.
The error says must be first statement on the line. Does anyone have any ideas how I can write this code so excel will accept it? Thanks a lot for the looks and any help you can give me.
Hank
Code:
For y = ActiveSheet.Cells(lngHeaderRow, 2).End(xlToRight).Column To 1 Step -1
If ActiveSheet.Cells(lngHeaderRow, y).Text = rsp Then
If y = 2 Then
ActiveSheet.Cells(13, y).Value = myNum + ActiveSheet.Cells(13, y).Value
End If
[B] Else If ActiveSheet.Cells(13, y).Value > ActiveSheet.Cells(13, (y - 1)).Value Then
[/B] ActiveSheet.Cells(13, y).Value = myNum + ActiveSheet.Cells(13, y).Value
End If
Else
ActiveSheet.Cells(13, y).Value = myNum + ActiveSheet.Cells(13, (y - 1)).Value
Next y
The code that is bold, obviously, is the part I'm having trouble with. It doesn't like the way it is written, as it gives me an error before I even run the code and immediately after I enter it.
The error says must be first statement on the line. Does anyone have any ideas how I can write this code so excel will accept it? Thanks a lot for the looks and any help you can give me.
Hank