Updated specific locations to be searchable, take a look at Las Vegas as an example.

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Reference external workbook using variable inside an if statement
Post Body

Hi all,

I've just started learning vba and have a question that conventional google hasn't managed to help me with... I want to do an if statement which would look on a specified sheet in a different workbook.

The full filepath of the different workbook is: C:\BantersaurusRex\.....\DifferentWorkbook.xls

I have made a variable called WBTarget which is equal to the above directory.

My If formula looks like: If Workbooks(WBTarget).Sheets("Sheet1").Cells(r, Columns("C").Column).Value = [some criteria here]

I get a debug runtime error: 9 on the line above but can't figure out how to properly reference an external sheet within an if function...

Any help would be much appreciated!

Author
Account Strength
90%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
751
Link Karma
16
Comment Karma
735
Profile updated: 2 days ago
Posts updated: 2 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago