VBA wont return cell value

Aussie Grid

New Member
Joined
Jan 14, 2010
Messages
47
I'm using the following code in a worksheet change event but it wont return the Target Offset value. However if I delete the linked value and type in Sun or any other day it finds it.

If Not Intersect(Target, Range("D8:D38")) Is Nothing Then
If Target.Value = Range("P40").Value Then
If Target.Offset(0, -2).Value = Range("Q40").Value Then
MsgBox Range("P40") & " cannot work on a " & Range("Q40")
End If
End If
End If

The offset column is
b3=a3(Date, 1/1/10 in A1, formated to ddd) =Fri
b4=b3+1(Sat)
b5=b4+1(Sun)
b6=b5+1(Mon)
etc
The offset target is to be checked against Q40 (Sun) or ideally checked against a range of days, say Q40:Q46, with the particular days that they cannot work. ie. Sun Tue Fri .

Any and all help or other ideas appreciated.

Aussie Grid
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hello Aussie Grid, welcome to the board.
If I understand your data layout description, the cell 2 columns to the left of your target cell is a formula. Therefore the value is not the same, only the return from the formula (or the text) of the cell is the same. (yes?)

To fix it should be as simple as changing your line:
If Target.Offset(0, -2).Value
To:
If Target.Offset(0, -2).Text

Hope it helps.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,448
Members
448,966
Latest member
DannyC96

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