ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 6,071
- Office Version
- 2024
- Platform
- Windows
I have a worksheet with customers names in column A
Across the page i have values relating to that customer.
This is how it works at present.
I have a customer called TOM JONES & currently he is in row 20 BUT i need to move him to row 12
I select the customer TOM JONES in column A & click the command button, i am asked which row do i need to move him to, This is done by an input field box where i enter 12
The customer TOM JONES & his values are now shown in the new row that i advised BUT still the original TOM JONES & his values are still shown in row 20
So currently on my worksheet i have TOM JONES shown in row 20 & also TOM JONES in row 12
I then have to manually delete TOM JONES in row 20
My goal is to add some extra code to the existing code supplied below something that will delete the original instance.
Across the page i have values relating to that customer.
This is how it works at present.
I have a customer called TOM JONES & currently he is in row 20 BUT i need to move him to row 12
I select the customer TOM JONES in column A & click the command button, i am asked which row do i need to move him to, This is done by an input field box where i enter 12
The customer TOM JONES & his values are now shown in the new row that i advised BUT still the original TOM JONES & his values are still shown in row 20
So currently on my worksheet i have TOM JONES shown in row 20 & also TOM JONES in row 12
I then have to manually delete TOM JONES in row 20
My goal is to add some extra code to the existing code supplied below something that will delete the original instance.
VBA Code:
Private Sub TransferData_Click()
Dim i As Integer
Dim ControlsArr As Variant, ctrl As Variant
Dim x As Long
Dim z As Integer
z = CInt(Application.InputBox("WHICH ROW SHOULD DATA BE INSERTED INTO ?", "NEW CUSTOMER ROW NUMBER MESSAGE", Type:=1))
ControlsArr = Array(Me.TextBox1, Me.TextBox2, Me.TextBox3, Me.TextBox4, Me.TextBox5, Me.TextBox6, Me.TextBox7, Me.TextBox8, Me.TextBox9, Me.TextBox10, Me.TextBox11, Me.TextBox12)
With ThisWorkbook.Worksheets("GRASS")
.Rows(z).EntireRow.Insert Shift:=xlDown
.Rows(z).RowHeight = 25
.Rows(z).Font.Color = vbBlack
.Rows(z).Font.Bold = True
.Rows(z).Font.Size = 16
.Rows(z).Font.Name = "Calibri"
Range(.Cells(z, "A"), .Cells(z, "l")).Borders.LineStyle = xlContinuous
For i = 0 To UBound(ControlsArr)
Select Case i
Case -1
.Cells(z, i + 1) = Val(ControlsArr(i))
ControlsArr(i).Text = ""
Case Else
.Cells(z, i + 1) = ControlsArr(i)
ControlsArr(i).Text = ""
End Select
Next i
End With
ActiveWorkbook.Save
Unload MoveCustomerRow
End Sub