Results 1 to 7 of 7

Macro to prevent switching ActiveBook

Threaded View

savio21 Macro to prevent switching... 12-02-2011, 10:41 AM
Kyle123 Re: Macro to prevent... 12-02-2011, 10:42 AM
savio21 Re: Macro to prevent... 12-02-2011, 12:00 PM
Kyle123 Re: Macro to prevent... 12-02-2011, 12:06 PM
savio21 Re: Macro to prevent... 12-02-2011, 02:12 PM
royUK Re: Macro to prevent... 12-02-2011, 02:28 PM
savio21 Re: Macro to prevent... 12-02-2011, 02:43 PM
  1. #1
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Macro to prevent switching ActiveBook

    Hi All,

    I have the following code in a UserForm to copy a range of cells and paste it into a new workbook.

        
    Sheets("YoYMats").Select
        Range("a1:s25").Select
        Selection.Copy
        Workbooks.Add
        ActiveSheet.Paste
    Unfrotunately, when I do this it makes the new workbook the Active Workbook and the above code fails when it is run a second time. I should also note, I do not want the user to see the workbook behind the UserForm. My current solution to the above problem was to add this code after the paste:

    Windows("GHG Calculator NM v3.xlsm").Activate
    This works well until the user saves the file as another name, then the code fails and i need to manually go in and update it. Is there a way for me to set the workbook with the macros as always the ActiveWorkbook?

    Thanks in advance for your help.
    Last edited by savio21; 12-02-2011 at 02:44 PM.

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