Add ID number next to customer row from userform transfer

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. 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

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
 

Attachments

  • EaseUS_2024_05_10_18_09_47.jpg
    EaseUS_2024_05_10_18_09_47.jpg
    68.9 KB · Views: 12

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I have used this below which applies a row number if the cell to the right has a value.

Currently if no value is in the cell to the right i see either ## or #NAME? depending on column width.

How do i change the code below so nothing is shown as opposed ## or #NAME?

Rich (BB code):
=IF(N4<>"",COUNTA($N$4:N4),””)
 
Upvote 0
I have used this below which applies a row number if the cell to the right has a value.

Currently if no value is in the cell to the right i see either ## or #NAME? depending on column width.

How do i change the code below so nothing is shown as opposed ## or #NAME?

Rich (BB code):
=IF(N4<>"",COUNTA($N$4:N4),””)
Excel does NOT like slanted quote marks. Use straight ones like you show at the beginning of your formula.

So your formula should look like this:
Excel Formula:
=IF(N4<>"",COUNTA($N$4:N4),"")
 
Upvote 0

Forum statistics

Threads
1,224,743
Messages
6,180,687
Members
452,994
Latest member
Janick

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