random range of cells via cell names

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.
 
G

GS

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
 
O

oldyork90

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")
 
G

GS

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top