Help with IF Elseif in macro

Frank3923

Board Regular
Joined
Jan 20, 2003
Messages
244
This is my first time utilizing a IF ElseIF statement with vba. I am receiving a compile error message – reflecting that I have a syntax error. If someone could point out my errors, I would appreciate the feedback.
Thank you in advance

Sub CHECKBuy3()
Dim LR As Long, a As Long
Dim i As Long
Application.ScreenUpdating = False
Worksheets("BP-Proj ").Select
LR = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To LR Step 2
IF Range("Q" & i ").value ="NO" and Range("S" & i ").Value = "Up Tick" THEN
Range("U" & i").Value = ""Buy""
Else
Range("U" & i").value = ""DO NOT Buy""

End If
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Frank3923,


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


Rich (BB code):
Option Explicit
Sub CHECKBuy3()
Dim LR As Long, a As Long
Dim i As Long
Application.ScreenUpdating = False
Worksheets("BP-Proj ").Select
LR = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To LR Step 2
  If Range("Q" & i).Value = "NO" And Range("S" & i).Value = "Up Tick" Then
    Range("U" & i).Value = "Buy"
  Else
    Range("U" & i).Value = "DO NOT Buy"
  End If
Next i
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top