Thread: VBA Question
View Single Post
  #29   Report Post  
Posted to microsoft.public.excel.worksheet.functions
carl carl is offline
external usenet poster
 
Posts: 42
Default VBA Question

On Jun 27, 2:36*pm, Gord Dibben wrote:
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.- Hide quoted text -


- Show quoted text -


Thanks Gord.

I made the changes but the macro still prompts me with the explorer
window to select a file.

I have my list of paths in Sheet 1 A1:A3

Here's the code I am using.

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 5
Sheets(2).Cells(n, nColumn) = ExecuteExcel4Macro _
("'" & sDir & "[ORF.xlsx]ORF_Charge'!R" & nRow & "C" & nColumn &
"")
Next
Next
End Sub


The only change I made was the file extension "xls" to "xlsx" and
nColumn set to 5.