random range of cells via cell names

  • Thread starter Thread starter oldyork90
  • Start date Start date
O

oldyork90

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.
 
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
 
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")
 
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
 
Back
Top