Quick VBA question

iisailor

Board Regular
Joined
Feb 18, 2009
Messages
58
I have this line of code in my macro and it continues to cause the error of method Range of object '_Global' failed.
im simply wondering if it has anything to do with my use of AND. This may sound stupid but ive never used AND in this way before so just wanted to double check.
Thanks in advance
Chris

If Range("B" & CStr(StockSearch)).Value = Range("A" & CStr(CopiedParts)) And Range("C" & CStr(StockSearch)).Value = Range("B" & CStr(CopiedParts)) And Range("D" & CStr(StockSearch)) = Range("C" & CStr(CopiedParts)) Then
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Very difficult to tell without seeing how StockSearch and CopiedParts are defined and assigned values. The syntax looks OK and will pick up ranges from the currently Activesheet.
 
Upvote 0
This should work

Code:
If Range("B" & StockSearch).Value = Range("A" & CopiedParts).Value And _
    Range("C" & StockSearch).Value = Range("B" & CopiedParts).Value And _
    Range("D" & StockSearch).Value = Range("C" & CopiedParts).Value Then

as long as none of those variables are not zero
 
Upvote 0

Forum statistics

Threads
1,203,514
Messages
6,055,836
Members
444,828
Latest member
StaffordStag

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