Macro hangs up after opening a second workbook

melodramatic

Board Regular
Joined
Apr 28, 2003
Messages
180
Office Version
  1. 365
Platform
  1. Windows
I am having a strange problem come up that I've never seen before. Hoping someone can tell me where I've glitched my code, so I can fix it and quit feeling like an idiot.

I am running a macro that pulls a list of new projects and enters the data into the Audit Log. The problem I'm having is that the Audit Log opens, and then the macro freezes on that page. No going further, no messages, no anything.

If for some reason I already have the Audit Log open, then the macro runs full-out, without a hiccup to be had.

Is there something that I'm doing wrong on the opening of that second file that keeps it from going on from there?

While this isn't an emergency (I can simply let it stop, then go back to wb1 and hit the macro again, and since the Audit Log is open, it works then), it's frustrating as heck. Hoping someone can help me.

Thank you so much for taking the time to look at this!


Code:
Sub ProjectTasks()

' Run Audit Log entry & Create New MDR
' Written by Melody October May
' Created Jul 6, 2020

Application.ScreenUpdating = False
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
On Error GoTo ErrorHandler

Dim wb1 As Workbook
Dim wb2 As Workbook
Dim pwd As String
Dim pwdX As String

pwd = Range("Z1")
ActiveWorkbook.Unprotect Password:=pwd
Set wb1 = ActiveWorkbook

Workbooks.Open Filename:="X:\QASystems\Audit Projects Status Log.xlsm"

'THIS IS WHERE MY PROBLEM OCCURS - THE MACRO HANGS UP HERE UNLESS THE LOG IS ALREADY OPEN

     Sheets("All Projects").Select
     Set wb2 = ActiveWorkbook
     pwdX = Range("AB1")
     Set wb2 = ActiveWorkbook

wb1.Activate

'Enter into Audit Projects Log
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try this, I am not sure it will fix it but it's worth a shot.

VBA Code:
        Workbooks.Open Filename:= _
        "X:\QASystems\Audit Projects Status Log.xlsm"
 
Upvote 0
How do you actually trigger the macro, and is there any code in the Workbook_Open event of the Audit log workbook?
 
Upvote 0
OK, I did the smart thing (d'uh!) and turned on display alerts. Turns out the hang-up was actually a few lines further down (which I didn't include), when I went to do the entry - I used the wrong password (pwdX instead of pwd) to unprotect the sheet.

I apologize for throwing out a "help me" that was nothing more than user sloppiness. I thank you both for pitching in on this :)
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,161
Members
448,948
Latest member
spamiki

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