Worsheet_Change

albatross32

New Member
Joined
Feb 17, 2010
Messages
32
I am trying to write a VBA code for the Worksheet_Change function.

It is a Private Sub in Sheet1.

My Target Address is $O$9

I need the code to say;

If Target Address value = "AGREED" And Sheet2 Q233 = 1 Then.........

So far I have got to;


CODE:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(0, 0) = "$O$9" And UCase(Target.Value) = "PLACED" And Sheets("Sheet2").Range("Q233").Value = "1" Then


However with this I am now getting 'Run-time error '13' Type mismatch'

Can someone advise me what changes are required or alternatively any different code which would work
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Separate the two tests:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(0, 0) = "$O$9" Then
       If UCase(Target.Value) = "PLACED" And Sheets("Sheet2").Range("Q233").Value = "1" Then
 
Upvote 0
Or it could be the fact that your testing for a string in the last bit.
Try changing
Sheets("Sheet2").Range("Q233").Value = "1"
to
Sheets("Sheet2").Range("Q233").Value = 1
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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