Results 1 to 6 of 6

Thread: Find (2003)

  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find (2003)

    If the find function returns a range why can't I add .row to the find function to find the relevant row number as follows

    Sub FindARange()
    ThisWorkbook.Worksheets("Standard sheet").Activate
    Dim endcell As Range
    Dim endRow As Integer

    endrow = Columns("Q:Q").Find what:="End Marker".row

    End Sub

    And given that the above does not work can somebody please tell me the best way to find the row number that I need

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Find (2003)

    Try this:

    <pre>endRow = Columns("Q:Q").Find(what:="End Marker").Row</pre>


    Steve

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find (2003)

    Thanks Steve

    Can you please explain why the brackets were needed around the what:=... parameter rather than almost every other bit of the function which tried earlier?

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Find (2003)

    The parentheses (brackets are the [ and ]) are needed whenever you use a method/function with an equal sign to place it into a variable.

    Steve

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find (2003)

    VBA syntax requires that the parenthesis be used aroung parameters to a method if there is an equal sign to the left of the method that assigns the results of the method to a variable. If there is no equal sign to the left of the method, then the syntax requires that the parenthesis not be used. In this case, it also makes it clear that the .Row is being used to modify the method and not the parameter to the method. I think it would be much more consistent to require the parenthesis in both cases, but Microsoft did not give me a vote. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Legare Coleman

  6. #6
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find (2003)

    Thanks

    That makes things clearer

Posting Permissions

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