Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Dynamic execution of a loop

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Dynamic execution of a loop

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)

"Jeroen Kluytmans" wrote in message
om...
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



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
AUTOMATIC EXECUTION VB_User Excel Discussion (Misc queries) 5 December 28th 07 11:48 PM
Macro Execution C Brandt Excel Discussion (Misc queries) 2 July 13th 07 07:23 AM
function execution matty_g Excel Worksheet Functions 11 June 9th 05 10:13 PM
function execution matty_g Excel Worksheet Functions 2 June 9th 05 12:05 AM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 01:35 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"