Keyboard Shortcuts, Multiple Workbooks with the same shortcut Open at the same time

Tonycing

New Member
Joined
Jun 6, 2018
Messages
1
I have two workbooks, each with a Keyboard shortcut assigned to the same key stroke combination. Both of the shortcuts do similar things, e.g. delete or add rows, but because the workbooks are different in terms of number of columns and content, the Macro can't work exactly the same in either workbook.

Excel is running the keyboard shortcut for workbook A when I use it in Workbook B, instead of using the shortcut that was programmed in workbook B.

My work-around solution is to only have one of these workbooks open at a time, but does anyone know how to make the keyboard shortcuts and their macros for the active workbook precede other open workbooks?

Thank you!
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,490
Try something like this:
Code:
Sub Workbook_Name()
'Modified 6/6/18 1:55 PM EDT
If ActiveWorkbook.Name = "Book1" Then
Cells(1, 1).Value = "Book1"
End If
If ActiveWorkbook.Name = "Book2" Then
Cells(1, 1).Value = "Book2"
End If
End Sub
Put this same Macro in both Workbooks.
 
Last edited:

Forum statistics

Threads
1,086,235
Messages
5,388,621
Members
402,128
Latest member
Jemx

Some videos you may like

This Week's Hot Topics

Top