ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,699
- Office Version
- 2007
- Platform
- Windows
Hi,
I am using the code below.
I run the code make a selection from ComboBox1,& add values to TextBox2,3 & 4
TextBox values 2,3 & 4 and sent to cell columns U,V & W which is corect.
The issue is column Y generates something.
Please see attached screen shot
And also
I am using the code below.
I run the code make a selection from ComboBox1,& add values to TextBox2,3 & 4
TextBox values 2,3 & 4 and sent to cell columns U,V & W which is corect.
The issue is column Y generates something.
Please see attached screen shot
Rich (BB code):
Private Sub CommandButton1_Click()
Dim lastRow As Long, i As Long
Dim wsGIncome As Worksheet
Dim arr(1 To 5) As Variant
Dim Prompt As String
Set wsGIncome = ThisWorkbook.Worksheets("G INCOME")
For i = 1 To UBound(arr)
arr(i) = Choose(i, ComboBox1.Value, TextBox2.Value, TextBox3.Value, TextBox4.Value)
If Len(arr(i)) = 0 Then
MsgBox "YOU MUST COMPLETE ALL THE FIELDS", vbCritical, "ADD CUSTOMERS NAME MESSAGE"
Exit Sub
End If
Next i
Application.ScreenUpdating = False
With wsGIncome
lastRow = .Cells(.Rows.Count, "U").End(xlUp).Row + 1
With .Cells(lastRow, 21).Resize(, UBound(arr))
.Value = arr
.Font.Name = "Calibri"
.Font.Size = 11
.Font.Bold = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Borders.Weight = xlThin
.Interior.ColorIndex = 6
.Cells(1, 1).HorizontalAlignment = xlLeft
Application.ErrorCheckingOptions.BackgroundChecking = False
End With
.Range("U5").Select
End With
Unload ADDNAME
Application.ScreenUpdating = True
With ActiveSheet.Sort
With .SortFields
.Clear
.Add Key:=Range("U4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
End With
.SetRange Range("U4").CurrentRegion
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
MsgBox "DATABASE SUCCESSFULLY UPDATED", vbInformation, "GRASS INCOME NAME & ADDRESS MESSAGE"
End Sub
And also
Rich (BB code):
Private Sub ComboBox1_Click()
Me.TextBox2.Value = Sheets("G INCOME").Range("U" & Me.ComboBox1.ListIndex + 3).Value
Me.TextBox3.Value = Sheets("G INCOME").Range("V" & Me.ComboBox1.ListIndex + 3).Value
Me.TextBox4.Value = Sheets("G INCOME").Range("W" & Me.ComboBox1.ListIndex + 3).Value
End Sub