Running a macro via hotkey vs normal method yields two different results..?

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
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You said:
When I run my macro via just launching it via normal methods

What do you define as normal Method?

Do you mean clicking a button or what.





 
Last edited:
Upvote 0
Found it on google!
"[FONT=&quot]Remove the shift key from the shortcut key combination that starts your program.[/FONT][FONT=&quot]If you have a workbook that has a workbook_open event or an auto_open procedure,
then if you open that file with the shift key held down, you stop those
procedures from running.[/FONT]

[FONT=&quot]The shift-key in the shortcut combination confuses excel/vba to stop after you
open a file using one of those shortcut keys."[/FONT]


https://social.msdn.microsoft.com/F...he-macros-selection-window-altf8?forum=isvvba
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
Latest member
laura12345

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