Consulting

Results 1 to 8 of 8

Thread: Range Dynamic Query

  1. #1

    Range Dynamic Query

    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
    Last edited by pfuglsang; 06-07-2005 at 05:28 AM. Reason: solved

  2. #2
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Hi Phil,

    Welcome to VBAX. You mean something like this?

    Sub EntireRoe()
    ActiveCell.EntireRow.Select
    End Sub
    HTH,
    John
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  3. #3
    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

  4. #4
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    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? )
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  5. #5
    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

  6. #6
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    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
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  7. #7
    Ok, thats working... thank you very much for your time, sorry again!!!

    Cheers
    Phil

  8. #8
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Not a prob
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •