Hello Chandoo community i am trying to get this thing to work as a dynamic means. Would appreciate an extra help. Thanks again for your time.
1st. When i want to change the number of five to two if there is already a two on column "F" have it move to three
three to four
four to five
and so on
2nd. when changing the description on column "F" if i click on ZCOMPLETED this will send it to row under description ZCOMPLETED. If i click on the generate button i want it to automatically work as a dynamic means. That if description 1 is done move "2 *" to "1 *"
move "3 *" to "2 *"
move "4 *" to "3 *"
and so on.
1st. When i want to change the number of five to two if there is already a two on column "F" have it move to three
three to four
four to five
and so on
2nd. when changing the description on column "F" if i click on ZCOMPLETED this will send it to row under description ZCOMPLETED. If i click on the generate button i want it to automatically work as a dynamic means. That if description 1 is done move "2 *" to "1 *"
move "3 *" to "2 *"
move "4 *" to "3 *"
and so on.
Code:
Sub openuserform()
NumberArange.Show
End Sub
Private Sub CommandButton1_Click()
NumberArange.MyNumber.Caption = NumberArange.MyNumber.Caption + 1
End Sub
Private Sub CommandButton2_Click()
NumberArange.MyNumber.Caption = NumberArange.MyNumber.Caption - 1
End Sub
Private Sub CommandButton3_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim rw As Range
Set ws = Worksheets("GENERAL")
For Each rw In ActiveSheet.UsedRange.Rows
If rw.Cells(1, 5) = Label3.Caption And rw.Cells(1, 4) = Label4.Caption Then
rw.Cells(1, 6) = MyNumber.Caption & Right(rw.Cells(1, 6), Len(rw.Cells(1, 6)) - InStr(rw.Cells(1, 6), " ") + 1)
End If
Next rw
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
End Sub
Private Sub CommandButton4_Click()
Unload Me
End Sub
Private Sub CommandButton5_Click()
Dim rw As Range
Dim mx As Integer
Dim lft As String
mx = 0
For Each rw In ActiveSheet.UsedRange.Rows
If InStr(rw.Cells(1, 6), " ") > 0 Then
lft = Left(rw.Cells(1, 6), InStr(rw.Cells(1, 6), " ") - 1)
If IsNumeric(lft) Then
If rw.Cells(1, 5) = ActiveCell.EntireRow.Cells(1, 5) Then
If Val(lft) > mx Then mx = Val(lft)
End If
End If
End If
Next rw
MyNumber.Caption = mx + 1
End Sub
Private Sub CommandButton6_Click()
MyNumber.Caption = CommandButton6.Caption
End Sub
Private Sub CommandButton7_Click()
MyNumber.Caption = CommandButton7.Caption
End Sub
Private Sub MyNumber_Click()
End Sub
Private Sub UserForm_Activate()
If ActiveCell.EntireRow.Cells(1, 6) <> "" Then MyNumber.Caption = Left(ActiveCell.EntireRow.Cells(1, 6), InStr(ActiveCell.EntireRow.Cells(1, 6), " ") - 1)
If ActiveCell.EntireRow.Cells(1, 5) <> "" Then Label3.Caption = ActiveCell.EntireRow.Cells(1, 5)
If ActiveCell.EntireRow.Cells(1, 4) <> "" Then Label4.Caption = ActiveCell.EntireRow.Cells(1, 4)
End Sub