+ Reply to Thread
Results 1 to 5 of 5

Copied macro keeps referencing original worksheet?

  1. #1
    Registered User
    Join Date
    10-19-2010
    Location
    .
    MS-Off Ver
    .
    Posts
    10

    Copied macro keeps referencing original worksheet?

    I wrote a simple macro that basically extracts data from a worksheet and puts it into a text file. The problem is though when I copy the macro to a different entirely new workbook of the same format and different data, the macro will keep referencing the original workbook and keep extracting data from that one. What do I do?

  2. #2
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: Copied macro keeps referencing original worksheet?

    An easy way is to edit the VB code and change the references manually
    Click on star (*) below if this helps

  3. #3
    Registered User
    Join Date
    10-19-2010
    Location
    .
    MS-Off Ver
    .
    Posts
    10

    Re: Copied macro keeps referencing original worksheet?

    How would I do that? This is my code:

    Please Login or Register  to view this content.
    It's really simple and just pulls off values from the current sheet, pastes them into a new sheet and then saves it as a text file.

  4. #4
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: Copied macro keeps referencing original worksheet?

    :="C:\BID" & j & ".txt",

    This looks like it need to be changed. Change the BID to something else

  5. #5
    Registered User
    Join Date
    10-19-2010
    Location
    .
    MS-Off Ver
    .
    Posts
    10

    Re: Copied macro keeps referencing original worksheet?

    Tried that, didn't work. Confused as to how a string would change anything?

    Is there some code that I could add that would tell it to use the current sheet/workbook as the active sheet to extract data from?
    Last edited by c2q; 08-08-2012 at 10:33 PM.

+ 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