merlynsdad
Programmer
I'm moving data between Excel workbooks. I have the following variables declared at the module level, but just to make sure, I've also got them declared in this sub as well.
Dim wb As Workbook
Dim strName10 As String
Dim strPath10 As String
Dim strName11 As String
Dim strPath11 As String
I have file names and paths for the strName and strPath variables, e.g. strName10 = "myfile.xls"
I'm setting wb as follows:
For Each wb In Application.Workbooks
If wb.Name = strName10 Then
Set wb = Workbooks(strName10)
wb.Activate
ElseIf wb.Name = strName11 Then
Set wb = Workbooks(strName11)
wb.Activate
End If
Next wb
I then do some work, come back to the workbook running the code with
Me.Activate
do some more work, then try to go back to the other workbook with
wb.Activate
At this point I'm getting an "Object Variable or With Block..." error. Since wb was set and activated successfully in the IF THEN statement (I think), why won't it activate now?
Any help is greatly appreciated. Thanks.
Dim wb As Workbook
Dim strName10 As String
Dim strPath10 As String
Dim strName11 As String
Dim strPath11 As String
I have file names and paths for the strName and strPath variables, e.g. strName10 = "myfile.xls"
I'm setting wb as follows:
For Each wb In Application.Workbooks
If wb.Name = strName10 Then
Set wb = Workbooks(strName10)
wb.Activate
ElseIf wb.Name = strName11 Then
Set wb = Workbooks(strName11)
wb.Activate
End If
Next wb
I then do some work, come back to the workbook running the code with
Me.Activate
do some more work, then try to go back to the other workbook with
wb.Activate
At this point I'm getting an "Object Variable or With Block..." error. Since wb was set and activated successfully in the IF THEN statement (I think), why won't it activate now?
Any help is greatly appreciated. Thanks.