Consulting

Results 1 to 12 of 12

Thread: Use .Range("A1:A10000") to end of records?

  1. #1

    Use .Range("A1:A10000") to end of records?

    Hello,

    how can we use to get the range endof records of the cells without to use this last part of code below

    .Range("S8:S100000".Find(What:=Me.ListBox1.Column(17), LookIn:=xlValues, LookAt:=xlWhole))
    is there an solution to use it so we don't have to add :S100000 of rows?

    because i believe if there are many more records it will not be able to search them all.

    Thanks

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    Range("S8:S" & Rows.count).Find


    or


    Columns("S").Find

  3. #3
    Hello Mana,

    i get an error if i use this

    Set findvalue2 = Sheet2.Range("S8:S" & Rows.Count).Find(What:=Me.ListBox1.Column(17), LookIn:=xlValues, LookAt:=xlWhole) 
    MsgBox (findvalue2.Offset(0, 1).Value)
    'Run-time error 91
    Object variable or with block variable not set'

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Try Range("S:S").Offset(8)...
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    Hi SamT,

    didn't work

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    @GhostOfDoom --- what is it EXACTLY are you wanting to accomplish, not how you think you want to do it
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  7. #7
    Hi Paul_Hossler,


    Well i like to .find all the rows without to use a default number of rows


    Sheet2.Range("S8:S100000")'S100000

    like


    Set findvalue2 = Sheet2.Range("S8:S").Find(What:=Me.ListBox1.Column(17), LookIn:=xlValues, LookAt:=xlWhole)

    so when i search for something and i use the offset it will show me the correct record


    MsgBox (findvalue2.Offset(0, 0).Value) ' display the record i looking for from the columns A till AI i use the 0,0 and search the correct cell

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Well, .Find will only return the first occurrence.

    Have you looked at .Filter?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  9. #9
    filter?

    what do you mean Paul_Hossler with filter

  10. #10
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    put together and attach a sample workbook with the macro

    don't need the userform, just the value from the combobox and in another sheet maybe the results
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  11. #11
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    .Find did not find anything
    Or
    Listbox column 17 of that list row is empty (Null)



    .Range("S8:S" & Rows.Count is perfect.

    ListBox1.Column(17) I have a doubt about
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  12. #12
    Hello SamT,

    just to let you know and the others that helpme out
    that i have solved it

    indeed it worked with the S"Rows

    Dim Lastrow As Integer
    Lastrow = Sheet2.Cells(Rows.Count, "S").End(xlUp).Row
    Set findvalue = Sheet2.Range("S9:S" & Lastrow).Find(What:=Me.ListBox1.Column(17), LookIn:=xlValues, LookAt:=xlWhole)
    Thank you all very much

Posting Permissions

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