Activate worksheet not completely working, sheet viewable, but edits another page

progeb

New Member
Joined
Jul 29, 2016
Messages
2
Hi! I have a "report workbook" with a macro that opens several other existing workbooks, copies data and creates a report on a new worksheet in the "reports workbook". It creates the report fine. While the macro runs, I implement a "progress form" to let me know what the code is doing ("Reading file 1", etc). The report macro ends like this:
Code:
targetWb.Activate
targetWs.Activate
targetWs.Cells(1, 2).Select

progLine1 = progLine1 & vbLf & "Done!"
progressForm.line1.Caption = progLine1
DoEvents

I then close the "progress form" with an Ok button:
Code:
Private Sub okButton_Click()
Application.ScreenUpdating = True
Application.DisplayAlerts = True

Unload progressForm
End Sub

The report is the active/viewable worksheet after I click Ok, but if I edit a cell, it will edit a different worksheet in the workbook (the one I use to initiate the process). This isn't viewable when I make the edit, but if I select that worksheet, I can see the change I made. I can resolve this by clicking another worksheet, and then coming back to the report page. What can I do to correctly activate the report page when the macro completes?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
try setting the workbook and sheet you want so that you're not relying on activeworkbook or worksheet
Code:
set wbk = workbook(workbookname)
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top