Macro Stops When Using Shortcut Key

MehmetYıldız

New Member
Joined
Dec 19, 2012
Messages
20
Hello Everyone,

I am very new about VBa and i really request your help.
I have a macro stored a module at Personel workbook and i am using personel workbook as a hidden one.
when i assign a shortcut below macro it is not working but whrn i am press F5 at VBA Editor it is working.
Please help me for this :)
Here is the code:
Code:
Sub Transferdata()


On Error GoTo err1:


Application.DisplayAlerts = False


ms2 = MsgBox("Do You Want To Create Uploading File?", vbInformation + vbYesNo, "Info,")


If ms2 = vbYes Then


ms1 = InputBox("What is the Type of Your Data", "Select Data Type", "Account")


m1 = ActiveWorkbook.Name


If ms1 = "Account" Then


Application.ScreenUpdating = False


Range("A5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
selfpath = Application.ActiveWorkbook.Path
m1 = ActiveWorkbook.Name
Workbooks.Open (selfpath & "\" & "Genel Format-1.xlsm")


    ActiveWorkbook.ActiveSheet.Range("E2").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
Workbooks(m1).Activate
Range("B5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks("Genel Format-1.xlsm").Activate
    Range("G2").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False


Range("K2").Select
Application.ScreenUpdating = True
'Application.SendKeys("%{DOWN}")


Else
Application.ScreenUpdating = False
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
selfpath = Application.ActiveWorkbook.Path
m1 = ActiveWorkbook.Name
Workbooks.Open (selfpath & "\" & "Genel Format-2.xlsm")


    Range("B2").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False


Workbooks(m1).Activate
Selection.Offset(0, 1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks("Genel Format-2.xlsm").Activate
Range("E2").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
Workbooks(m1).Activate
Selection.Offset(0, 2).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks("Genel Format-2.xlsm").Activate
Range("G2").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
Range("K2").Select
Application.ScreenUpdating = True
'Application.SendKeys("%{DOWN}")


End If


Else


ms3 = MsgBox("Operation Cancelled", vbExclamation, "Info,")


End If


Application.CutCopyMode = False


Exit Sub


err1:


ms4 = MsgBox("An Error Encountered. Please Check Your Inputs")
End Sub
 
Last edited by a moderator:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Not home to post any code but what I would do first of all is remove the on error goto statement and the displayalerts false and see what you get when you try running the code.

Edit: Actually thinking about it is your shortcut key referencing the personal workbook?
 
Last edited:
Upvote 0
thanks for your help. when i assign home key instead of ctrl+shift combination it is fixed.

for your comment, ı think i can post a code at here. everybody is doing and i can't see a prohibition for this

Not home to post any code but what I would do first of all is remove the on error goto statement and the displayalerts false and see what you get when you try running the code.

Edit: Actually thinking about it is your shortcut key referencing the personal workbook?
 
Upvote 0
There is a bug that stops code dead if you use a Workbooks.Open call and use a shortcut key involving the shift key. Any other key combination should be OK.

I think Mark was saying that he couldn't post code currently, not that you shouldn't.

However, in future please do not bump your question so often. It will often actually reduce your chances of getting help, and it's against the guidelines (since the forum would be chaotic if everyone did that!).
 
Upvote 0

Forum statistics

Threads
1,216,066
Messages
6,128,586
Members
449,461
Latest member
jaxstraww1

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