+ Reply to Thread
Results 1 to 6 of 6

Run 2 Macros with one Shortcut key

  1. #1
    Registered User
    Join Date
    02-18-2015
    Location
    HOLLAND MI
    MS-Off Ver
    WINDOWS 7 PROFESSIONAL
    Posts
    61

    Run 2 Macros with one Shortcut key

    Good morning,

    Is there a way to run both the Macros below with one Short cut key?

    I have tried combining the Macros... something goes wrong.

    I have tried:
    Sub CallMacros()
    CopySource
    CopyTrend
    End Sub
    ...something goes wrong.

    Sub CopySource()

    Dim rngSource As Range
    Dim rngTarget As Range
    Dim iRow As Integer

    Set rngSource = Worksheets("DATA").Range("Source")
    iRow = Worksheets("MERGED").Cells(Rows.Count, 1).End(xlUp).Row + 1
    Set rngTarget = Worksheets("MERGED").Range("B" & iRow)
    rngSource.Copy Destination:=rngTarget

    Range("A6:G25").Select
    ActiveWorkbook.Worksheets("SUMMARY").SORT.SortFields.Clear
    ActiveWorkbook.Worksheets("SUMMARY").SORT.SortFields.Add Key:=Range("G6:G25") _
    , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("SUMMARY").SORT
    .SetRange Range("A6:G25")
    .Header = xlGuess
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    Range("A1").Select

    End Sub
    AND
    Sub CopyTrend()

    Range("E3:F22").SORT Key1:=Range("F3"), Order1:=xlAscending, _
    Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

    Dim column_number As Long
    column_number = ActiveSheet.Cells.Find(What:="*", After:=Range("IV65536"), SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
    Range(Cells(3, column_number), Cells(22, column_number + 1)).Value = Range("E3:F22").Value

    End Sub

    Thanks for any help!

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Run 2 Macros with one Shortcut key

    Hi, MIGARDEIN,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Run 2 Macros with one Shortcut key

    Hi Migardein,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between
    Please Login or Register  to view this content.
    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  4. #4
    Registered User
    Join Date
    02-18-2015
    Location
    HOLLAND MI
    MS-Off Ver
    WINDOWS 7 PROFESSIONAL
    Posts
    61

    Re: Run 2 Macros with one Shortcut key

    Me again...

    I think the problem might be that my second Macro:
    Sub CopyTrend()

    Range("E3:F22").SORT Key1:=Range("F3"), Order1:=xlAscending, _
    Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

    Dim column_number As Long
    column_number = ActiveSheet.Cells.Find(What:="*", After:=Range("IV65536"), SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
    Range(Cells(3, column_number), Cells(22, column_number + 1)).Value = Range("E3:F22").Value
    End Sub

    the part in red... is not specifis to a worksheet.
    Anyone know how I can do that?

    Thanks

  5. #5
    Registered User
    Join Date
    02-18-2015
    Location
    HOLLAND MI
    MS-Off Ver
    WINDOWS 7 PROFESSIONAL
    Posts
    61

    Re: Run 2 Macros with one Shortcut key

    Sorry... and Thanks.

    I will close this thread.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Run 2 Macros with one Shortcut key

    Hi, MIGARDEIN,

    you would still have to comply with the rule pointed out above (and that is not to start new thread at http://www.excelforum.com/excel-prog...rtcut-key.html which is against Forum Rule 5).

    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Creating Almost Duplicate Macros Shortcut
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 35
    Last Post: 10-16-2012, 12:23 PM
  2. [SOLVED] Shortcut keys assigned to macros/functions in excel
    By Max in forum Excel Formulas & Functions
    Replies: 33
    Last Post: 09-12-2005, 10:05 PM
  3. Shortcut keys assigned to macros/functions in excel
    By Max in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-06-2005, 07:05 AM
  4. [SOLVED] Running macros from shortcut keys
    By Darren Hill in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-18-2005, 11:05 PM
  5. Changing shortcut keys on macros
    By WayneB in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-13-2005, 04:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1