Results 1 to 5 of 5

Saving Active Workbook as Variable

Threaded View

  1. #3
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Saving Active Workbook as Variable

    Okay, so right now I use this code to open the workbook.
    Workbooks.Open ("Lorencz:Users:amykate:Desktop:Template.xlt")

    I have some code before it and then more code after it. But at the end, I am wanting to go back to that open template to use it again.

    Where would I put that "Dim wbTemp as Workbook" part?

    Would it be like this? (your code is in bold)
    Sub FTH()
    
        Dim wbTemp as Workbook
    
        Selection.Columns("A:BQ").Copy
    
        Workbooks.Open ("Lorencz:Users:amykate:Desktop:WebconTemplate.xlt")
    
        Sheets("FTH").Select
        Range("A2").Select
        
        Selection.PasteSpecial Paste:=xlValues
        Cells.Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False
    
        Set wbTemp = ActiveWorkbook
    
        Sheets("FTH").Select
        Range("A1").Select
        
       Cells.Find(What:="STOP", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
          :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
          MatchCase:=False).Activate
    
        Range(ActiveCell, "BR2").Copy
        Workbooks("2010_RunningSheet.xls").Worksheets("FTH").Cells _
            (Rows.Count, "C").End(xlUp).Offset(1, -2).PasteSpecial xlPasteValues
    
    End Sub

    And also, what would the activate workbook code look like using that object?

    Like this?
    Workbooks("wbTemp").Activate
    Last edited by amyxkatexx; 03-29-2010 at 03:35 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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