VBA Multiple IF conditions - why doesn't mine work?

Jossilyn

New Member
Joined
Jul 16, 2009
Messages
49
Hi there,

While looking on your site I found this post of June 2008 by Anxoperez which ended with this formula:
If ActiveCell.Value < -25 And ActiveCell.Offset(-2, 0).Value < -25 And ActiveCell.Offset(-3, 0).Value < -25 Then
Range("C4").Select
End If
End Sub

I am looking to do something similar on excel 07 as follows:
Range("O16").Select
IF ActiveCell.Offset(0,-1)Value ="1" And ActiveCell.Offset(0,-2).Value = "1" Then
ActiveCell.Value = "1"

Compile error expected: Then or GoTo At the First value (which I have highlighted in red)

Why doesn't mine work?

Also would like the If formula to repeat for range O16:O36.

Please help.
 
aarrrggghh!
another problem

how do I get it to work automatically as opposed to going in to developer and running the code or assigning a macro?

thanks for being so patient.
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
What do you need to be the trigger to fire it off? Like if someone enters something in a cell or a button or a keyboard command?
 
Upvote 0
OK, How do we tell that? Is it a human entry in a cell or some calculation?

We will use a worksheet_change event on the sheet level which will allow the code to fire under certain sheet level change criteria

Cheers

Dan
 
Upvote 0
Hello,

Do you want VBA or a Worksheet Function alternative? Can you provide a scenario?
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

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