Macro not executing

Seamus2626
Seamus2626 used Ask the Experts™
on
I have the below code.

When another macro1 runs, i want this to run afterwards.

I have tried calling it at the end of macro1. It calls the code but doesnt execute it.

What the code is simply doing is unhiding a tab, changing some headings and rehiding the tab.

But the headings arent changing even though the below macro is being called

Thanks
Seamus



Open in new window


Sub Update3()
'
' Update3 Macro
' Macro recorded 18/10/2010 by seamus
'
' Keyboard Shortcut: Ctrl+s
'

  MsgBox "The call worked"
    Range("F31").Select
    Sheets("COUPONS RAW DATA").Visible = True
    Range("L213").Select
    Selection.End(xlUp).Select
    Selection.End(xlUp).Select
    Selection.End(xlUp).Select
    Range("AM4").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Range("AM4").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Application.CutCopyMode = False
    Selection.Cut
    Range("G6").Select
    ActiveCell.FormulaR1C1 = "Redemption proceeds"
    Range("H6").Select
    ActiveCell.FormulaR1C1 = "End cash"
    Range("I6").Select
    ActiveCell.FormulaR1C1 = "Outstanding cash"
    Range("J6").Select
    ActiveCell.FormulaR1C1 = "Current cash (base)"
    Range("K6").Select
    ActiveCell.FormulaR1C1 = "Failed trade flag"
    Range("L6").Select
    ActiveCell.FormulaR1C1 = "Income type"
    Range("M6").Select
    ActiveCell.FormulaR1C1 = "Item type"
    Range("N6").Select
    ActiveCell.FormulaR1C1 = "P/R"
    Range("O6").Select
    ActiveCell.FormulaR1C1 = "ISIN"
    Range("P6").Select
    ActiveCell.FormulaR1C1 = "Ex date"
    Range("Q6").Select
    ActiveCell.FormulaR1C1 = "Rec date"
    Range("R6").Select
    ActiveCell.FormulaR1C1 = "Pay date"
    Range("S6").Select
    ActiveCell.FormulaR1C1 = "Notes"
    Range("T6").Select
    ActiveCell.FormulaR1C1 = "Request"
    Range("U6").Select
    ActiveCell.FormulaR1C1 = "Age (Days)"
    Range("V6").Select
    ActiveCell.FormulaR1C1 = "Age category"
    Range("W6").Select
    ActiveCell.FormulaR1C1 = "Rqst no"
    Range("X4").Select
    Range(Selection, Selection.End(xlToLeft)).Select
    Selection.ClearContents
    Range("A5").Select
    Sheets("BY YEAR").Select
    Range("I8").Select
    Sheets("COUPONS RAW DATA").Select
    Range("D43").Select
    ActiveWindow.SelectedSheets.Visible = False
    Sheets("BY YEAR").Select
    Range("G12").Select
End Sub
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
VBA Developer
Commented:
Try adding this after you unhide the sheet:

Sheets("COUPONS RAW DATA").Activate


Sub Update3()
'
' Update3 Macro
' Macro recorded 18/10/2010 by seamus
'
' Keyboard Shortcut: Ctrl+s
'

  MsgBox "The call worked"
    Range("F31").Select
    Sheets("COUPONS RAW DATA").Visible = True
    Sheets("COUPONS RAW DATA").Activate
    Range("L213").Select
    Selection.End(xlUp).Select
    Selection.End(xlUp).Select
    Selection.End(xlUp).Select

'etc.

Author

Commented:
Genius, i am humbled in your presence!!

Thank you very much Broomee9.

Out of interest. What is the reason it faisl to call w/o that line?
TracyVBA Developer

Commented:
Thanks for the grade!

When you call this macro you are on a certain sheet, let's call it 'x'.  When you unhide a different sheet, let's call it 'y', all the macro does is unhide 'y', but the active sheet is still 'x'.  So the way your macro is written, it will only add your headings and what not on the active sheet.  That's why the sheet being unhid, 'y', needs to get activated first, so that the changes will be made on that sheet ('y').

Author

Commented:
I understand, thanks again.

Seamus

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial