PDA

View Full Version : [SOLVED] Range Dynamic Query



pfuglsang
06-07-2005, 01:56 AM
Hi,

Just wondering if anyone knows how to select an entire row dynamically? This piece of code


Range(ActiveCell, ActiveCell.End(xlToRight)).Select

only selects to the next empty cell where as I want to go from eg column A at any given row to column IV???

Any help would be much appreciated...

Cheers
Phil :dunno

johnske
06-07-2005, 04:54 AM
Hi Phil,

Welcome to VBAX. You mean something like this?


Sub EntireRoe()
ActiveCell.EntireRow.Select
End Sub
HTH,
John :)

pfuglsang
06-07-2005, 05:09 AM
Hi John,

You are a legend, I have been trying to figure out that code for the last couple days...it works a dream!!!

Thanks
Phil :thumb

johnske
06-07-2005, 05:49 AM
Not a prob Phil, glad to be able to help...

Regards,
John

(PS can you go to thread tool at the top of the thread and mark this solved pls? :))

pfuglsang
06-07-2005, 05:55 AM
Hi AND WOOPSSSSS....

I dont know which world I was just in but that didnt actually solve my problem....even though it was the right answer to my question...sorry! I need it to work from a specific cell across to the end of the row....????


ActiveCell.Cells(1, 3).Select
' move to this cell

Range(ActiveCell, ActiveCell.End(xlToRight)).Select
' select all the cells to right of selected cell

This is what I have been working on but when this code encounters a blank cell it will stop at that cell and selection, where I need it to continue to the final column eg IV.

Is there a way you can use in the ActiveCell.End( <end><shift><enter> ) keyboard keys as that would work??

Thanks again & sorry my bad
Phil :doh:

johnske
06-07-2005, 06:25 AM
Sub TryThis1()
'stops at 1st non-empty cell
Range(ActiveCell.Address & ":" & ActiveCell.End(xlToRight).Address).Select
End Sub

Sub TryThis2()
'carries on to IV
Range(ActiveCell.Address & ":IV" & ActiveCell.Row).Select
End Sub

:thumb

pfuglsang
06-07-2005, 07:03 AM
Ok, thats working... thank you very much for your time, sorry again!!!

Cheers
Phil :yes :bow:

johnske
06-07-2005, 05:25 PM
Not a prob :)