Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default loop to name ranges

i have a database of records starting with A5. A5
contains the title of the first record. the range of
data for this record is C5:D9. the next records' title
is in A10. this record has 5 lines, going from C10:D14.
i have a formula that puts the range for the first record
in F5. so F5 = "C5:D9". and the desired name for this
record is in G5. so G5 = "DESIRED RANGE NAME" obviously
each range has a different name. i have this:

Sub NameOptionRanges()

Dim CellF As Range
Dim CellG As Range

For Each CellF In Range("F5:F1000")

If CellF < "" Then
For Each CellG In Range("G5:G1000")
If CellG < "" Then
Range(CellF).Select
Range(CellF).Name = CellG.Value
End If
Next
End If

Next

End Sub

but i can't quite figure out how to make the loops work
right. i want to name the range which is in column F,
with the name located exactly one cell to the right of it
in column G. TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default loop to name ranges

in case anyone doesn't reply, i figured it out, and you
want to see how i did it:

Sub NameOptionRanges()
Dim CellF As Range
For Each CellF In Range("F5:F1000")
If CellF < "" Then
Range(CellF).Name = CellF.Offset(0, 1).Value
End If
Next
End Sub


-----Original Message-----
i have a database of records starting with A5. A5
contains the title of the first record. the range of
data for this record is C5:D9. the next records' title
is in A10. this record has 5 lines, going from C10:D14.
i have a formula that puts the range for the first

record
in F5. so F5 = "C5:D9". and the desired name for this
record is in G5. so G5 = "DESIRED RANGE NAME" obviously
each range has a different name. i have this:

Sub NameOptionRanges()

Dim CellF As Range
Dim CellG As Range

For Each CellF In Range("F5:F1000")

If CellF < "" Then
For Each CellG In Range("G5:G1000")
If CellG < "" Then
Range(CellF).Select
Range(CellF).Name = CellG.Value
End If
Next
End If

Next

End Sub

but i can't quite figure out how to make the loops work
right. i want to name the range which is in column F,
with the name located exactly one cell to the right of

it
in column G. TIA
.

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
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
how copy formula that contains ranges so ranges do not overlap Patty Excel Worksheet Functions 1 November 20th 08 04:15 PM
Help With Loop Dennis Excel Worksheet Functions 2 February 1st 05 08:04 AM
How to loop through all ranges in a worksheet Nanette[_2_] Excel Programming 6 January 12th 04 07:30 PM
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 04:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"