Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default selecting column down to variant cell

Is it possible to find the bottom of a sheet, say there are 1500 entries in
column A... and then select F9:F1500 if column F doesn't have values in every
row?

For example, the next time the macro is run thier maybe 1505 rows in the
sheet...

here is a test code that doesn't work for me... but may help convey my idea.

Dim c As Variant

Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Select
Set c = ActiveCell
Range("f9").Select
Range(Selection, Selection.c(xlDown)).Select
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default selecting column down to variant cell

Try this John

Sub test()
Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
Range("F9:F" & lr).Select
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"John" wrote in message ...
Is it possible to find the bottom of a sheet, say there are 1500 entries in
column A... and then select F9:F1500 if column F doesn't have values in every
row?

For example, the next time the macro is run thier maybe 1505 rows in the
sheet...

here is a test code that doesn't work for me... but may help convey my idea.

Dim c As Variant

Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Select
Set c = ActiveCell
Range("f9").Select
Range(Selection, Selection.c(xlDown)).Select



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default selecting column down to variant cell

Thank yous to all of you, both Ron's and Bernie's one liner worked...

my code adaption didn't, but problem solved.

Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Select
Set c = ActiveCell
Range("f9").Select
Range(Selection, c)).Select

Thanks again!


"Ron de Bruin" wrote:

Try this John

Sub test()
Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
Range("F9:F" & lr).Select
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"John" wrote in message ...
Is it possible to find the bottom of a sheet, say there are 1500 entries in
column A... and then select F9:F1500 if column F doesn't have values in every
row?

For example, the next time the macro is run thier maybe 1505 rows in the
sheet...

here is a test code that doesn't work for me... but may help convey my idea.

Dim c As Variant

Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Select
Set c = ActiveCell
Range("f9").Select
Range(Selection, Selection.c(xlDown)).Select




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default selecting column down to variant cell

John,

My mistake - I left in an extra ) on that last line: take it out, and that code will work.

HTH,
Bernie
MS Excel MVP

my code adaption didn't, but problem solved.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default selecting column down to variant cell

John,

This is how your code should have been written to work:

Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Select
Set c = ActiveCell
Range("f9").Select
Range(Selection, c)).Select

But this one line will work just as well

Range("A9", Range("A9").End(xlDown)).Offset(0, 5).Select

HTH,
Bernie
MS Excel MVP


"John" wrote in message
...
Is it possible to find the bottom of a sheet, say there are 1500 entries in
column A... and then select F9:F1500 if column F doesn't have values in every
row?

For example, the next time the macro is run thier maybe 1505 rows in the
sheet...

here is a test code that doesn't work for me... but may help convey my idea.

Dim c As Variant

Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Select
Set c = ActiveCell
Range("f9").Select
Range(Selection, Selection.c(xlDown)).Select





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default selecting column down to variant cell

Bernie,

The OP should go with Ron's code which works from the bottom of the page -
up

Your code works from the top down and will stop at the 1st blank cell. The
OP says that there are sporadic blank cells...

--
steveB

Remove "AYN" from email to respond
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
John,

This is how your code should have been written to work:

Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Select
Set c = ActiveCell
Range("f9").Select
Range(Selection, c)).Select

But this one line will work just as well

Range("A9", Range("A9").End(xlDown)).Offset(0, 5).Select

HTH,
Bernie
MS Excel MVP


"John" wrote in message
...
Is it possible to find the bottom of a sheet, say there are 1500 entries
in
column A... and then select F9:F1500 if column F doesn't have values in
every
row?

For example, the next time the macro is run thier maybe 1505 rows in the
sheet...

here is a test code that doesn't work for me... but may help convey my
idea.

Dim c As Variant

Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Select
Set c = ActiveCell
Range("f9").Select
Range(Selection, Selection.c(xlDown)).Select





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default selecting column down to variant cell

That's why I used column A, since the sporadic blanks cells are in column F.

HTH,
Bernie
MS Excel MVP

Your code works from the top down and will stop at the 1st blank cell. The OP says that there are
sporadic blank cells...


Is it possible to find the bottom of a sheet, say there are 1500 entries in
column A... and then select F9:F1500 if column F doesn't have values in every
row?



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default selecting column down to variant cell

see my second post above!

"Bernie Deitrick" wrote:

That's why I used column A, since the sporadic blanks cells are in column F.

HTH,
Bernie
MS Excel MVP

Your code works from the top down and will stop at the 1st blank cell. The OP says that there are
sporadic blank cells...


Is it possible to find the bottom of a sheet, say there are 1500 entries in
column A... and then select F9:F1500 if column F doesn't have values in every
row?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting the penultimate cell from a column of data jfp Excel Worksheet Functions 3 July 17th 09 02:37 PM
Selecting A Column based on Cell Value newguy Excel Discussion (Misc queries) 0 December 14th 06 09:39 PM
Selecting any cell in a column I want my ComboBox to show. How? ABP MLundqvist Excel Discussion (Misc queries) 4 March 1st 06 01:15 PM
Asign Array Variant to Column William C. Smith Excel Programming 3 December 27th 03 04:20 AM
Selecting single column with merged cell at top Paul Kendall[_5_] Excel Programming 3 October 29th 03 09:01 PM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"