If statement in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I need help designing a VBA Macro to execute the following:

IF (A2=A1,0,1)
I need to execute this VBA macro from 1 to 300.
Thanks,
 
Try this for the active sheet
It will use the B column to display the 0 or 1

Sub test()
Dim a As Long
For a = 2 To 300
If Cells(a, 1).Value = Cells(a - 1, 1).Value Then
Cells(a, 2).Value = 0
Else
Cells(a, 2).Value = 1
End If
Next a
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top