knittelmail
New Member
- Joined
- Jun 28, 2023
- Messages
- 21
- Office Version
- 365
- Platform
- Windows
I have a macro that is a collection of smaller macros that are sometimes themselves a collection of smaller macros. This "big" macro is tied to a button on a worksheet.
The first time I push the button, the macro stops running after the first step. If I keep the worksheet open, manually clean up the mess after the first try, and push the button again, it will complete. It will complete every time until I have to close the worksheet, but won't the next time I open it. My code is ugly, but aside from this one issue, it does what I want it to. Does anyone have any ideas as to why it doesn't work the first time, but does the second? I will try to answer any questions you have. Thank you in advance!
Here is the part where it gets stuck:
Sub ImportandCopy()
Application.Run "PERSONAL.XLSB!GetReport"
---- this is where it gets stuck
Application.Run "PERSONAL.XLSB!UnmergeUnwrap"
Range("A1").Select
Application.Run "PERSONAL.XLSB!Delete_Columns"
Application.Run "PERSONAL.XLSB!CleanStations"
Application.Run "PERSONAL.XLSB!CopyHeader"
Application.Run "PERSONAL.XLSB!CopyStations"
Application.Run "PERSONAL.XLSB!SetBoldValueinCells"
Application.Run "PERSONAL.XLSB!ConvertNums"
Application.Run "PERSONAL.XLSB!FinalCleanUp"
End Sub
The code for "PERSONAL.XLSB!GetReport"
Sub GetReport()
Workbooks.Open Filename:="H:\Production Records\Production Print\Report.xlsx"
Sheets("Report").Copy Before:=Workbooks("Revised Formula Sheet A.xlsm").Sheets(1)
Workbooks("Report").Close SaveChanges:=False
Sheets("Formula Sheet").Activate
' I read somewhere that slowing the process down might help it run better so that is what the counting loop is for.
Dim x As Integer
For i = 1 To 10000
Range("A2").Value = i
Next i
Range("A2").ClearContents
End Sub
The first time I push the button, the macro stops running after the first step. If I keep the worksheet open, manually clean up the mess after the first try, and push the button again, it will complete. It will complete every time until I have to close the worksheet, but won't the next time I open it. My code is ugly, but aside from this one issue, it does what I want it to. Does anyone have any ideas as to why it doesn't work the first time, but does the second? I will try to answer any questions you have. Thank you in advance!
Here is the part where it gets stuck:
Sub ImportandCopy()
Application.Run "PERSONAL.XLSB!GetReport"
---- this is where it gets stuck
Application.Run "PERSONAL.XLSB!UnmergeUnwrap"
Range("A1").Select
Application.Run "PERSONAL.XLSB!Delete_Columns"
Application.Run "PERSONAL.XLSB!CleanStations"
Application.Run "PERSONAL.XLSB!CopyHeader"
Application.Run "PERSONAL.XLSB!CopyStations"
Application.Run "PERSONAL.XLSB!SetBoldValueinCells"
Application.Run "PERSONAL.XLSB!ConvertNums"
Application.Run "PERSONAL.XLSB!FinalCleanUp"
End Sub
The code for "PERSONAL.XLSB!GetReport"
Sub GetReport()
Workbooks.Open Filename:="H:\Production Records\Production Print\Report.xlsx"
Sheets("Report").Copy Before:=Workbooks("Revised Formula Sheet A.xlsm").Sheets(1)
Workbooks("Report").Close SaveChanges:=False
Sheets("Formula Sheet").Activate
' I read somewhere that slowing the process down might help it run better so that is what the counting loop is for.
Dim x As Integer
For i = 1 To 10000
Range("A2").Value = i
Next i
Range("A2").ClearContents
End Sub