+ Reply to Thread
Results 1 to 4 of 4

how to get macro to run only in ThisWorkbook

  1. #1
    Registered User
    Join Date
    01-22-2014
    Location
    Potosi, MO
    MS-Off Ver
    Excel 2013
    Posts
    64

    how to get macro to run only in ThisWorkbook

    Below is a section of code from a macro that just does some copy and paste special stuff. It goes back and forth from NEW EOD.xlsm, and EODHistory.xlsm. How would I go about making sure that it only does these things to the workbook the macro is in? This macro is called upon from another workbook, and I got some pasted stuff on another workbook that was running a macro at the same time. Thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: how to get macro to run only in ThisWorkbook

    It looks like some of the macro got cut off at the bottom.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270

    Re: how to get macro to run only in ThisWorkbook

    Here is an example

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: how to get macro to run only in ThisWorkbook

    Scott,

    Are you always copying the same ranges? There may be a more efficient way of doing this...

    What exactly would you like to happen?

  5. #5
    Registered User
    Join Date
    01-22-2014
    Location
    Potosi, MO
    MS-Off Ver
    Excel 2013
    Posts
    64

    Re: how to get macro to run only in ThisWorkbook

    This was the only way that I could get it to work, I think because of merged cells. When I would try to do more range's at once, I would get an error. I tried just copying everything on the tab (which is what im doing one at a time in this macro above) and pasting special, but it didn't work. I want everything on the tab copied over with formatting, etc...however, all of those ranges are referencing cells from other tabs...So I didn't want to just copy and paste the whole thing, because it copies the formulas. I just want it to copy and paste it, just how it looks. Because the same page is cleared by a macro everyday, and then new info is entered. The macro above just copies and pastes (one range at a time) until I have it all, and says it in another work book, so that we can go back and look at what was entered on each day.

+ 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. [SOLVED] Overwrite Thisworkbook code with Macro
    By Fean in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-16-2013, 08:27 AM
  2. Excel Macro Problem with ThisWorkBook - Not sure how to fix
    By kgaebler in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2012, 11:11 AM
  3. Deleting a macro in thisworkbook
    By polska2180 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-26-2007, 03:05 PM
  4. Module1 vs Thisworkbook for Macro
    By Craigm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-28-2005, 08:17 AM
  5. RE: Help with ThisWorkbook:macro as it currenly exists
    By David in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-27-2005, 05: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