Link to home
Start Free TrialLog in
Avatar of mikes6058
mikes6058

asked on

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
Avatar of Rob Henson
Rob Henson
Flag of United Kingdom of Great Britain and Northern Ireland image

At the end of macro 1 put:

Call parseLISsalesdata

Thanks
Rob H
ASKER CERTIFIED SOLUTION
Avatar of Rob Henson
Rob Henson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
@Rob
You posted while I was typing. It's tie. :)
What a coincidence! I once again posted after 10 seconds. You are very fast indeed. :)
Avatar of mikes6058
mikes6058

ASKER

Oh you guys! I'll split the winnings on this occasion!

Mike
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. :)