IREALLYambatman
Board Regular
- Joined
- Aug 31, 2016
- Messages
- 63
So I'm genuinely confused about what is going on here.. When I run my macro via just launching it via normal methods, everything works perfectly. But when I use the hotkey I have set for it.. Ctrl-Shift-A the macro goes haywire and ends up doing the wrong things... I start with the correct workbook being active in either case and I have no clue what is going on to cause this.. help? The "MAIN" Sub is AnionsWater which calls everything else.. I left out the stuff that I'm pretty sure is unrelated...
Code:
Sub AnionsWater()
CallMeLater = ActiveWorkbook.Name
Dim xWB As Workbook 'Close All "Workbooks" that are blank and unsaved
Application.ScreenUpdating = False
For Each xWB In Application.Workbooks
NewOrNot = xWB.Name
If InStr(NewOrNot, "Book") <> 0 Then xWB.Close
Next
Application.ScreenUpdating = True
ActiveSheet.Unprotect "Password"
ActiveWorkbook.Unprotect "Password"
ActiveWorkbook.Worksheets("Edit Here").Activate
ActiveWorkbook.Worksheets("Edit Here").Cells.EntireColumn.AutoFit
'Find the last used column in a Row: row 1 in this example
' With ActiveSheet
With ActiveWorkbook.Worksheets("Edit Here")
LastCol = .Cells(3, .Columns.Count).End(xlToLeft).Column
End With
Call CheckAnalytes
ActiveWorkbook.Worksheets("Edit Here").Activate
Call QForME(CallMeLater)
End Sub
Sub CheckAnalytes()
ActiveSheet.Unprotect "Password"
ActiveWorkbook.Unprotect "Password"
ActiveWorkbook.Worksheets("Edit Here").Activate
ActiveWorkbook.Worksheets("Edit Here").Cells.EntireColumn.AutoFit
With ActiveWorkbook.Worksheets("Edit Here") 'Find Last Column
LastCol = .Cells(3, .Columns.Count).End(xlToLeft).Column
End With
End Sub
Sub QForME(WorkBookName)
'Path to File Containing Macro we want to run is C:\HPLCMacro\HPLCQuant.xls
'Name Of Macro we want to run is - QuantMain
Dim wbb As Workbook
On Error Resume Next
Set wbb = Workbooks("HPLCQuant.xls")
On Error GoTo 0
If wbb Is Nothing Then Set wbb = Workbooks.Open("C:\HPLCMacro\HPLCQuant.xls")
Workbooks(WorkBookName).Activate 'We active the file with our original macro as the macro we're about to run will need to work on that file.
Run "HPLCQuant.xls!QuantMain"
wbb.Close False
Set wbb = Nothing
End Sub