No match found

VBA_Newbie123

New Member
Joined
May 20, 2017
Messages
9
Hi,

I have this code but just cannot find the value I am looking for as it will only return 'No match for' I have my dates in the correct column in exactly the same format

Code:
[/COLOR]Private Sub CommandButton4_Click()

    Dim Found As Range
    
     If TextBox3.Value = "" Then
        MsgBox "No Date. ", , "Missing Entry"
    Else
        Set Found = Sheets("Sheet1").Range("C7:C30").Find(What:=TextBox3.Value, _
                                                       LookIn:=xlValues, _
                                                       LookAt:=xlWhole, _
                                                       SearchOrder:=xlByRows, _
                                                       SearchDirection:=xlNext, _
                                                       MatchCase:=False)
        If Found Is Nothing Then
            MsgBox "No match for " & TextBox3.Value, , "No Match Found"
        Else
            Found.Offset(0, 1).Value = TextBox3.Value
        End If
    End If
    


End Sub


[COLOR=#333333]
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I would guess that the value in your textbox is text and the range you are searching in, they are actually dates. Try wrapping your textbox3.value in the DateValue() function and see if that works.

Code:
Private Sub CommandButton4_Click()

    Dim Found As Range
    
     If TextBox3.Value = "" Then
        MsgBox "No Date. ", , "Missing Entry"
    Else
        Set Found = Sheets("Sheet1").Range("C7:C30").Find(What:=[B]DateValue([/B]TextBox3.Value[B])[/B], _
                                                       LookIn:=xlValues, _
                                                       LookAt:=xlWhole, _
                                                       SearchOrder:=xlByRows, _
                                                       SearchDirection:=xlNext, _
                                                       MatchCase:=False)
        If Found Is Nothing Then
            MsgBox "No match for " & TextBox3.Value, , "No Match Found"
        Else
            Found.Offset(0, 1).Value = TextBox3.Value
        End If
    End If
    


End Sub
 
Upvote 0
Yep, that works!

So I want to set the value offsets into the cells depending on the Option buttons, can I add code in like this?

Code:
Private Sub CommandButton4_Click()


    Dim Found As Range
    
     If TextBox4.Value = "" Then
        MsgBox "No Date. ", , "Missing Entry"
    Else
        Set Found = Sheets("Sheet1").Range("C:C").Find(What:=DateValue(TextBox4.Value), _
                                                       LookIn:=xlValues, _
                                                       LookAt:=xlWhole, _
                                                       SearchOrder:=xlByRows, _
                                                       SearchDirection:=xlNext, _
                                                       MatchCase:=False)
        If Found Is Nothing Then
            MsgBox "No match for " & TextBox4.Value, , "No Match Found"
        Else
        
        If OptionButton1.Value = True Then
     
            Found.Offset(0, 3).Value = TextBox1.Value
            Found.Offset(0, 4).Value = TextBox2.Value
            Found.Offset(0, 5).Value = TextBox3.Value

If OptionButton2.Value = True Then
     
            Found.Offset(0, 6).Value = TextBox1.Value
            Found.Offset(0, 7).Value = TextBox2.Value
            Found.Offset(0, 8).Value = TextBox3.Value

If OptionButton1.Value = True Then
     
            Found.Offset(0, 9).Value = TextBox1.Value
            Found.Offset(0, 10).Value = TextBox2.Value
            Found.Offset(0, 11).Value = TextBox3.Value




            

            
        End If
    End If
    


End Sub

Not sure how to better explain that part?
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top