• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to Partial match

Fairly vague question. You can use Instr, Find or Match with a wildcard. Depends on the situation.
 
Still a bit vague I'm afraid. Are you trying to match two strings against each other? If so, you can see if one appears somewhere in the other using Instr:

Code:
If instr(1, "text to search", "text to look for", vbTextCompare) <> 0 Then
msgbox "Text was found"
End If
 
Afraid not - you still haven't clearly explained what exactly you are trying to achieve.
 
Code:
Sub ProcessData()
Dim wksSource As Worksheet, wksDestn As Worksheet
Dim lngSrcLastRow As Long, lngDstLastRow As Long, i As Long, j As Long

'\\ Set necessary references
Set wksSource = Worksheets("Allocation Data")
Set wksDestn = Worksheets("Tally")
lngSrcLastRow = wksSource.Range("A" & Rows.Count).End(xlUp).Row
lngDstLastRow = wksDestn.Range("A" & Rows.Count).End(xlUp).Row

Application.DisplayAlerts = False
Application.ScreenUpdating = False

'\\Loop through ranges on both sheets
For i = 2 To lngSrcLastRow
    For j = 2 To lngDstLastRow
        If wksDestn.Range("A" & j).Value = wksSource.Range("A" & i).Value And _
        InStr(wksDestn.Range("B" & j).Value, wksSource.Range("B" & i).Value) > 0 Then
            wksDestn.Range("P" & j).Value = wksSource.Range("C" & i).Value
            wksDestn.Range("Q" & j).Value = wksSource.Range("D" & i).Value
            wksDestn.Range("R" & j).Value = wksSource.Range("E" & i).Value
            wksDestn.Range("S" & j).Value = wksSource.Range("F" & i).Value
            wksDestn.Range("T" & j).Value = wksSource.Range("G" & i).Value
            wksDestn.Range("U" & j).Value = wksSource.Range("H" & i).Value
            wksDestn.Range("V" & j).Value = wksSource.Range("I" & i).Value
            '\\ Remove comment mark from below line if you expect only ONE match
          'Exit for
      End If
    Next j
Next i

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

Mod Edit: Code tags added!
 
Last edited by a moderator:
I got solution can u pls tell me how to use Countifs function in vba for this formula
=COUNTIFS('Process Data'!$A:$A,Tally!$A3,'Process Data'!$C:$C,Tally!$B3,'Process Data'!$H:$H,Tally!H$2)
 
Back
Top