ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Newbie Cell Selection Question (https://www.excelbanter.com/excel-programming/386443-newbie-cell-selection-question.html)

Keith Wilby

Newbie Cell Selection Question
 
Hi Group.

I'm a seasoned VBA programmer in Access but now I'm having to use automation
to have Access create line graphs in Excel.

How do you use code to select cells in a column that are populated with
data? By that I mean that, if I have cells A1 to A10 populated, how do I
get that range for use in code? I need to do this because, with each dump
of data from Access, the number of rows populated will change.

I'm guessing I need to loop through the cells collection until I find a null
but am unsure of the syntax.

Any pointers greatly appreciated.

Keith.
www.keithwilby.com



Bob Phillips

Newbie Cell Selection Question
 
Columns(1).SpecialCells(xlCellTypeConstants).Selec t


or better

Dim rng As Range

Set rng = Columns(1).SpecialCells(xlCellTypeConstants)

and work on rng

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Keith Wilby" wrote in message
...
Hi Group.

I'm a seasoned VBA programmer in Access but now I'm having to use
automation to have Access create line graphs in Excel.

How do you use code to select cells in a column that are populated with
data? By that I mean that, if I have cells A1 to A10 populated, how do I
get that range for use in code? I need to do this because, with each dump
of data from Access, the number of rows populated will change.

I'm guessing I need to loop through the cells collection until I find a
null but am unsure of the syntax.

Any pointers greatly appreciated.

Keith.
www.keithwilby.com




Adrian D. Bailey

Newbie Cell Selection Question
 
If you know the start (e.g. the topmost cell) then you could use code
similar to this...
Range("A1", Range("A1").End(xlDown)).Select

You might also try putting the words "select region" into Excel's Help - it
might give you some other ideas.
--
--
Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences
Loughborough University, Loughborough Leics, LE11 3TU, UK.
Tel: 01509 223007 Fax: 01509 223940

Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509 563263
--

"Keith Wilby" wrote in message
...
Hi Group.

I'm a seasoned VBA programmer in Access but now I'm having to use
automation to have Access create line graphs in Excel.

How do you use code to select cells in a column that are populated with
data? By that I mean that, if I have cells A1 to A10 populated, how do I
get that range for use in code? I need to do this because, with each dump
of data from Access, the number of rows populated will change.

I'm guessing I need to loop through the cells collection until I find a
null but am unsure of the syntax.

Any pointers greatly appreciated.

Keith.
www.keithwilby.com




Keith Wilby

Newbie Cell Selection Question
 
"Adrian D. Bailey" wrote in message
...
If you know the start (e.g. the topmost cell) then you could use code
similar to this...
Range("A1", Range("A1").End(xlDown)).Select

You might also try putting the words "select region" into Excel's Help -
it might give you some other ideas.


Many thanks Adrian and Bob, that's just what I wanted.

Regards,
Keith.




All times are GMT +1. The time now is 03:30 PM.

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