+ Reply to Thread
Results 1 to 3 of 3

Running Macro on same row in two worksheets

  1. #1
    Registered User
    Join Date
    12-11-2012
    Location
    Columbia, South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    4

    Running Macro on same row in two worksheets

    I know this has been asked many times on many different forums, which is where I got the code I'm using, but I just can't seem to get it to work correctly. My workbook has five worksheets, and my code is supposed to insert a blank row at the same spot on two of them, copying the formulae from the row above. However, all it ends up doing is inserting five blank rows with the formulae in the worksheet the user is viewing. Now, I did combine two codes from two different places, so I'm sure the problem is I didn't combine them properly (one for inserting the blank row, the other for doing it across multiple worksheets). The two worksheets I want this code to run on are labeled "Register" and "Budget". Here's my code:

    Please Login or Register  to view this content.
    Thanks for the help!
    Last edited by dale040205; 12-12-2012 at 08:03 AM. Reason: added code tags

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Running Macro on same row in two worksheets

    Hi, dale040205,

    although you loop through all sheets the code will always be performed on the active sheet due to the fact that there is no indication for VBA to apply it to different worksheets.

    Maybe give this code a try:
    Please Login or Register  to view this content.
    And please use Code-Tags to display the code as requested per Forum-Rules.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    12-11-2012
    Location
    Columbia, South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Running Macro on same row in two worksheets

    That worked great, thank you. Added code tags to original post!

+ 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