Hi,
I have defined a set of variables 'mydata1', 'mydata2' ... 'mydata35' using the value of a named cell in a closed sheet
I would then like to loop through these variables to complete a repetative bit of code, think it should be possible, but im not sure how?
My code is below, any questions then just ask, thanks.
For i = 1 to 10
FilePath = ThisWorkbook.Worksheets(2).Range("B" & i).Value 'file paths and names are printed on worksheet 2 already
FileName = ThisWorkbook.Worksheets(2).Range("A" & i).Value
JustPath = Left(FilePath, InStrRev(FilePath, "\"))
'''data location & range to copy
mydata1 = "='" & JustPath & "[" & FileName & "]Sheet1'!" & "NamedCell"
mydata2 = "='" & JustPath & "[" & FileName & "]Sheet1'!" & "AnotherNamedCell"
'etc. etc.
For j = 1 to 35
'''link to worksheet
With ThisWorkbook.Worksheets(1).Cells(i,j) 'I dont want to write out this with loop 35 times
.Formula = mydata & j '<<<<< this is the bit im not sure about
'''convert formula to text
.Value = .Value
End With
Next
Next
Bookmarks