LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default naming two open workbooks

From a blank Excel application (toolbar), I am opening one workbook
("oldSheet"), and then opening another workbook ("newSheet"), and copying
values from the old to the new. I need help identfying each workbook.
I want to declare range objects (i.e. oldSheet and newSheet), but don't know
how. Please help?

So far, I have:

Sub captureData() 'from old
Dim B4 As String, D4 As String, K4 As String, O4 As String
Dim C6 As String, H6 As String, O6 As String
Dim oldSheet 'As Sheet1, newSheet
Set oldSheet = ActiveWorkbook.Sheets(1)
B4 = oldSheet.Range("B4").Value
D4 = oldSheet.Range("d4").Value
K4 = oldSheet.Range("k4").Value
O4 = oldSheet.Range("o4").Value
C6 = oldSheet.Range("c6").Value
H6 = oldSheet.Range("h6").Value
O6 = oldSheet.Range("o6").Value
'to new
Workbooks.Open Filename:="newOne.xls"
ActiveWorkbook.ActiveSheet.Range("b2").Value = B4
ActiveWorkbook.ActiveSheet.Range("e2").Value = D4
ActiveWorkbook.ActiveSheet.Range("b4").Value = K4
ActiveWorkbook.ActiveSheet.Range("b5").Value = O4
ActiveWorkbook.ActiveSheet.Range("c8").Value = C6
ActiveWorkbook.ActiveSheet.Range("f8").Value = H6
ActiveWorkbook.ActiveSheet.Range("o8").Value = O6
End Sub

TIA


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date calculation across workbooks / Workbook naming question. Phil Excel Discussion (Misc queries) 2 February 1st 08 12:55 PM
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. san Excel Programming 1 January 3rd 06 03:22 AM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Naming Workbooks and Sheets Mike Excel Programming 2 February 20th 04 05:55 PM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"