Arrange description with other options

Hello Experts Exhange community, i am trying to make three other buttons to function with this userform code.

When i click on the userform button ("HOLD" - " ZCOMPLETED" or "AUTO ARRANGE") button make the exixting description on those column replaced with those on button description then search for other row that has the same task with folder name and automatically change those as well.

make the exixting description on those column replaced with those on button description then search for other row that has the same task with folder name and automatically change those as well.
***Change cells with "HOLD --"
***Change cells with "ZCOMPLETED --"
***Change cells with (AUTO ARRANGE #)

Fyi: the actual userform works the only additions will be these three button to have same concept as the actual userform.

images and code with better description is underneath this line, Thanks again Experts Exchange community.

Number-Arange-With-Options.pngNumber-Arange-with-options-2.pngNumber-Arange-with-options-3.pngNumber-Arange-with-options-4.png
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(ActiveCell.EntireRow.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 CommandButton6_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

Open in new window

Omar HernandezAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Saqib Husain, SyedConnect With a Mentor EngineerCommented:
This is a new requirement. You would have close this question if this question has been correctly  answered. Then you can ask a new question.
0
 
Saqib Husain, SyedEngineerCommented:
Excel file?
0
 
Omar HernandezAuthor Commented:
forgot about this part. Here you go is with this comment.
completed-8-29-22.xlsm
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
Saqib Husain, SyedEngineerCommented:
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(ActiveCell.EntireRow.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 Val(lft) > mx Then mx = Val(lft)
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

Open in new window

0
 
Omar HernandezAuthor Commented:
Hello there Saqib, thanks for your response.

The number works perfectly if i am changing numbers to numbers, but when i
***click on a number and try to change it to "HOLD" or "ZCOMPLETED" it gives me a run time error
***Also when i click on Auto arrange if i click on it and the last number was 9 that was assaign to a column, once i delete numbers pertaining to that column and i then go to a task and click on the AUTO ARRANGE button, there not being no numbers it still continue where it last ended and go on from 10 on. Instead of checking for what is the last number in that column and continue from what ever is the last number in that column.
---For example greatest number in that column is 6 if i hit on auto arrange it will show 7.
Back to back example.
---For example greatest number in that column is 3 if i hit on auto arrange it will show 4. and so on

Fyi: if the "--" that pertain to the six column is problematic i would not mind if you have it
 "2"       "HOLD"      "ZCOMPLETED"
instead of having
"2--"      "HOLD --"    "ZCOMPLETED"

error.png
0
 
Saqib Husain, SyedEngineerCommented:
try
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 Val(lft) > mx Then mx = Val(lft)
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

Open in new window

0
 
Omar HernandezAuthor Commented:
Hey Saqib another inconvenience also pop

Fyi: if it is more helpful for you

add a code where, when those condition are met before applying new description to column "F" erase any words and apply the new informaiton to column "F"

more better understanding what i am saying please check the image below.
moving-from-zcompleted-to-hold.png
moving-from-zcompleted-to-hold-2.png
moving-from-zcompleted-to-hold-then-.png
0
 
Saqib Husain, SyedEngineerCommented:
First let me know if the last code worked as intended?
0
 
Omar HernandezAuthor Commented:
all other inconvenience are solved the only part that will need a little tweaking is the part of the Auto Arrange button even if there is no number it starts on number 4
0
 
Saqib Husain, SyedEngineerCommented:
That is because there are hidden rows in the data which contain the number 3
0
 
Omar HernandezAuthor Commented:
I see what your are saying,  when Auto Arrange is click can it exclude all other words that has numbers if it is not under the same name of row column "E" college

For example

on college is 5
on business is 2
on accounting is 4

If i click on auto arrange

on college it will start on 6
on business it will start on 3
on accounting it will start on 5
0
 
Omar HernandezAuthor Commented:
this is what i meant, when Auto Arrange is click can it exclude all other words that has numbers if it is not under the same name of  column "E" college.
0
 
Omar HernandezAuthor Commented:
Thanks again Saqib i really appreciate the help you provide.
0
 
Saqib Husain, SyedEngineerCommented:
Being pedantic, you should have selected the comment which contains the solution which correctly answers the question.

Anyways thanks for the appreciation. Glad to help.
0
All Courses

From novice to tech pro — start learning today.