+ Reply to Thread
Results 1 to 4 of 4

[Solved] How to make macros code reference data in open sheet

  1. #1
    Registered User
    Join Date
    07-27-2015
    Location
    Canada
    MS-Off Ver
    15.0.4
    Posts
    33

    [Solved] How to make macros code reference data in open sheet

    Thanks in advance for your help.

    I created a macros that makes a chart based on my data in sheet 1 of my workbook. I have 50 sheets with data in the same tempate and format, and I'd like to be able to run this macros to create a new chart on each sheet. Unfortunately when I recorded the macros (with relative referencing on), it created a code that references sheet 1 only. In this case, the sheet is called "ABRZX."

    Is there a way to edit this code to reference data within an open sheet?

    Thank you!


    Please Login or Register  to view this content.
    Last edited by MontrealMTL; 08-16-2015 at 06:01 PM.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: How to make macros code reference data in open sheet

    You could make a copy and try this, if what you mean by open sheet as meaning the sheet that is active when you run the macro.

    Add this code at the top of your macros under the Sub statement.
    Please Login or Register  to view this content.
    Then use find and replace in the code window to search for this.
    "=ABRZX
    and replace it with this.
    "=" & strSheetName & "

    Make sure to try it on a copy.

    As an example:
    This: "=ABRZX!$A$3"
    Should be this after find and replace: "=" & strSheetName & "!$A$3"
    Last edited by skywriter; 08-16-2015 at 04:55 PM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    07-27-2015
    Location
    Canada
    MS-Off Ver
    15.0.4
    Posts
    33

    Re: How to make macros code reference data in open sheet

    Solved! Thank you

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: How to make macros code reference data in open sheet

    Quote Originally Posted by MontrealMTL View Post
    Solved! Thank you
    Thanks for marking the thread solved and for the rep. points.

+ 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. how to make workbook open code specific to a sheet
    By whitwoo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2014, 01:16 PM
  2. Replies: 1
    Last Post: 01-07-2014, 04:59 AM
  3. How can i make Outlook open before(or while) running a code?
    By Legend Rubber in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-01-2013, 11:50 AM
  4. Replies: 5
    Last Post: 01-09-2013, 04:06 AM
  5. MACROS to make Sheet 1 look like Sheet 2 (Re arranging)
    By taimysho0 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-03-2013, 05:29 PM
  6. How to open a spreadsheet and make changes to it from code?
    By lanem in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2006, 07:20 PM
  7. How to make a button VBA code reference other VBA code subroutines???
    By gunman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2005, 08:05 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