Update row based on textbox values

Jayliam

New Member
Joined
May 12, 2015
Messages
29
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I am having an issue with finding values of a textbox and updating adjacent rows. When I enter a alphabetic value in the textbox it works but if I enter a numeric only then it comes back saying it can't find the record. Below is my code.

Private Sub CommandButton2_Click()
Dim m As Variant
Dim iRow As Long
Dim ws As Worksheet
Dim FindString As String
Dim Rng As Range
Set ws = Worksheets("DATALOG")


iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row

If Len(Me.TextBox1.Value) > 0 Then

m = Application.Match(Me.TextBox1.Value, ws.Range("A:A"), False)
If Not IsError(m) Then
m = CLng(m)

With ws

.Cells(iRow, 18).Value = Me.TextBox2.Value
.Cells(iRow, 19).Value = Me.TextBox3.Value
.Cells(iRow, 20).Value = Me.TextBox4.Value
.Cells(iRow, 21).Value = Me.TextBox59.Value
.Cells(iRow, 22).Value = Me.TextBox60.Value
.Cells(iRow, 23).Value = Me.TextBox61.Value
.Cells(iRow, 24).Value = Me.TextBox19.Value
.Cells(iRow, 25).Value = Me.TextBox7.Value
.Cells(iRow, 26).Value = Me.TextBox10.Value
.Cells(iRow, 27).Value = Me.TextBox6.Value
.Cells(iRow, 28).Value = Me.TextBox8.Value
.Cells(iRow, 29).Value = Me.TextBox11.Value
.Cells(iRow, 30).Value = Me.TextBox5.Value
.Cells(iRow, 31).Value = Me.TextBox9.Value
.Cells(iRow, 32).Value = Me.TextBox12.Value
.Cells(iRow, 33).Value = Me.TextBox13.Value
.Cells(iRow, 34).Value = Me.TextBox16.Value
.Cells(iRow, 35).Value = Me.TextBox20.Value
.Cells(iRow, 36).Value = Me.TextBox14.Value
.Cells(iRow, 37).Value = Me.TextBox17.Value
.Cells(iRow, 38).Value = Me.TextBox21.Value
.Cells(iRow, 39).Value = Me.TextBox15.Value
.Cells(iRow, 40).Value = Me.TextBox18.Value
.Cells(iRow, 41).Value = Me.TextBox22.Value
.Cells(iRow, 42).Value = Me.TextBox23.Value
.Cells(iRow, 43).Value = Me.TextBox27.Value
.Cells(iRow, 44).Value = Me.TextBox31.Value
.Cells(iRow, 45).Value = Me.TextBox24.Value
.Cells(iRow, 46).Value = Me.TextBox28.Value
.Cells(iRow, 47).Value = Me.TextBox32.Value
.Cells(iRow, 48).Value = Me.TextBox25.Value
.Cells(iRow, 49).Value = Me.TextBox29.Value
.Cells(iRow, 50).Value = Me.TextBox33.Value
.Cells(iRow, 51).Value = Me.TextBox26.Value
.Cells(iRow, 52).Value = Me.TextBox30.Value
.Cells(iRow, 53).Value = Me.TextBox34.Value
.Cells(iRow, 54).Value = Me.TextBox35.Value
.Cells(iRow, 55).Value = Me.TextBox36.Value
.Cells(iRow, 56).Value = Me.TextBox37.Value
.Cells(iRow, 57).Value = Me.TextBox38.Value
.Cells(iRow, 58).Value = Me.TextBox39.Value
.Cells(iRow, 59).Value = Me.TextBox40.Value
.Cells(iRow, 60).Value = Me.TextBox41.Value
.Cells(iRow, 61).Value = Me.TextBox43.Value
.Cells(iRow, 62).Value = Me.TextBox45.Value
.Cells(iRow, 63).Value = Me.TextBox47.Value
.Cells(iRow, 64).Value = Me.TextBox42.Value
.Cells(iRow, 65).Value = Me.TextBox44.Value
.Cells(iRow, 66).Value = Me.TextBox46.Value
.Cells(iRow, 67).Value = Me.TextBox48.Value
.Cells(iRow, 68).Value = Me.TextBox50.Value
.Cells(iRow, 69).Value = Me.TextBox51.Value
.Cells(iRow, 70).Value = Me.TextBox52.Value
.Cells(iRow, 71).Value = Me.TextBox53.Value
.Cells(iRow, 72).Value = Me.TextBox54.Value
.Cells(iRow, 73).Value = Me.TextBox55.Value
.Cells(iRow, 74).Value = Me.TextBox56.Value
.Cells(iRow, 75).Value = Me.TextBox57.Value
.Cells(iRow, 76).Value = Me.TextBox58.Value



End With

Else
MsgBox "SALE ORDER: " & Me.TextBox1 & Chr(10) & "Record Not Found", 48, "Not Found"
Me.TextBox1.SetFocus
End If

End If

End Sub
Private Sub CommandButton3_Click()
Unload Me
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
The values from a textbox are always text, so if you are trying to match against numeric values you'll need to convert the value from the textbox to a number.

You can test if the value in the textbox is numeric using IsNumeric and you can convert it using Val.
 
Upvote 0
The values from a textbox are always text, so if you are trying to match against numeric values you'll need to convert the value from the textbox to a number.

You can test if the value in the textbox is numeric using IsNumeric and you can convert it using Val.
I have never used this before. Can you send me an example please?
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,924
Members
448,533
Latest member
thietbibeboiwasaco

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