+ Reply to Thread
Results 1 to 10 of 10

Moving between sheets in a workbook

  1. #1
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    26

    Moving between sheets in a workbook

    I have 4 sheets in my workbook (11NN, 11NB, 17NN and 17NB) and I need my macro to copy and paste data from a worksheet into a different corresponding worksheet. For example my data goes into 11NN then it gets copied and pasted into 11NB and the same for the two 17 tabs. So I need the macro to know that the data has gone into 11 vs 17 then copy and paste it into 11 and not 17. I am new to VBA and this is my first time making a macro so I hope the explanation isn't confusing. I know that I will need to incorporate variables but I am just not sure exactly how to make this work.

  2. #2
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Moving between sheets in a workbook

    Hi,

    Welcome to the forum

    Is it true to assume that the corresponding sheet (into which the data should be copied) is immediately to the right of the input sheet?
    Regards,
    Rudi

  3. #3
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Moving between sheets in a workbook

    Yes it is immediately to the right. Not sure if it will matter or not but that sheet will be hidden.

  4. #4
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Moving between sheets in a workbook

    TX,

    Hidden should not matter....
    Would you trigger the macro directly after updating the ??NN sheet? In other words when should the macro run?, what data will the macro need to copy and where should the data to be pasted go on the ??NB sheet?

  5. #5
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Moving between sheets in a workbook

    The macro is attached to a button on the NN sheet and will be clicked then the data will be populated from a saved file then copied over to the NB sheet. Both of the sheets are exactly the same so they will be pasted over to the same cells.

  6. #6
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Moving between sheets in a workbook

    Hi,

    Try code like this for each of those worksheet buttons...
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Moving between sheets in a workbook

    Here is part of what I have in that macro. This section fixes some of the formating and highlighting for the sheet. I have bolded the section where I am having trouble. I only want to have to write this once and not put it into each button. So I need this to be able to see what sheet it is in, either 11 or 17, and put it into the 11NB or 17NB that it is linked to.


    Range("C6:AI40").Select
    With Selection.Font
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    End With
    With Selection.Interior
    .Pattern = xlNone
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With
    Selection.ClearComments
    Range("C6:E40,I6:K40,O6:Q40,U6:W40,AA6:AC40,AG6:AI40").Select
    Range("AG6").Activate
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorDark1
    .TintAndShade = -0.249977111117893
    .PatternTintAndShade = 0
    End With
    Range("C6:AI40").Select
    Selection.Copy
    Sheet34.Visible = True
    Sheets("11 NB").Select
    Range("C6").Select
    ActiveSheet.Paste
    Range("A1:B1").Select
    Sheet34.Visible = xlSheetHidden
    Sheets("11 NN").Select
    Application.CutCopyMode = False
    Range("A1:B1").Select

  8. #8
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Moving between sheets in a workbook

    Try this:
    The red part should make this code universal...
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Moving between sheets in a workbook

    So far this has worked! Thank you so much RudiS!

  10. #10
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Moving between sheets in a workbook

    Excellent.... Good to know

+ 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. Replies: 4
    Last Post: 09-15-2012, 02:18 PM
  2. Moving columns from different workbook into one single workbook in different sheets
    By alex0403 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2012, 11:17 AM
  3. [SOLVED] Moving Sheets within a workbook
    By Dan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-04-2006, 06:00 PM
  4. [SOLVED] Moving sheets to another workbook
    By affordsol in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2006, 03:00 PM
  5. Moving Macros with Sheets to New Workbook
    By Brad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2005, 01:06 PM

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