Quicky: vba IF cell.offset.month = Then...

ClimoC

Well-known Member
Joined
Aug 21, 2009
Messages
584
Hello

Just having a little trouble with syntax. Just need to do this:

"If the month in date cell in col G is the same month as shown in cell M1, Then (proceed)"

It's got an OFFSET because it is running through rows in a table and checking two conditions. Here's the For and If statement which I need corrected:

Code:
For Each zp In Range("A6:A500")
    If zp.Offset(0, 8).Font.Strikethrough = False And zp.Offset(0, 6).Month = Range("Schedule!R5C45").Month Then
        zp.Value = True
        zp.Font.ColorIndex = 10
        Else
        zp.Value = False
    End If
Next

Here though it is looking at cell AS5, which is the first of the month which is set by cell M1. So It can either look at AS5 or at M1, the answer (the month) will be the same in both those cells.

Anyone help?

Cheers
 
Month is a function, not a property of a Range object:
Code:
    If zp.Offset(0, 8).Font.Strikethrough = False And Month(zp.Offset(0, 6).Value) = Month(Range("Schedule!R5C45").Value) Then
 
Upvote 0
Thanks Rory - that looks better, but it still didn't work.

Method 'Range' of Object '_Global' failed
 
Upvote 0
Try:
Code:
    If zp.Offset(0, 8).Font.Strikethrough = False And Month(zp.Offset(0, 6).Value) = Month(Sheets("Schedule").Cells(5, 45).Value) Then
 
Upvote 0

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