+ Reply to Thread
Results 1 to 5 of 5

Applying Macro across several worksheets

  1. #1
    Registered User
    Join Date
    01-28-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    26

    Applying Macro across several worksheets

    Hi all,

    Can someone help me with this problem please?

    I have a spreadhseet with data in tables across several worksheets, I need to amalgamate all the tables into one single table. The macro I came up with is below, but I can't find a way to make it apply to all the worksheets. Any help would be greatly appreciated.

    Thanks

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+C
    '
    Windows("FORECAST 3.1F NEW.xlsx").Activate
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Windows("Forecast Exports Combined.xlsm").Activate
    ActiveSheet.Paste
    Range("A1").Select
    Selection.End(xlDown).Select
    Range("A9").Select
    End Sub

  2. #2
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Applying Macro across several worksheets

    Hi there,
    I don't know if this can be of help as I don't have much experience in VBA but you can try the following:

    Please Login or Register  to view this content.
    Hopefully this does the trick.

  3. #3
    Registered User
    Join Date
    01-28-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Applying Macro across several worksheets

    Thanks for reply sans, it didn't work. I wonder if there is something not right with my macro coding?
    Last edited by daniel_t; 10-31-2012 at 11:15 AM.

  4. #4
    Registered User
    Join Date
    01-28-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Applying Macro across several worksheets

    I've figured it out, thanks for the help!

    These were the codes that worked -

    Sub Macro13()
    '
    ' Macro13 Macro
    '
    ' Keyboard Shortcut: Ctrl+p
    '
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Windows("Book6.xlsm").Activate
    Range("A1").Select
    Selection.End(xlDown).Select
    Rows("2:2").Select
    Selection.Insert Shift:=xlDown
    Range("A1").Select
    Selection.End(xlDown).Select
    Rows("10:10").Select
    Application.CutCopyMode = False
    Range("A7").Select
    Selection.End(xlDown).Select
    End Sub

    ----------------------------------------------------------

    Sub Run_All_Sheets()
    Dim wb As Workbook, ws As Worksheet
    Set wb = ActiveWorkbook
    For Each ws In wb.Worksheets
    With ws
    .Activate
    ' Macro13 Macro
    '
    ' Keyboard Shortcut: Ctrl+p
    '
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Windows("Book6.xlsm").Activate
    Range("A1").Select
    Selection.End(xlDown).Select
    Rows("2:2").Select
    Selection.Insert Shift:=xlDown
    Range("A1").Select
    Selection.End(xlDown).Select
    Rows("10:10").Select
    Application.CutCopyMode = False
    Range("A7").Select
    Selection.End(xlDown).Select
    End With
    Next ws
    End Sub

  5. #5
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Applying Macro across several worksheets

    You are welcome. I am glad I was able to be of help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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