+ Reply to Thread
Results 1 to 2 of 2

Find and FindNext, issues

  1. #1
    Registered User
    Join Date
    03-17-2015
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    1

    Find and FindNext, issues

    I have many lists that i have combined into one big list.

    In order to summarize the list on the summary page, I'm trying to use VBA however I'm having problems. Firstly a big thanks to the lovely people on this forum for your help so far.

    If not got round to adding a loop for each row in ("Combined") as its have trouble dealing with only 1 row.

    For each row in "combined" column B [model] it should search "summary" for [model] entries already there. There should only be two instances of model in "Summary" with different statuses PASS or 3.

    If its there already and the status is the same it should add 1 to the qty. If the model and the status cant be found they should be added to the summary.

    Feel like im going in circles, so any help appreciated

    Sub Find_First()

    Dim FindString As String
    Dim Rng As Range
    Dim status As String
    Dim rng2 As Range



    FindString = Sheets("Combined").Range("b2").Value
    status = Sheets("Combined").Range("b2").Offset(0, 2).Value

    If Trim(FindString) <> "" Then
    With Sheets("Summary").Range("b:b")
    Set Rng = .Find(What:=FindString, _
    after:=.Cells(.Cells.Count), _
    LookIn:=xlValues, _
    LookAt:=xlWhole, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)

    If Rng Is Nothing Then

    Range("B65536").End(xlUp).Offset(1, 0).Select
    ActiveCell.Value = FindString
    ActiveCell.Offset(0, 2).Value = status
    ActiveCell.Offset(0, 1).Value = ActiveCell.Offset(0, 1).Value + 1


    Else

    If Not Rng Is Nothing And Rng.Offset(0, 2).Value = status Then


    Application.Goto Rng, True

    ActiveCell.Offset(0, 1).Value = ActiveCell.Offset(0, 1).Value + 1

    Else

    If Not Rng Is Nothing And Rng.Offset(0, 2).Value <> status Then

    Application.Goto Rng, True

    With Sheets("Summary").Range("b:b")
    Set rng2 = .Find(What:=FindString, _
    after:=Rng, _
    LookIn:=xlValues, _
    LookAt:=xlWhole, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)

    If rng2 Is Nothing Then

    Range("B65536").End(xlUp).Offset(1, 0).Select
    ActiveCell.Value = FindString
    ActiveCell.Offset(0, 2).Value = status
    ActiveCell.Offset(0, 1).Value = ActiveCell.Offset(0, 1).Value + 1

    Else

    If Not rng2 Is Nothing And rng2.Offset(0, 2).Value = status Then


    Application.Goto rng2, True

    ActiveCell.Offset(0, 1).Value = ActiveCell.Offset(0, 1).Value + 1
    End If


    End If




    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Find and FindNext, issues

    You can edit your post, to add code tags.


    CodeTags.jpg

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. find value in column with FindNext
    By nono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2010, 04:35 PM
  2. Cells.find and .findnext
    By Buzzaro in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2007, 08:29 AM
  3. Using Find & FindNext in a form
    By BernzG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2005, 07:28 PM
  4. [SOLVED] Nesting Find and FindNext
    By SA3214 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-10-2005, 04:05 PM
  5. Using 'Find' and 'FindNext' in vba
    By SA3214 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-25-2005, 09:06 AM

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