Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Help with named ranges

Hi
I am trying to perform calculations on named ranges in a data sheet.
Each range is non contiguous and named as follows:
crng4, crng5, crng6, ... , crng24

I would like to access them through a loop as shown below.
Is this possible ?
Everything I have tried so far has not worked.
e.g.

For k = 4 To 24

If Shd.Cells(i + j, k) < "" Then
Set rng.Name = "crng" & k
Shpro.Cells(3 + k, 12 * j + 7) =
Round(AA.PercentRank(Shd.Range(rng), Shd.Cells(i + j, k)) *
100, "0") '% rank
End If

Next k

I have also tried Ar1 = Array("Crng4", "crng5", ... , "crng24")
and then
Round(AA.PercentRank(Shd.Range(Ar1(k-3)), Shd.Cells(i + j, k)) * 100,
"0") '% rank

but that didn't work either.

Regards

Andrew B




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Help with named ranges

Using your example, the way to create a new named range is more like this:

ThisWorkbook.Names.Add Name:= "crng" & k, RefersTo:=Shd.Cells(i + j, k)

See if you can work with that.
--
Regards,
Ron


"Andrew B" wrote:

Hi
I am trying to perform calculations on named ranges in a data sheet.
Each range is non contiguous and named as follows:
crng4, crng5, crng6, ... , crng24

I would like to access them through a loop as shown below.
Is this possible ?
Everything I have tried so far has not worked.
e.g.

For k = 4 To 24

If Shd.Cells(i + j, k) < "" Then
Set rng.Name = "crng" & k
Shpro.Cells(3 + k, 12 * j + 7) =
Round(AA.PercentRank(Shd.Range(rng), Shd.Cells(i + j, k)) *
100, "0") '% rank
End If

Next k

I have also tried Ar1 = Array("Crng4", "crng5", ... , "crng24")
and then
Round(AA.PercentRank(Shd.Range(Ar1(k-3)), Shd.Cells(i + j, k)) * 100,
"0") '% rank

but that didn't work either.

Regards

Andrew B





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Help with named ranges

Hi,

Round(AA.PercentRank(Shd.Range("crng" & k), Shd.Cells(i + j, k)) *

HTH

"Andrew B" wrote:

Hi
I am trying to perform calculations on named ranges in a data sheet.
Each range is non contiguous and named as follows:
crng4, crng5, crng6, ... , crng24

I would like to access them through a loop as shown below.
Is this possible ?
Everything I have tried so far has not worked.
e.g.

For k = 4 To 24

If Shd.Cells(i + j, k) < "" Then
Set rng.Name = "crng" & k
Shpro.Cells(3 + k, 12 * j + 7) =
Round(AA.PercentRank(Shd.Range(rng), Shd.Cells(i + j, k)) *
100, "0") '% rank
End If

Next k

I have also tried Ar1 = Array("Crng4", "crng5", ... , "crng24")
and then
Round(AA.PercentRank(Shd.Range(Ar1(k-3)), Shd.Cells(i + j, k)) * 100,
"0") '% rank

but that didn't work either.

Regards

Andrew B





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Help with named ranges

Hi
Thanks for you help. I found that one of the ranges I was referring to
wasn't labelled correctly and so wasn't reerring to numbers.

Range("crng" & k) does work.

Thanks

Andrew B wrote:
Hi
I am trying to perform calculations on named ranges in a data sheet.
Each range is non contiguous and named as follows:
crng4, crng5, crng6, ... , crng24

I would like to access them through a loop as shown below.
Is this possible ?
Everything I have tried so far has not worked.
e.g.

For k = 4 To 24

If Shd.Cells(i + j, k) < "" Then
Set rng.Name = "crng" & k
Shpro.Cells(3 + k, 12 * j + 7) =
Round(AA.PercentRank(Shd.Range(rng), Shd.Cells(i + j, k)) *
100, "0") '% rank
End If

Next k

I have also tried Ar1 = Array("Crng4", "crng5", ... , "crng24")
and then
Round(AA.PercentRank(Shd.Range(Ar1(k-3)), Shd.Cells(i + j, k)) * 100,
"0") '% rank

but that didn't work either.

Regards

Andrew B




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
Named ranges [email protected] Excel Discussion (Misc queries) 1 March 21st 06 10:33 PM
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM
named ranges - changing ranges with month selected gr8guy Excel Programming 2 May 28th 04 04:50 AM
named ranges, I think inquirer Excel Programming 2 May 4th 04 03:27 AM
Named ranges Charles Williams Excel Programming 0 April 20th 04 05:32 PM


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