rmccafferty
Board Regular
- Joined
- Jul 16, 2009
- Messages
- 60
This is an excel macro and I just cannot get one variable to set a value. I have rem'd out most of the lines of the below trying to eliminate any other issues that could cause the problem. I am trying to set two variables as worksheets (Ws1 and Ws2) to excel files. And eventually I want to copy data from one to the other.
The Ws1 variable works just fine with everything else Rem's out.
When I rem out everything but the Dim and Set for Ws2, I get an error message whatever I do. I eventually set up a file named A, with a Sheet named A. And every time I run the code, I get an error with the "set Ws2" line highlighted. The lines of code break in the below due to the short width of the window. But the Set Ws1 that is 3 lines long here is only 1 line long in my code. I believe the only two lines not rem'd out are the Dim and Set commands for Ws2.
'Dim Ws1 As Worksheet
Dim Ws2 As Worksheet
' Set Ws1 = Workbooks("tAVRHeartTeamEvaluation_Data_scsv_041011.xls").Sheets("tAVRHeartTeamEvaluation_Data")
Set Ws2 = Workbooks("A.xls").Sheets("A")
' Set Ws2 = Workbooks("Book2.xls").Sheets("Sheet1")
If anyone can tell me what is wrong, I would greatly appreciate it.
The Ws1 variable works just fine with everything else Rem's out.
When I rem out everything but the Dim and Set for Ws2, I get an error message whatever I do. I eventually set up a file named A, with a Sheet named A. And every time I run the code, I get an error with the "set Ws2" line highlighted. The lines of code break in the below due to the short width of the window. But the Set Ws1 that is 3 lines long here is only 1 line long in my code. I believe the only two lines not rem'd out are the Dim and Set commands for Ws2.
'Dim Ws1 As Worksheet
Dim Ws2 As Worksheet
' Set Ws1 = Workbooks("tAVRHeartTeamEvaluation_Data_scsv_041011.xls").Sheets("tAVRHeartTeamEvaluation_Data")
Set Ws2 = Workbooks("A.xls").Sheets("A")
' Set Ws2 = Workbooks("Book2.xls").Sheets("Sheet1")
If anyone can tell me what is wrong, I would greatly appreciate it.