Cell Referencing

N

Neil Pearce

Dear all,

Is it possible to reference cells in Excel using numbers for both rows and
columns rather than the letter and number reference as is standard?

If so, is it possible to write a macro that selects range A1 to A+X:1+Y
where X & Y are variable integers in other cells?


Thanking-you in advance,

Neil
 
J

Joel

Using macros you cna reference cells either using numbers or letters. Cells
can ber referenced using eithe rRANGE or CELLS. Here are some examples

Range("A1:B10")
Cells(1,"B") row then column
Cells(1,2)
Range(cells(1,"A"),cells(10,"C")

for you case use the following
Range("A1",cells(X + 1, Y + 1))
 
N

Neil Pearce

Thanks Joel.

So if I wanted a simple macro code to attach to a button to select a range,
as dictated by cells Z1 & Z2, the following should work?

sub SelectRange()

range("A1",cells((Z1+1),(Z2+1))).select
end sub


Kind regards,

Neil
 
D

David Biddulph

Yes.

Tools/ Options/ General:
R1C1 reference style.
--
David Biddulph

Neil Pearce said:
Dear all,

Is it possible to reference cells in Excel using numbers for both rows and
columns rather than the letter and number reference as is standard?
....
 
J

Joel

I thinbk the code below is what you want. You don't havbe Z1 and Z2 defined.
I thionk you are referencing the workbook cells Z1 and Z2, therfore, you
need to use range.

sub SelectRange()

range("A1",cells((Range("Z1")+1),(Range("Z2")+1))).select
end sub
 
N

Neil Pearce

Yes Z1 and Z2 are indeed reference to cells in the workbook, apologies for
the lack of clarification.

The code below halts at the second range and returns "wrong number of
arguments or invalid property asignment". Any ideas?
 

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