IF and TextBox value with wildcard?

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
482
Office Version
  1. 365
Platform
  1. Windows
Good morning to all Presidents, ex-Presidents, and those who aspire to be the President!

I am trying to show and hide a UserForm button based on the presence of a specific character in a specific TextBox:

VBA Code:
If SE_SubLotNumberWithAsterisk.Value <> "*.*" Then SE_Confirm.Visible = False

I also tried

VBA Code:
If SE_SubLotNumberWithAsterisk.Text Like "." Then SE_Confirm.Visible = False

Here's my full code:

VBA Code:
Private Sub SearchSE_SubLotNumber()
Dim SE_SubLotNumber_id As String
SE_SubLotNumber = Trim(SE_SubLotNumber.Text)
LastRow = Worksheets("Calendar").Cells(Rows.Count, 49).End(xlUp).Row
For i = 1 To LastRow
If Worksheets("Calendar").Cells(i, 49).Value = SE_SubLotNumber Then

SE_ShipDate.Text = Worksheets("Calendar").Cells(i, 2).Value
SE_ShipDateTimeDate.Text = Worksheets("Calendar").Cells(i, 62).Value
SE_ShipDateEnteredBy.Text = Worksheets("Calendar").Cells(i, 63).Value

SE_SubLotNumber.Text = Worksheets("Calendar").Cells(i, 50).Value
SE_SubLotNumberWithAsterisk.Text = Worksheets("Calendar").Cells(i, 3).Value
SE_SubLotTimeDate.Text = Worksheets("Calendar").Cells(i, 64).Value
SE_SubLotEnteredBy.Text = Worksheets("Calendar").Cells(i, 65).Value

SE_JobNumber.Text = Worksheets("Calendar").Cells(i, 4).Value
SE_JobNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 66).Value
SE_JobNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 67).Value

SE_ContractNumber.Text = Worksheets("Calendar").Cells(i, 5).Value
SE_ContractNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 68).Value
SE_ContractNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 69).Value

SE_Subdivision.Text = Worksheets("Calendar").Cells(i, 6).Value

SE_FieldManager.Text = Worksheets("Calendar").Cells(i, 7).Value

SE_Model.Text = Worksheets("Calendar").Cells(i, 9).Value
SE_ModelTimeDate.Text = Worksheets("Calendar").Cells(i, 70).Value
SE_ModelEnteredBy.Text = Worksheets("Calendar").Cells(i, 71).Value

SE_Elevation.Text = Worksheets("Calendar").Cells(i, 10).Value
SE_ElevationTimeDate.Text = Worksheets("Calendar").Cells(i, 72).Value
SE_ElevationEnteredBy.Text = Worksheets("Calendar").Cells(i, 73).Value

SE_GarageHandling.Text = Worksheets("Calendar").Cells(i, 11).Value
SE_GarageHandlingTimeDate.Text = Worksheets("Calendar").Cells(i, 74).Value
SE_GarageHandlingEnteredBy.Text = Worksheets("Calendar").Cells(i, 75).Value

SE_FloorOrderNumber.Text = Worksheets("Calendar").Cells(i, 18).Value
SE_FloorOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 76).Value
SE_FloorOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 77).Value

SE_FloorTicketNumber.Text = Worksheets("Calendar").Cells(i, 19).Value
SE_FloorTicketNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 78).Value
SE_FloorTicketNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 79).Value

SE_LooseLumberOrderNumber.Text = Worksheets("Calendar").Cells(i, 20).Value
SE_LooseLumberOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 80).Value
SE_LooseLumberOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 81).Value

SE_LooseLumberTicketNumber.Text = Worksheets("Calendar").Cells(i, 21).Value
SE_LooseLumberTicketNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 82).Value
SE_LooseLumberTicketNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 83).Value

SE_HousewrapOrderNumber.Text = Worksheets("Calendar").Cells(i, 22).Value
SE_HousewrapOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 84).Value
SE_HousewrapOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 85).Value

SE_HousewrapTicketNumber.Text = Worksheets("Calendar").Cells(i, 23).Value
SE_HousewrapTicketNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 86).Value
SE_HousewrapTicketNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 87).Value

SE_RoofLoadOrderNumber.Text = Worksheets("Calendar").Cells(i, 24).Value
SE_RoofLoadOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 88).Value
SE_RoofLoadOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 89).Value

SE_RoofLoadTicketNumber.Text = Worksheets("Calendar").Cells(i, 25).Value
SE_RoofLoadTicketNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 90).Value
SE_RoofLoadTicketNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 91).Value

SE_RoofLoadShipDate.Text = Worksheets("Calendar").Cells(i, 26).Value
SE_RoofLoadShipDateTimeDate.Text = Worksheets("Calendar").Cells(i, 92).Value
SE_RoofLoadShipDateEnteredBy.Text = Worksheets("Calendar").Cells(i, 93).Value

SE_BoardwalksOrderNumber.Text = Worksheets("Calendar").Cells(i, 27).Value
SE_BoardwalksOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 94).Value
SE_BoardwalksOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 95).Value

SE_BoardwalksShipDate.Text = Worksheets("Calendar").Cells(i, 28).Value
SE_BoardwalksShipDateTimeDate.Text = Worksheets("Calendar").Cells(i, 96).Value
SE_BoardwalksShipDateEnteredBy.Text = Worksheets("Calendar").Cells(i, 97).Value

SE_PorchPostsOrderNumber.Text = Worksheets("Calendar").Cells(i, 29).Value
SE_PorchPostsOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 98).Value
SE_PorchPostsOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 99).Value

SE_PorchPostsTicketNumber.Text = Worksheets("Calendar").Cells(i, 30).Value
SE_PorchPostsTicketNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 100).Value
SE_PorchPostsTicketNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 101).Value

SE_PorchPostsShipDate.Text = Worksheets("Calendar").Cells(i, 31).Value
SE_PorchPostsShipDateTimeDate.Text = Worksheets("Calendar").Cells(i, 102).Value
SE_PorchPostsShipDateEnteredBy.Text = Worksheets("Calendar").Cells(i, 103).Value

SE_FyponOrderNumber.Text = Worksheets("Calendar").Cells(i, 32).Value
SE_FyponOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 104).Value
SE_FyponOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 105).Value

SE_FyponTicketNumber.Text = Worksheets("Calendar").Cells(i, 33).Value
SE_FyponTicketNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 106).Value
SE_FyponTicketNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 107).Value

SE_FyponOrderDate.Text = Worksheets("Calendar").Cells(i, 34).Value
SE_FyponOrderDateTimeDate.Text = Worksheets("Calendar").Cells(i, 108).Value
SE_FyponOrderDateEnteredBy.Text = Worksheets("Calendar").Cells(i, 109).Value

SE_FyponReceivedDate.Text = Worksheets("Calendar").Cells(i, 35).Value
SE_FyponReceivedDateTimeDate.Text = Worksheets("Calendar").Cells(i, 110).Value
SE_FyponReceivedDateEnteredBy.Text = Worksheets("Calendar").Cells(i, 111).Value

SE_FyponShipDate.Text = Worksheets("Calendar").Cells(i, 36).Value
SE_FyponShipDateTimeDate.Text = Worksheets("Calendar").Cells(i, 112).Value
SE_FyponShipDateEnteredBy.Text = Worksheets("Calendar").Cells(i, 113).Value

SE_RoofTrussesOrderNumber.Text = Worksheets("Calendar").Cells(i, 37).Value
SE_RoofTrussesOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 114).Value
SE_RoofTrussesOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 115).Value

SE_RoofTrussesTicketNumber.Text = Worksheets("Calendar").Cells(i, 38).Value
SE_RoofTrussesTicketNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 116).Value
SE_RoofTrussesTicketNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 117).Value

SE_FoamOrderNumber.Text = Worksheets("Calendar").Cells(i, 39).Value
SE_FoamOrderNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 118).Value
SE_FoamOrderNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 119).Value

SE_FoamTicketNumber.Text = Worksheets("Calendar").Cells(i, 40).Value
SE_FoamTicketNumberTimeDate.Text = Worksheets("Calendar").Cells(i, 120).Value
SE_FoamTicketNumberEnteredBy.Text = Worksheets("Calendar").Cells(i, 121).Value

SE_Options_01.Text = Worksheets("Calendar").Cells(i, 131).Value
SE_Options_02.Text = Worksheets("Calendar").Cells(i, 132).Value
SE_Options_03.Text = Worksheets("Calendar").Cells(i, 133).Value
SE_Options_04.Text = Worksheets("Calendar").Cells(i, 134).Value
SE_Options_05.Text = Worksheets("Calendar").Cells(i, 135).Value
SE_Options_06.Text = Worksheets("Calendar").Cells(i, 136).Value
SE_Options_07.Text = Worksheets("Calendar").Cells(i, 137).Value
SE_Options_08.Text = Worksheets("Calendar").Cells(i, 138).Value
SE_Options_09.Text = Worksheets("Calendar").Cells(i, 139).Value
SE_Options_10.Text = Worksheets("Calendar").Cells(i, 140).Value
SE_Options_11.Text = Worksheets("Calendar").Cells(i, 141).Value
SE_Options_12.Text = Worksheets("Calendar").Cells(i, 142).Value
SE_Options_13.Text = Worksheets("Calendar").Cells(i, 143).Value
SE_Options_14.Text = Worksheets("Calendar").Cells(i, 144).Value

SE_FPR_SentTo.Text = Worksheets("Calendar").Cells(i, 125).Value
SE_FPR_Sent.Text = Worksheets("Calendar").Cells(i, 126).Value
SE_FPR_Received.Text = Worksheets("Calendar").Cells(i, 127).Value

SE_SubLotNumber.Text = Worksheets("Calendar").Cells(i, 49).Value

If SE_FPR_SentTo.Value <> "" Then SE_Send_Plan_Request.Visible = False
If SE_FPR_SentTo.Value <> "" Then SE_Plan_Received.Visible = True
If SE_FPR_SentTo.Value <> "" Then SE_PR_SentTo.Visible = True
If SE_FPR_SentTo.Value <> "" Then SE_PR_Sent.Visible = True
If SE_FPR_Received.Value <> "" Then SE_PR_Received.Visible = True
If SE_SubLotNumberWithAsterisk.Text Like "." Then SE_Confirm.Visible = False

CheckEditJobs

End If
Next
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,
Try using the controls change event to check for the existence of specified character and display commandbutton accordinlgy

VBA Code:
Private Sub SE_SubLotNumberWithAsterisk_Change()
    Const CharNotAllowed As String = "J"
    Me.SE_Confirm.Visible = InStr(1, Me.SE_SubLotNumberWithAsterisk.Text, CharNotAllowed, vbTextCompare) = 0
End Sub

Dave
 
Upvote 0
Solution
Hi,
Try using the controls change event to check for the existence of specified character and display commandbutton accordinlgy

VBA Code:
Private Sub SE_SubLotNumberWithAsterisk_Change()
    Const CharNotAllowed As String = "J"
    Me.SE_Confirm.Visible = InStr(1, Me.SE_SubLotNumberWithAsterisk.Text, CharNotAllowed, vbTextCompare) = 0
End Sub

Dave

Very nice solution. Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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