run 2 macro's consecutively | join snippets

Macro 1
Sub getworkbook()
    ' Get workbook...
    Dim ws As Worksheet
    Dim filter As String
    Dim targetWorkbook As Workbook, wb As Workbook
    Dim Ret As Variant

    Set targetWorkbook = Application.ActiveWorkbook

    ' get the customer workbook
    filter = "Text files (*.xls*),*.xls*"
    Caption = "Please Select an input file "
    Ret = Application.GetOpenFilename(filter, , Caption)

    If Ret = False Then Exit Sub

    Set wb = Workbooks.Open(Ret)

    wb.Sheets(1).Move After:=targetWorkbook.Sheets(targetWorkbook.Sheets.Count)

    ActiveSheet.Name = "DATA"
End Sub

Open in new window


Macro2
Sub parseLISsalesdata()
'
' parseLISsalesdata Macro
'

'
    Rows("1:4").Select
    Selection.Delete Shift:=xlUp
    Columns("A:A").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
        FieldInfo:=Array(Array(0, 2), Array(23, 1), Array(45, 1), Array(63, 1)), _
        TrailingMinusNumbers:=True
    Range("A2:D2").Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    ActiveWorkbook.Worksheets("lissalesaugust").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("lissalesaugust").Sort.SortFields.Add Key:=Range( _
        "A2:A27085"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortTextAsNumbers
    With ActiveWorkbook.Worksheets("lissalesaugust").Sort
        .SetRange Range("A2:D27085")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Set myRng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
    myRng.AutoFilter Field:=1, Criteria1:=Array( _
        "~~~~~~~~~~~", "LOCALINDSUP", "STOCK CODE"), Operator:=xlFilterValues
    myRng.Offset(1).Resize(myRng.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete Shift:=xlUp
    myRng.AutoFilter
End Sub

Open in new window


I would like macro 1 to finish completely and then macro 2 to run straight after.

Macro 1 will import a selected sheet from another workbook into the active workbook. Macro 2 will modify/reorganize the data in the newly imported sheet.

Mike
mikes6058Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rob HensonFinance AnalystCommented:
At the end of macro 1 put:

Call parseLISsalesdata

Thanks
Rob H
0
Rob HensonFinance AnalystCommented:
Alternatively set a third macro to run both:

Sub RunBoth ()

Call getworkbook
Call parseLISsalesdata

End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You can call another macro within the first macro or have a new macro calling both the macros one by one.

Sub getworkbook()
    ' Get workbook...
    Dim ws As Worksheet
    Dim filter As String
    Dim targetWorkbook As Workbook, wb As Workbook
    Dim Ret As Variant

    Set targetWorkbook = Application.ActiveWorkbook

    ' get the customer workbook
    filter = "Text files (*.xls*),*.xls*"
    Caption = "Please Select an input file "
    Ret = Application.GetOpenFilename(filter, , Caption)

    If Ret = False Then Exit Sub

    Set wb = Workbooks.Open(Ret)

    wb.Sheets(1).Move After:=targetWorkbook.Sheets(targetWorkbook.Sheets.Count)

    ActiveSheet.Name = "DATA"
    Call parseLISsalesdata
End Sub

Open in new window


OR

Sub CallTwoMacros()
Call getworkbook
Call parseLISsalesdata
End Sub

Open in new window

0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Rob HensonFinance AnalystCommented:
Refreshing a web page is a lovely concept, shame it doesn't happen all the time. Been guilty of it myself as well...

Thanks
Rob H
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
@Rob
You posted while I was typing. It's tie. :)
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
What a coincidence! I once again posted after 10 seconds. You are very fast indeed. :)
0
mikes6058Author Commented:
Oh you guys! I'll split the winnings on this occasion!

Mike
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Oh you guys! I'll split the winnings on this occasion!
We both were here to help you, not to get points. Glad we could help. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.