#1   Report Post  
Jeff
 
Posts: n/a
Default If statement in VBA

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,

  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

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



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jeff" wrote in message ...
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,



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Statement and Excel DavidM Charts and Charting in Excel 3 January 7th 05 12:53 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
If/Then statement A Ford Excel Discussion (Misc queries) 5 December 2nd 04 04:45 PM
=IF statement Dick Excel Discussion (Misc queries) 10 November 27th 04 02:47 PM
The "Open" statement carl0s66 Excel Discussion (Misc queries) 1 November 26th 04 04:26 PM


All times are GMT +1. The time now is 11:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"