ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   random range of cells via cell names (https://www.excelbanter.com/excel-programming/449836-random-range-cells-via-cell-names.html)

[email protected]

random range of cells via cell names
 
There was an earlier post about how to construct a range of random cells. The examples used cell addresses like "A5, A6 ... and so on.

I've tried 100 times and I can't figure out how to do this with named cells. I'd like to do something like define the range with "cell_name_total", "cell_name_sum" ...

I just can get it to go.

Thanks.

GS[_2_]

random range of cells via cell names
 
There was an earlier post about how to construct a range of random
cells. The examples used cell addresses like "A5, A6 ... and so on.

I've tried 100 times and I can't figure out how to do this with named
cells. I'd like to do something like define the range with
"cell_name_total", "cell_name_sum" ...

I just can get it to go.

Thanks.


Substitute the sample cell addresses with your cell names...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



[email protected]

random range of cells via cell names
 
On Tuesday, February 18, 2014 9:52:13 PM UTC-6, GS wrote:
There was an earlier post about how to construct a range of random


cells. The examples used cell addresses like "A5, A6 ... and so on.




I've tried 100 times and I can't figure out how to do this with named


cells. I'd like to do something like define the range with


"cell_name_total", "cell_name_sum" ...




I just can get it to go.




Thanks.




Substitute the sample cell addresses with your cell names...



--

Garry



Free usenet access at http://www.eternal-september.org

Classic VB Users Regroup!

comp.lang.basic.visual.misc

microsoft.public.vb.general.discussion


I tried these and none worked. Can you spot the silly thing I'm doing wrong?

Set rgRandomCells = myWs.Range(Cells("thisisa1"), Cells("thisisa2"),Cells("thisis23"))

Set rgRandomCells = myWs.Range(myWs.Range("thisisa1"), myWs.Range("thisisa1"))

Set rgRandomCells = myWs.Range("thisisa1, thisisa2")

GS[_2_]

random range of cells via cell names
 
Try...

Set rgRandomCells = myWs.Range("thisisa1", "thisisa2")
OR
Set rgRandomCells = myWs.Range("thisisa1", "thisisb3")

...to access A1:A2 OR A1:B3 as a block. To access as separate try...

const sMyRanges$ = "thisisa1,thisisa2,thisisb3"
Dim n
For Each n In Split(sMyRanges, ",")
MsgBox Range(n).Address
Next 'n

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




All times are GMT +1. The time now is 06:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com