ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,726
- Office Version
- 2007
- Platform
- Windows
The code i have in use is shown below & also a screenshot to assist you.
My goal now is to apply a ID number of which is placed in column M
The ID number has no connection with the customer,its only there for my purpose,so as & when customers are deleted the ID number next to them will change hence no connection to customer.
As you can see my last userform to worksheet transfer has no ID number which should be 37
Something to remember that should the customer at row 28 "ROY" be deleted then currently that customer's row would be deleted & the rows below would just simply be moved up.
BUT
I dont want the last ID number NOT to have a blank row of cells to the right of it etc.
So basically if a customer is added then we add another ID number, If a customer is deleted then we delete an ID number.
So if we have 44 customers then the ID will be 1-44
My goal now is to apply a ID number of which is placed in column M
The ID number has no connection with the customer,its only there for my purpose,so as & when customers are deleted the ID number next to them will change hence no connection to customer.
As you can see my last userform to worksheet transfer has no ID number which should be 37
Something to remember that should the customer at row 28 "ROY" be deleted then currently that customer's row would be deleted & the rows below would just simply be moved up.
BUT
I dont want the last ID number NOT to have a blank row of cells to the right of it etc.
So basically if a customer is added then we add another ID number, If a customer is deleted then we delete an ID number.
So if we have 44 customers then the ID will be 1-44
Rich (BB code):
Private Sub TransferValues_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, TextBox1.Value, TextBox2.Value, TextBox3.Value, TextBox4.Value, TextBox5.Value)
If Len(arr(i)) = 0 Then
MsgBox "YOU MUST COMPLETE ALL THE FIELDS", vbCritical, "USERFORM FIELDS EMPTY MESSAGE"
Exit Sub
End If
Next i
Application.ScreenUpdating = False
With wsGIncome
Lastrow = .Cells(.Rows.Count, "N").End(xlUp).Row + 1
With .Cells(Lastrow, 14).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
With Sheets("G INCOME")
If .AutoFilterMode Then .AutoFilterMode = False
x = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range("N4:S" & x).Sort Key1:=Range("N4"), Order1:=xlAscending, Header:=xlGuess
End With
Unload ADDCUSTOMER
.Range("N4").Select
End With
Application.ScreenUpdating = True
End Sub