VBA - Check adjacent cells when value changes

jackyoung2012

Board Regular
Joined
May 22, 2012
Messages
63
Hi All,

I'm trying to write a procedure that checks to see that, when a cells value is changed, if the cell nex tto it is empty, some extra code runs. I have made a start but keep getting an error message:

Code:
Sub validateCompleteOrder(ByVal sheetname As String, ByVal address As Range)


Dim ws As Worksheet
Dim checkrange As Range


Set ws = Worksheets(sheetname)
Set checkrange = address




If IsEmpty(ws.Range(address).Offset(0, 1)) Then
MsgBox ("worked")
End If

I keep getting the error "method range of object '_worksheet failed. Any ideas? I am triggering this function by passing through a string with the worksheet name and a range object.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,207,170
Messages
6,076,912
Members
446,240
Latest member
theprattipati

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