LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Changing range name in loop

Hey group,

I'm having a problem with looping through a macro and
renaming a range accordingly.
First step i name my range . Which i can get. but when the
loop progresses im trying to have it change according to
the amount of times the procedure loops. i was hoping
someone could help me. Thank you in advance.


Jeff

P.s there are notes where im having difficulty



'''''''
Dim DMrng As String
Dim Fname As String
Dim Sierra As String, Yukon As String, Malibu As String
Dim Cnt As Integer
'''sets CNT initial value
Cnt = 0


'''''Loop in question begins
Do
Fname = ActiveWorkbook.Name

'''selects if there is only one cell in range

If ActiveCell.Offset(-1, 0).Value < "" Then Range
(Selection, Selection.End(xlUp)).Name = "DMrng" & Cnt

'' if multiple cells in range the selects
If ActiveCell.Offset(-1, 0).Value = "" Then
ActiveCell.Name = "DMrng" & Cnt

'XXXXXXXXXXXX here is the problem the name i can not
'''XXXXXXXXXXX GET range to be named
correctly'''''''''''''''''''''

Sierra = "=COUNTIF(" & "'" & Fname & "'!" & DMrng &
cnt",Sierra)"
Yukon = "=COUNTIF(" & "'" & Fname & "'!DMrng &
cnt,""Yukon"")"
Malibu = "=COUNTIF(" & "'" & Fname & "'!DMrng &
cnt,""Malibu"")"


ActiveCell.FormulaR1C1 = Sierra
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = Yukon
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = Malibu

Cnt = Cnt + 1
loop until activecell.value= ""
 
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
reset the range of FOR loop Farooq Sheri Excel Discussion (Misc queries) 1 April 7th 09 08:05 PM
Loop through last cell/row of used range tkraju via OfficeKB.com Excel Discussion (Misc queries) 1 April 4th 09 04:45 PM
Excel VBA - changing variables during a loop ellis_x[_3_] Excel Programming 3 July 5th 04 08:44 AM
Increasing a range in a loop ric Excel Programming 4 April 26th 04 07:59 PM
Loop for changing cell formatting Matt Excel Programming 1 January 15th 04 03:47 PM


All times are GMT +1. The time now is 01:12 AM.

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"