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

I have a macro which defines the active workbook as aWB and the open
workbook as oWB. I'd like to define cell data as in the active workbook
based on what's in the open workbook.

I'd like to have something like this:

Cells(i,"H").Value = formula with info from oWB.

It looks something like this:

=MATCH(G$3,[Book1]Sheet1!$33:$33) in the EXCEL worksheet.

Where [Book1] is the open workbook.

How do I write this formula so that I get the VALUE in the listed cell
instead of the formula? I can get the formula, but want the value.

Alternatively, I can copy paste/special each row of data before I close
oWB, but if there's a more elegant way, I'd like to use it.

Thanks in advance.

Barb Reinhardt



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Extracting data from a closed workbook

I used this hope it helps?.
Regards
Charles

Sub TestGetValue()
'
p = Range("A1").Value
f = Range("A2").Value
s = Range("A3").Value
a = Range("A4").Value
MsgBox GetValue(p, f, s, a)
End Sub


Public Function GetValue(path, file, sheet, ref)
Dim arg As String
If Right(path, 1) < "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If

arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)

GetValue = ExecuteExcel4Macro(arg)

End Function


"Barb Reinhardt" wrote:

I have a macro which defines the active workbook as aWB and the open
workbook as oWB. I'd like to define cell data as in the active workbook
based on what's in the open workbook.

I'd like to have something like this:

Cells(i,"H").Value = formula with info from oWB.

It looks something like this:

=MATCH(G$3,[Book1]Sheet1!$33:$33) in the EXCEL worksheet.

Where [Book1] is the open workbook.

How do I write this formula so that I get the VALUE in the listed cell
instead of the formula? I can get the formula, but want the value.

Alternatively, I can copy paste/special each row of data before I close
oWB, but if there's a more elegant way, I'd like to use it.

Thanks in advance.

Barb Reinhardt




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Extracting data from a closed workbook

Entering the formula programmatically and then using Copy + Paste Special...
| Values is probably the most reliable way to go. Of course, you don't have
to operate on one cell at a time. Instead, operate on entire ranges at one
go.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Custom business solutions leveraging a multi-disciplinary approach


"Barb Reinhardt" wrote:

I have a macro which defines the active workbook as aWB and the open
workbook as oWB. I'd like to define cell data as in the active workbook
based on what's in the open workbook.

I'd like to have something like this:

Cells(i,"H").Value = formula with info from oWB.

It looks something like this:

=MATCH(G$3,[Book1]Sheet1!$33:$33) in the EXCEL worksheet.

Where [Book1] is the open workbook.

How do I write this formula so that I get the VALUE in the listed cell
instead of the formula? I can get the formula, but want the value.

Alternatively, I can copy paste/special each row of data before I close
oWB, but if there's a more elegant way, I'd like to use it.

Thanks in advance.

Barb Reinhardt




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
Get Data From Closed Workbook Minitman Excel Worksheet Functions 20 March 18th 08 09:50 PM
add data to a closed workbook Spencer Hutton Excel Programming 2 April 9th 05 07:16 PM
PUT data in closed workbook Max Potters Excel Programming 5 August 18th 04 01:33 PM
getting data from closed workbook onedaywhen Excel Programming 0 April 2nd 04 09:10 AM
getting data from closed workbook onedaywhen Excel Programming 0 April 2nd 04 09:08 AM


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

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

About Us

"It's about Microsoft Excel"