+ Reply to Thread
Results 1 to 4 of 4

Search for specific data and count number of rows till empty Cell

  1. #1
    Registered User
    Join Date
    06-03-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    2

    Search for specific data and count number of rows till empty Cell

    I am pretty much a beginner in the excel VBA!! Jumping straight to the query

    I have condition mentioned in column H, And based on that condition, the data in another column (multiple rows) have to be copied to the word document. I am trying to read the data till the blank from the row which as met the condition and then was planning to get count which could be used to select the range for copying to the word.

    But somehow the function doesn't use that After:= command only.

    In the attached file, say if the column H5 as Fail. then from the E5 till the blank/Grey Line in the 19th row (E5:E18) have to be copied. and then move on to find the next row in H with Fail condition

    Help please!!!

    strSearch = "Fail"
    dID = 0
    With ActiveSheet.Range("H:H")
    Set Trng = .Find(strSearch, LookAt:=xlWhole) ' find the first occurence
    If Not Trng Is Nothing Then
    FirstOcc = Trng.Address
    Do
    dID = dID + 1
    r = Mid(FirstOcc, 4, Len(FirstOcc))
    stpRow = .Columns(5).Find(What:="*", After:=.Cells(r, 5), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row occurence'Call the writing to word doc code
    Set Trng = .FindNext(Trng)
    Loop While Not Trng Is Nothing And Trng.Address <> FirstOcc
    End If
    End With

    Sample Data.xls

  2. #2
    Forum Guru
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,230

    Re: Search for specific data and count number of rows till empty Cell

    Please Login or Register  to view this content.
    Should be

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-03-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Search for specific data and count number of rows till empty Cell

    I think that word occurence is anyway a typo. Also I want the excel to search after Cell (r,5). But it doesn't :-(

  4. #4
    Forum Guru
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,230

    Re: Search for specific data and count number of rows till empty Cell

    Did you get an error once you removed the typo? I think the syntax is wrong.
    Most likely would be
    Please Login or Register  to view this content.

+ 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