Thread: VBA Question
View Single Post
  #22   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben[_2_] Gord Dibben[_2_] is offline
external usenet poster
 
Posts: 621
Default VBA Question

Carl

MyFile.xls should be ORF.xls

Here is corrected code which works for me in a test on three folders listed in
A1:A3 of Sheet1 of a new workbook...............code is in a module of that new
workbook.

A1............."C:\Gordstuff"
A2............."C"\Mystuff"
A3............."C:\Yourstuff"

Sub test2()
Dim nRow As Integer, nColumn As Integer, n As Integer
Dim sDir As String
nRow = 5
For i = 1 To 3 'where 3 is the range of paths in Sheet1 A1:A3
'adjust as necessary
sDir = Range("A" & i)
n = n + 1
For nColumn = 1 To 25
Sheets(2).Cells(n, nColumn) = ExecuteExcel4Macro _
("'" & sDir & "[ORF.xls]ORF_Charge'!R" & nRow & "C" & nColumn & "")
Next
Next
End Sub


Gord

On Mon, 27 Jun 2011 09:42:59 -0700 (PDT), carl wrote:

On Jun 24, 12:25*am, isabelle wrote:
sorry my fingers are tired a "h" is missing

--
isabelle


Thanks you Isabelle.

I am using Excel2003 SP1 (11.6355.6360)

I tried to use this one (of the 2 your offerred)

Sub test2()
Dim nRow As Integer, nColumn As Integer, n As Integer
Dim sDir As String
nRow = 5
For i = 1 To 1
sDir = Range("A" & i) 'Range("A1:Ax") contains values like "c:\temp
\"
n = n + 1
For nColumn = 1 To 256
Sheets(2).Cells(n, nColumn) = ExecuteExcel4Macro _
("'" & sDir & "[MyFile.xls]ORF_Charge'!R" & nRow & "C" & nColumn
& "")
Next
Next
End Sub

The macro would prompt a window called "MyFile.xls" - it looked like
an explorer window.

What am I suppose to do at this point ?

Thanks again.