+ Reply to Thread
Results 1 to 12 of 12

Macro to Select Certain Tab

Hybrid View

  1. #1
    Registered User
    Join Date
    03-16-2014
    Location
    Oshkosh, WI
    MS-Off Ver
    Excel 2007
    Posts
    52

    Macro to Select Certain Tab

    This is probably something super easy, but I'm not a macro guy, so help is much appreciated. I have a macro I created that is taking certain sections of a table and pasting them into another workbook. However, right now I can only get the macro to paste into the active sheet of the other workbook. I want my selected cells to be pasted to a specific sheet with the name "Budget". The same with going back to my original workbook I want to make sure it is taking the selection from sheet name "BudgetExport" My macro code is below.


    Sub BudgetExport()
    '
    ' BudgetExport Macro
    ' To Export Budget
    '
    ' Keyboard Shortcut: Ctrl+Shift+X
    '
        Range("D5").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range("D5:O21").Select
        Selection.Copy
        Windows("Budget Updated.xlsb").Activate
        Range("D5").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False][/COLOR]
        Windows("Budget Creator.xlsb").Activate
        Range("D24").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range("D24:O25").Select
        Range(Selection, Selection.End(xlDown)).Select
        Range("D24:O88").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Budget Updated.xlsb").Activate
        Range("D24").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Windows("Budget Creator.xlsb").Activate
        ActiveWindow.SmallScroll Down:=-40
        Range("D24").Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        Range("R8").Select
    End Sub

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to Select Certain Tab

    Hi,

    Maybe

    Sub BudgetExport()
    '
    ' BudgetExport Macro
    ' To Export Budget
    '
    ' Keyboard Shortcut: Ctrl+Shift+X
    
        Sheets("BudgetExport").Range("D5:O21").Copy
        Windows("Budget Updated.xlsb").Activate
        Sheets("Budget").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
    
        Windows("Budget Creator.xlsb").Activate
        Sheets("BudgetExport").Range("D24:O88").Copy
        Windows("Budget Updated.xlsb").Activate
        Sheets("Budget").Range("D24").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
        Range("R8").Select
    End Sub
    It was a little difficult to understand precisely what you want to do in any circumstance since your code was presumably put together by the macro recorder and hence only recorded stuff that happened to be relevant at that time. If you need further advice then upload the workbook and tell us what you want to do, rather than what the macro recorder did.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    03-16-2014
    Location
    Oshkosh, WI
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Macro to Select Certain Tab

    Ok here are the workbooks. I'm hoping that by hitting Ctrl+Shift+X to copy Cells D5:O21 & D24:O88 from "Budget Export" Tab in "Budget Creator" workbook to the same cells in "BBudget" Tab in "Budget Updated" workbook (Paste Values). Enjoy my lovely spreadsheets I started by being bored this winter.
    Thanks for the help.
    Attached Files Attached Files

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to Select Certain Tab

    Hi,

    Sorrty small typo earlier

    Sub BudgetExport()
    '
    ' BudgetExport Macro
    ' To Export Budget
    '
    ' Keyboard Shortcut: Ctrl+Shift+X
    
        Sheets("Budget Export").Range("D5:O21").Copy
        Windows("Budget Updated.xlsb").Activate
        Sheets("Budget").Range("D5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
    
        Windows("Budget Creator.xlsb").Activate
        Sheets("Budget Export").Range("D24:O88").Copy
        Windows("Budget Updated.xlsb").Activate
        Sheets("Budget").Range("D24").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
        Range("R8").Select
    End Sub

  5. #5
    Registered User
    Join Date
    03-16-2014
    Location
    Oshkosh, WI
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Macro to Select Certain Tab

    Sorry, for the delay in reply, but tried this code today and it didn't work. Any ideas?

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to Select Certain Tab

    Just checked again and it works OK for me.

    You'll need to tell me what you mean by 'it didn't work'. Did the macro run but not do anything, did it run but not copy and paste the right data, did it not run at all and debug with an error? If the latter on which line did it halt.

    Have you put this code in the Budget Creator workbook in place of your existing code.

    If so upload the workbooks again with the new code I gave you.

+ 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. macro to select free cell at end of row and run another macro.
    By wynn1964 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2014, 01:05 PM
  2. Stop Macro, Select Cell, Restart Macro
    By tenk283 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2010, 12:48 AM
  3. Pause macro, select file, continue macro
    By DamienC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-18-2008, 07:18 AM
  4. Macro to select certain sheets then perform part of other macro on them only
    By raehippychick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2007, 10:12 AM
  5. [SOLVED] Select a macro button with a macro
    By Spike in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2006, 07:35 AM

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