Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default Getting data from a closed wbook

Hello,
Getting data from a closed wbook
it works very well with the CODE 1 below inspired from
http://www.rondebruin.nl/copy7.htm
However, I need to extract data from a cell which address varies per sheet
and has not been named. So I would have expected to use an offset function
from a named cell (see CODE 2 (below)but it does not work. It returns a
#VALUE!
any help would be greatly appreciated
Thanks a million
Caroline


CODE 1:
For i = 1 To N
Dim Name As String
Name = Range("WorksheetName1").Offset(i - 1, 0).Value

Dim mypath As String
mypath = "='" & Range("mypath").Value & "\" & "[" &
Range("WorkbookName").Value & "]" & Range("WorksheetName1").Offset(i - 1,
0).Value & "'!"

'export data
Dim CalcExpt(1 To 3) As String
'DATES
CalcExpt(1) = "YearEnd"
CalcExpt(2) = "Launchyear1"
CalcExpt(3) = "Launchyear2"

'import range
Dim CalcImpt(1 To 3) As Range
'DATES
Set CalcImpt(1) = Sheets(Name).Range("YearEnd")
Set CalcImpt(2) = Sheets(Name).Range("Launchyear1")
Set CalcImpt(3) = Sheets(Name).Range("Launchyear2")
'copy data
For j = 1 To UBound(CalcExpt)

Dim mydata As String
mydata = mypath & CalcExpt(j)

With CalcImpt(j)
.FormulaArray = mydata
.Value = .Value
End With
Next

Next


CODE 2
For i = 1 To N
Dim Name As String
Name = Range("WorksheetName1").Offset(i - 1, 0).Value

Dim mypath As String
mypath = "=OFFSET('" & Range("mypath").Value & "\" & "[" &
Range("WorkbookName").Value & "]" & Range("WorksheetName1").Offset(i - 1,
0).Value & "'!"
Dim str As String
str = ",-1,-1)"

'export data
Dim CalcExpt(1 To 1) As String
CalcExpt(1) = "Step2Cell1"

Dim CalcImpt(1 To 1) As Range
Set CalcImpt(1) = Sheets(Name).Range("Step2Cell1")

For j = 1 To UBound(CalcExpt)

Dim mydata As String
mydata = mypath & CalcExpt(j) & str

With CalcImpt(j)
.FormulaArray = mydata
.Value = .Value
End With
Next
Next


Reply
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
Getting data from a closed wbook Geoff K Excel Programming 45 October 6th 09 04:33 PM
updating wbook from other... sal21 Excel Programming 0 November 9th 05 06:49 PM
transfering data from 2 wbook sal21 Excel Programming 8 August 29th 05 12:36 PM
transfering data value from 2 Wbook... sal21[_68_] Excel Programming 0 August 25th 05 09:26 PM
Read And Write On A Closed Wbook sal21[_47_] Excel Programming 2 November 11th 04 11:10 PM


All times are GMT +1. The time now is 04:20 PM.

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"