Results 1 to 18 of 18

Find and Replace with multiple conditions problem.

Threaded View

Benisato Find and Replace with... 03-10-2010, 11:38 AM
JBeaucaire Re: Find and Replace with... 03-10-2010, 12:12 PM
Benisato Re: Find and Replace with... 03-10-2010, 12:29 PM
JBeaucaire Re: Find and Replace with... 03-10-2010, 12:36 PM
Benisato Re: Find and Replace with... 03-10-2010, 12:48 PM
Benisato Re: Find and Replace with... 03-10-2010, 12:56 PM
Benisato Re: Find and Replace with... 03-11-2010, 01:47 AM
Benisato Re: Find and Replace with... 03-11-2010, 02:36 AM
JBeaucaire Re: Find and Replace with... 03-11-2010, 04:12 AM
Benisato Re: Find and Replace with... 03-11-2010, 01:14 PM
JBeaucaire Re: Find and Replace with... 03-11-2010, 02:42 PM
Benisato Re: Find and Replace with... 03-11-2010, 03:03 PM
JBeaucaire Re: Find and Replace with... 03-11-2010, 07:06 PM
Benisato Re: Find and Replace with... 03-11-2010, 10:19 PM
JBeaucaire Re: Find and Replace with... 03-12-2010, 12:09 AM
Benisato Re: Find and Replace with... 03-12-2010, 02:00 AM
JBeaucaire Re: Find and Replace with... 03-12-2010, 04:53 AM
Benisato Re: Find and Replace with... 03-12-2010, 06:06 AM
  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    63

    Find and Replace with multiple conditions problem.

    Hey all,
    Hopefully someone can help me with this problem I'm having, as I can't seem to find a solution anywhere online or in the help files that works for me. I'm currently trying to write some code that will search a row for a specific string, and once found, will then look at the cell to the immediate left for a different specific string. If it finds both, it will then copy the contents of the cell 2 rows to the left into a different cell on a seperate sheet. This is what I've come up with so far:

    Sub Find_MH()
        Dim FindString As String
        Dim Rng As Range
        FindString = "MH"
        If Trim(FindString) <> "" Then
            With Sheets("Data").Range("D:D")
                Set Rng = .Find(What:=FindString, _
                                After:=.Cells(.Cells.Count), _
                                LookIn:=xlValues, _
                                LookAt:=xlWhole, _
                                SearchOrder:=xlByRows, _
                                SearchDirection:=xlNext, _
                                MatchCase:=False)
                If Not Rng Is Nothing And Rng.Offset(0, -1).Value = "Available" Then
                    Sheet1.Range("B29").Value = Rng.Offset(0, -2).Value
                    Rng.Offset(0, -1).Value = "Allocated"
                    Else
                    MsgBox "No MH Found"
                End If
            End With
        End If
    End Sub
    That code will search down the D column for the string "MH" and then check for the string "Available" in the adjacent cell. What I can't figure out is how to properly use the FindNext command to keep searching if it doesn't find the "Available" string in the adjacent cell, until both conditions are met, and then execute the other code.

    Hopefully I've explained it so that other people can understand what I'm trying to do.
    Any help would be greatly appreciated

    Chris
    Last edited by Benisato; 03-12-2010 at 06:06 AM.

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