View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Stefi Stefi is offline
external usenet poster
 
Posts: 2,646
Default macro with If statement not working

Try this way (not tested, but the cause of error is eliminated)

Sub loopthrough()
Dim myRow As Integer
myRow = 1

Range("AI225").Select
Do Until myRow = 10
If ActiveCell.Offset(0, -15).Range("a1").Select = "Karlan-Gine" Then
ActiveCell = "MIT0000"
End If
ActiveCell.Offset(1, 0).Select
myRow = myRow + 1
Loop

End Sub

Regards,
Stefi


€žapril€ť ezt Ă*rta:

i have taken an existing macro that loops and am trying to tailor it to my
needs. here is what i want to do
1. go to cell ai225
2. check the contents of t225
3. if t225 = General Research then put "MIT0000" in cell ai225
4. move to the next row and perform the same operation.

when i run the macro i get an error notice "End If without Block if". Any
ideas.

here is the macro

sub loopthrough()
Dim myRow As Integer
myRow = 1

Range("AI225").Select
If ActiveCell.Offset(0, -15).Range("a1").Select = "Karlan-Gine" Then
ActiveCell = "MIT0000"

Do Until myRow = 10

End If
ActiveCell.Offset(1, 0).Select

myRow = myRow + 1

Loop

End Sub

thanks in advance for your help
aprilshowers