hello
in earlier time i got help from @Akuini in this thread using loop to populate data in textboxes and comboboxes after matching to populate data from sheet to multiple controls(comboboxes and textboxes) . now I would mod this code by add command button to copy data from userform to sheet
thanks in advance
in earlier time i got help from @Akuini in this thread using loop to populate data in textboxes and comboboxes after matching to populate data from sheet to multiple controls(comboboxes and textboxes) . now I would mod this code by add command button to copy data from userform to sheet
VBA Code:
Sub toPopulate()
Dim c As Range
Dim tx As String
Dim i As Long, j As Long, k As Long, m As Long
tx = Me.ComboBoxSearch.Value
ws.Cells(1).CurrentRegion.Sort Key1:=ws.Cells(1), Order1:=xlAscending, Header:=xlYes
Set c = ws.Columns(1).Find(What:=tx, LookIn:=xlValues, lookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then
k = WorksheetFunction.CountIf(ws.Columns(1), tx)
If k > nSet Then MsgBox "Too many invoices. You need more textbox & combobox": Exit Sub
For j = 1 To k
For i = 1 To 6
Me.Controls(ary(i + m)).Value = c.Offset(j - 1, i - 1).Value
Next
m = m + 6
Next
End If
End Sub