+ Reply to Thread
Results 1 to 11 of 11

Select range depending on a column

  1. #1
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Select range depending on a column

    If i have row 10-20 in column A filled, what vba code would i need to select a range in column C that selects rows 10-20

    If that 10-20 rows in column A chnages to say 10-50 the vba code will select 10-50 in column C

    Many Thanks
    Last edited by Directlinq; 03-04-2009 at 06:55 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select range depending on a column

    Depends on how you're identifying A ... you can use A and then Offset(,2) to select C

    Please Login or Register  to view this content.
    The above identifies a range by starting at row 10 in Col A and ending at last non-blank in A ... it then offsets the range by 2 columns - ie resulting in a range in Col C of those dimensions specified by values in A.

  3. #3
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: Select range depending on a column

    That sound like what i want it to do but it is say syntax error when i put it in vba

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select range depending on a column

    As I said it identifies a range, you need to "do" something with it obviously (ie Set or .Value = "x" etc....), given I can't see your code and have no idea how you intend to use said range I can't comment any further.

  5. #5
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: Select range depending on a column

    Once the cells have been selected i was hoping to apply
    Please Login or Register  to view this content.
    formatting macro
    Last edited by Directlinq; 03-04-2009 at 05:48 AM.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select range depending on a column

    Per Forum rules please Edit your last post and add CODE tags (highlight VBA & press # icon).

    Also please specify significance of row 30 ... given this is not an absolute reference I am presuming the formulae you offer are for C30 ?

  7. #7
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: Select range depending on a column

    Row 30 is where the dates start from in column A but they could end anywhere below that in column A

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select range depending on a column

    OK so the starting row is 30 and not 10 as you specified earlier, correct ?

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: Select range depending on a column

    You are correct row 30 is the starting row.
    Sorry this vba code works but i thought by getting the code you gave me i could adapt it to the rest of my vba code. I think im in over my head. This is the full code
    Please Login or Register  to view this content.
    This is why im getting confused. So your offset will work for selecting individual columns but for more than 1 column it will not work.

    Sorry, I thought i could work out what to do for the rest but they are more than 1 column.

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Select range depending on a column

    I can't test as I don't have any data but perhaps the below will work for you

    Please Login or Register  to view this content.
    EDIT: VBA updated at 10:43 UK time.
    Last edited by DonkeyOte; 03-04-2009 at 06:43 AM.

  11. #11
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: Select range depending on a column

    Wow perfect

    Thank you so much

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1