Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I usually have a number of workbooks open at the same time. In a macro I
need to move one sheet from the active workbook to another workbook and then reactivate the original workbook. The original workbook that is open is one of several that begins with RF________________.xls. How do I reactivate the original RF_____________.xls. There is only one workbook with the RF___________.xls name open at a time. TIA Greg |
#2
![]() |
|||
|
|||
![]()
How about something like:
Option Explicit Sub testme() Dim CurWkbk As Workbook Dim OtherWkbk As Workbook Dim FoundIt As Boolean Dim SheetNameToCopy As String SheetNameToCopy = "Sheet1" Set CurWkbk = ActiveWorkbook If LCase(Left(CurWkbk.Name, 2)) = "rf" Then MsgBox "You're in the RF workbook!" Exit Sub End If FoundIt = False For Each OtherWkbk In Application.Workbooks If LCase(Left(OtherWkbk.Name, 2)) = "rf" Then FoundIt = True Exit For End If Next OtherWkbk If FoundIt = True Then CurWkbk.Worksheets(SheetNameToCopy).Copy _ befo=OtherWkbk.Worksheets(1) CurWkbk.Activate Else MsgBox "no RF workbook is open!" End If End Sub GregR wrote: I usually have a number of workbooks open at the same time. In a macro I need to move one sheet from the active workbook to another workbook and then reactivate the original workbook. The original workbook that is open is one of several that begins with RF________________.xls. How do I reactivate the original RF_____________.xls. There is only one workbook with the RF___________.xls name open at a time. TIA Greg -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
HOW DO I SUM TWO CELLS FROM ONE WORKBOOK TO ANOTHER WORKBOOK? | Excel Worksheet Functions | |||
Playing a macro from another workbook | Excel Discussion (Misc queries) | |||
Unprotect Workbook | Excel Discussion (Misc queries) | |||
make hidden window or workbook visible without specify the name | Excel Worksheet Functions | |||
Stubborn toolbars in Excel | Excel Discussion (Misc queries) |