Excuse me, something is wrong again
Standard module :
Public ws1 As Worksheet
Public rCopy As Range
Workbook_Open :
Set ws1 = Sheets("abc")
Set rCopy = ws1.Range("A1")
Third module :
ws1.Select ' Error
rCopy.Select ' Error
Please help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The code you have posted does work.
One reason you may get an error is if you have been debugging your code and at some point had an error and stopped excution, the public variables will no longer be set. You simply need to run the
Workbook_Opensub again (you can run it from the IDE, usingF5)Note, you should take the advise from you last question and use
Set ws1 = Thisworkbook.Sheets("abc"). If you don’t you run the risk thatws1will get set to sheetabcin another workbook, because as written it is equivalent toSet ws1 = ActiveWorkbook.Sheets("abc")