Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Retrieving a value at some cell from another Workbook

I want to retrieve some values from an existing Workbook to another one (Two
..XLS files)

What I am doing works, but isn't quite what I want.
After I retrieve a value on a workbook in another directory from other
workbook in a different directory, I get the value on the cell, but if you
mouseover the function it displays the following link:
='D:\directory\[excelfile.xls]Accounting'!$A$12

****I want the value, not the formula I use to get the data. Does .Evaluate
works?****

I use this code to retrieve and save the data:
Public Sub procInserirDados()
....
For n = 7 To 13
h = n
For Each Dados In objFolha(2).Range("A" & n)
objFolha(2).Range("A" & n).Value = _
"='" & strDirectory & "[" & strFile & "]" & strWorkbook &
"'!$A$" & h + 1
Next Dados
Next n
....
end sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Retrieving a value at some cell from another Workbook

The best way is to open the workbook and get the values. Youcould also after
insterting the formula perform a copy and then Paste Values only

Here is code to open the workbook

Public Sub procInserirDados()
'...
Myfile = strDirectory & "\" & strFile
MySheet = strWorkbook

Workbooks.Open Filename:=Myfile
Set oldbk = ActiveWorkbook
With oldbk.Sheets(MySheet)
For n = 7 To 13
h = n
For Each Dados In ThisWorkbook.objFolha(2).Range("A" & n)
ThisWorkbook.objFolha(2).Range("A" & n).Value = _
.Range("A" & (h + 1))
Next Dados
Next n
oldbk.Close savechanges:=False
'...
End Sub


"Joao" wrote:

I want to retrieve some values from an existing Workbook to another one (Two
.XLS files)

What I am doing works, but isn't quite what I want.
After I retrieve a value on a workbook in another directory from other
workbook in a different directory, I get the value on the cell, but if you
mouseover the function it displays the following link:
='D:\directory\[excelfile.xls]Accounting'!$A$12

****I want the value, not the formula I use to get the data. Does .Evaluate
works?****

I use this code to retrieve and save the data:
Public Sub procInserirDados()
...
For n = 7 To 13
h = n
For Each Dados In objFolha(2).Range("A" & n)
objFolha(2).Range("A" & n).Value = _
"='" & strDirectory & "[" & strFile & "]" & strWorkbook &
"'!$A$" & h + 1
Next Dados
Next n
...
end sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Retrieving a value at some cell from another Workbook

Thank you Joel, it works fine, however there's no other way to do it without
opening the retrieving workbook?

Thanks anyway - Big help solved it.

"Joel" wrote:

The best way is to open the workbook and get the values. Youcould also after
insterting the formula perform a copy and then Paste Values only

Here is code to open the workbook

Public Sub procInserirDados()
'...
Myfile = strDirectory & "\" & strFile
MySheet = strWorkbook

Workbooks.Open Filename:=Myfile
Set oldbk = ActiveWorkbook
With oldbk.Sheets(MySheet)
For n = 7 To 13
h = n
For Each Dados In ThisWorkbook.objFolha(2).Range("A" & n)
ThisWorkbook.objFolha(2).Range("A" & n).Value = _
.Range("A" & (h + 1))
Next Dados
Next n
oldbk.Close savechanges:=False
'...
End Sub


"Joao" wrote:

I want to retrieve some values from an existing Workbook to another one (Two
.XLS files)

What I am doing works, but isn't quite what I want.
After I retrieve a value on a workbook in another directory from other
workbook in a different directory, I get the value on the cell, but if you
mouseover the function it displays the following link:
='D:\directory\[excelfile.xls]Accounting'!$A$12

****I want the value, not the formula I use to get the data. Does .Evaluate
works?****

I use this code to retrieve and save the data:
Public Sub procInserirDados()
...
For n = 7 To 13
h = n
For Each Dados In objFolha(2).Range("A" & n)
objFolha(2).Range("A" & n).Value = _
"='" & strDirectory & "[" & strFile & "]" & strWorkbook &
"'!$A$" & h + 1
Next Dados
Next n
...
end sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Retrieving a value at some cell from another Workbook

As I said before. You can add the formula the way you did before. Then copy
the values and use paste special pasting only the values. This will remove
the formulas.

"Joao" wrote:

Thank you Joel, it works fine, however there's no other way to do it without
opening the retrieving workbook?

Thanks anyway - Big help solved it.

"Joel" wrote:

The best way is to open the workbook and get the values. Youcould also after
insterting the formula perform a copy and then Paste Values only

Here is code to open the workbook

Public Sub procInserirDados()
'...
Myfile = strDirectory & "\" & strFile
MySheet = strWorkbook

Workbooks.Open Filename:=Myfile
Set oldbk = ActiveWorkbook
With oldbk.Sheets(MySheet)
For n = 7 To 13
h = n
For Each Dados In ThisWorkbook.objFolha(2).Range("A" & n)
ThisWorkbook.objFolha(2).Range("A" & n).Value = _
.Range("A" & (h + 1))
Next Dados
Next n
oldbk.Close savechanges:=False
'...
End Sub


"Joao" wrote:

I want to retrieve some values from an existing Workbook to another one (Two
.XLS files)

What I am doing works, but isn't quite what I want.
After I retrieve a value on a workbook in another directory from other
workbook in a different directory, I get the value on the cell, but if you
mouseover the function it displays the following link:
='D:\directory\[excelfile.xls]Accounting'!$A$12

****I want the value, not the formula I use to get the data. Does .Evaluate
works?****

I use this code to retrieve and save the data:
Public Sub procInserirDados()
...
For n = 7 To 13
h = n
For Each Dados In objFolha(2).Range("A" & n)
objFolha(2).Range("A" & n).Value = _
"='" & strDirectory & "[" & strFile & "]" & strWorkbook &
"'!$A$" & h + 1
Next Dados
Next n
...
end sub

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
Retrieving Textbox values from another workbook [email protected] Excel Programming 0 August 20th 07 01:54 PM
retrieving cell value from a query linked workbook Candyman Excel Programming 2 March 1st 07 09:00 PM
Retrieving cell formatting from closed workbook paulharvey Excel Programming 1 July 15th 05 02:55 PM
Retrieving cell formatting from closed workbook Paul Harvey Excel Programming 0 July 14th 05 09:48 PM
Retrieving the sheet names of another workbook Aidy[_2_] Excel Programming 1 June 25th 04 07:29 PM


All times are GMT +1. The time now is 06:38 PM.

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"