ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Morning,
I am using this working code below.
Currently when i run it the values are placed into Row 4
What i would like help / advice with please is as opposed to placing it in row 4 each time let the user specify the row for it to be inserted.
We have a grass cutting round so the customers are on a worksheet in round groups.
So just placing a new customer into row 4 isnt any use sames goes for sorting A-Z etc.
The user will look at the worksheet first & see that this new customer should be inserted into row 11
He would complete the form & then enter in TextBox9 the row number
The code should then create a new row & the values placed in this at row11
The existing value on the worksheet would then all move down 1 row.
Please can you assist.
Have a nice day.
I am using this working code below.
Currently when i run it the values are placed into Row 4
What i would like help / advice with please is as opposed to placing it in row 4 each time let the user specify the row for it to be inserted.
We have a grass cutting round so the customers are on a worksheet in round groups.
So just placing a new customer into row 4 isnt any use sames goes for sorting A-Z etc.
The user will look at the worksheet first & see that this new customer should be inserted into row 11
He would complete the form & then enter in TextBox9 the row number
The code should then create a new row & the values placed in this at row11
The existing value on the worksheet would then all move down 1 row.
Please can you assist.
Have a nice day.
Rich (BB code):
Private Sub CommandButton1_Click()
Dim i As Integer
Dim ControlsArr As Variant, ctrl As Variant
Dim x As Long
For i = 1 To 6
With Me.Controls("ComboBox" & i)
If .ListIndex = -1 Then
MsgBox "MUST SELECT ALL OPTIONS", 48, "CLONING TRANSFER SHEET"
.SetFocus
Exit Sub
End If
End With
Next i
ControlsArr = Array(Me.ComboBox1, Me.ComboBox2, Me.ComboBox3, Me.ComboBox4, Me.ComboBox5, Me.ComboBox6)
With ThisWorkbook.Worksheets("CLONING")
.Range("A4").EntireRow.Insert Shift:=xlDown
.Range("A4:F4").Borders.Weight = xlThin
For i = 0 To UBound(ControlsArr)
Select Case i
Case 3
.Cells(4, i + 1) = Val(ControlsArr(i))
ControlsArr(i).Text = ""
Case Else
.Cells(4, i + 1) = ControlsArr(i)
ControlsArr(i).Text = ""
End Select
Next i
End With
Application.ScreenUpdating = False
ActiveWorkbook.Save
Application.ScreenUpdating = True
With ThisWorkbook.Worksheets("CLONING")
.Range("A5").Select
.Range("A4").Select
MsgBox "Database Has Been Updated", vbInformation, "SUCCESSFUL MESSAGE"
End With
End Sub