Solved

refer to variable named workbook

Posted on 2011-02-20
7
308 Views
Last Modified: 2012-05-11
Related to a previous question,.
How can I refer to a variable named workbook.

Set wb2 = ThisWorkbook.FullName Replace("Performance", "Scoreboard", , , vbTextCompare)

doesn't work
and I have tried a few combinations.
Sorry if I am a pain.
0
Comment
Question by:Stephen Byrom
  • 3
  • 2
  • 2
7 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34936821
Have you tried:

Set wb2 = application.workbooks.open replace(thisworkbook.FullName, "Performance", "Scoreboard",,,vbTextCompare)
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 34936828
IN fact I missed a bit, brackets!

Set wb2 = Application.Workbooks.Open(Replace(ThisWorkbook.FullName, "Performance", "Scoreboard", , , vbTextCompare))

Chris
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34936829
Hello,

the syntax for the replace function is

Replace(expression, find, replace[, start[, count[, compare]]])

In your previous question (which would have been a lot easier to find if you had posted a related question or included a link to the previous question), this line of code was suggested:

application.workbooks.open replace(thisworkbook.FullName, "Performance", "Scoreboard",,,vbTextCompare)

Your current line of code is missing an element:

>> Set wb2 = ThisWorkbook.FullName Replace("Performance", "Scoreboard", , , vbTextCompare)

You do not state the "expression" bit, but seem to supply the "find", "replace" and "compare" bits only.

I'm not quite sure what you want to achieve, but maybe

Set wb2 =  Replace(ThisWorkbook.FullName, "Performance", "Scoreboard", , , vbTextCompare)

<not tested!>

If that does not help, please post your code in full and explain the context of what you are trying to achieve.

cheers, teylyn
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 1

Author Closing Comment

by:Stephen Byrom
ID: 34936843
Thanks again for the help.
The assistance I get on here also helps me understand more the syntax etc.
Thanks again.

To Teylyn,
I am sorry for not being more helpfull with the links in my original post. I will remember to do that in future.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34936865
FYI, when a question is 'related' you have the option from that closed question to "sk a related question" via the button ... this includes a hyperlink to the original question in your new one and then would perhaps serve to provide the clarification Teylyn suggested.  This is always good because the more relevant info you post the more likely you are to get multiple experts responding and that has to be a good thing for you as the asker.

Chris
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 34936880
Thanks for the tip Chris.
I will remember that in future.
(there will be more questions, there always are)
:)
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34936907
>> (there will be more questions, there always are)

:)

What would life be without challenges?

Glad you found your answer from an expert who knows the subject.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question