Dynamic execution of a loop

  • Thread starter Thread starter Jeroen Kluytmans
  • Start date Start date
J

Jeroen Kluytmans

Dear all,

I have made the loop below, It works fine, but now I am strugling with
the following. I want the Range to be dynamic, the starting point will
always be A8, but in cell C5 there is a number determining the end
point of the loop: So C5 = 5 then the end will be A12, C5 = 10, the
end will be A17. How can I make this?

Dim Rng As Range
Dim sheetname As String

For Each Rng In Range("'Main Data Sheet'!A8:'Main Data
Sheet'!A12")
Sheets.Add
sheetname = [Rng]
ActiveSheet.Name = (sheetname)
Next Rng

Regards,
Jeroen Kluytmans
 
Hi Jeroen,

Dim Rng As Range
Dim sheetname As String

For Each Rng In Range("'Main Data Sheet'!A8").resize(Range("'Main Data
Sheet'!C5").Value)
Sheets.Add
sheetname = [Rng]
ActiveSheet.Name = (sheetname)
Next Rng

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top