I am not familiar with Excel VB. I have a search bar and I want to get the details by entering the style No(column C) from column A:H
. I have the data entry in excel sheet. I:J
columns need to be added.
When i enter the style No in search bar, all the details are displaying
for the column I & J i have two textbox named txtIssueDate
& txtActualIssued
.
I want to add the details for the empty fields for a particular row the which style no that i have searched in search bar.
I need to code for update button for those two textboxes when i search in search bar the details will display, i need to update the details for those textboxes My Excel Sheet
I have attached dashboard Interface.
Search Button Code:
Private Sub TextBox7_DropButtonClick()
TextBox7_DropButtonClick.Caption = Format(Date, "dd-mmm-yy")
End Sub
Private Sub cmdSearch_Click()
Dim iSearch As Long, i As Long
Dim iFound As VbMsgBoxResult
iSearch = Worksheets("Sheet1").Range("C1").CurrentRegion.Rows.Count
For i = 2 To iSearch
If Trim(Sheet1.Cells(i, 3)) <> Trim(txtSearch.Text) And i = iSearch Then
iFound = MsgBox("Item Not Found! Please update ")
cmdAddRecord.Enabled = FALSE
Dim iControl As Control
For Each iControl In Me.Controls
If iControl.Name Like "txt*" Then iControl = vbNullString
Next
txtSearch.SetFocus
End If
If Trim(Sheet1.Cells(i, 3)) = Trim(txtSearch.Text) Then
txtLine.Text = Sheet1.Cells(i, 1)
txtDescription.Text = Sheet1.Cells(i, 2)
txtStyle.Text = Sheet1.Cells(i, 3)
txtItem.Text = Sheet1.Cells(i, 4)
txtFabric.Text = Sheet1.Cells(i, 5)
txtBrand.Text = Sheet1.Cells(i, 6)
txtTotalqty.Text = Sheet1.Cells(i, 7)
txtDate.Text = Sheet1.Cells(i, 8)
txtIssueDate1.Text = Sheet1.Cells(i, 9)
txtActualIssue1.Text = Sheet1.Cells(i, 9)
cmdAddRecord.Enabled = TRUE
Exit For
End If
Next i
End Sub
Add Button Code: (But it is wrong Because I cannot add it to the relevant style No Row)
Private Sub cmdAddRecord_Click()
''If txtIssueDate1.Text = "" Then
'' MsgBox ("Fields cannot empty!")
''Else
''End If
Dim iSearch As Long, i As Long
Dim iFound As VbMsgBoxResult
iSearch = Worksheets("Sheet1").Range("C1").CurrentRegion.Rows.Count
For i = 2 To iSearch
If Trim(Sheet1.Cells(i, 3)) = Trim(txtSearch.Text) Then
Dim wks As Worksheet
Dim AddNew As Range
Set wks = Sheet1
Set AddNew = wks.Range("I65356").End(xlUp).Offset(1, 0)
AddNew.Offset(0, 0).Value = txtIssueDate1.Text
AddNew.Offset(0, 1).Value = txtActualIssue1.Text
MsgBox ("Details are Entered!")
Exit For
End If
Next i
End Sub