Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
With this code in a standard module in a workbook named "Copy of Vehicle Quotation Internal V7a" and I save it as a workbook named "My New Workbook 1" how can I get the code to now reference the new name.
Where in the code below this line of code: Set wbSource = Workbooks("Copy of Vehicle Quotation Internal V7a.xlsm") Will the equivalent of this: Set wbSource = Workbooks("My New Workbook 1.xlsm") I tried using a variable where Dim wbName As WorkBook is set to ActiveWorkbook.Name with Set wbSource = Workbooks(wbName & ".xlsm") but it errors out wanting an object or type mismatch depending on either Dim wbName As Syring or Dim wbName As WorkBook Thanks. Howard Function IsFileOpen(FileName As String) Dim iFilenum As Long Dim iErr As Long On Error Resume Next iFilenum = FreeFile() Open FileName For Input Lock Read As #iFilenum Close iFilenum iErr = Err On Error GoTo 0 Select Case iErr Case 0: IsFileOpen = False Case 70: IsFileOpen = True Case Else: Error iErr End Select End Function Sub MyVQICopy() Dim wbSource As Workbook Dim wbDest As Workbook If Not IsFileOpen("Income Report v2.xlsm") Then Workbooks.Open ("Income Report v2.xlsm") End If Set wbSource = Workbooks("Copy of Vehicle Quotation Internal V7a.xlsm") Set wbDest = Workbooks("Income Report v2.xlsm") wbDest.Sheets("Sheet1").Range("J" & Rows.Count).End(xlUp)(2) = wbSource.Sheets("Sheet1").Range("B2").Value wbDest.Sheets("Sheet1").Range("K" & Rows.Count).End(xlUp)(2) = wbSource.Sheets("Sheet1").Range("D3").Value wbDest.Sheets("Sheet1").Range("L" & Rows.Count).End(xlUp)(2) = wbSource.Sheets("Sheet1").Range("B29").Value wbDest.Sheets("Sheet1").Range("N" & Rows.Count).End(xlUp)(2) = wbSource.Sheets("Sheet1").Range("B19").Value wbDest.Sheets("Sheet1").Range("O" & Rows.Count).End(xlUp)(2) = Time wbSource.Sheets("Sheet1").Range("B2,D3,B29,B19").C learContents End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Save Workbook with existing Name in the Folder | Excel Programming | |||
save workbook without code | Excel Programming | |||
How to save existing Workbook with a new new name, without changingthe open Workbook name? | Excel Programming | |||
Allowing xlBook.SaveAs in Access code to overwrite existing workbook? | Excel Programming | |||
Save Workbook without VBA code | Excel Programming |