Solved

Arrange description with other options

Posted on 2016-08-30
14
38 Views
Last Modified: 2016-09-01
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

0
Comment
Question by:Omar Hernandez
  • 7
  • 7
14 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41777375
Excel file?
0
 

Author Comment

by:Omar Hernandez
ID: 41777381
forgot about this part. Here you go is with this comment.
completed-8-29-22.xlsm
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41779265
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
 

Author Comment

by:Omar Hernandez
ID: 41779281
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
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41779294
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
 

Author Comment

by:Omar Hernandez
ID: 41779295
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
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41779300
First let me know if the last code worked as intended?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Omar Hernandez
ID: 41779302
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
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41779314
That is because there are hidden rows in the data which contain the number 3
0
 

Author Comment

by:Omar Hernandez
ID: 41779326
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
 

Author Comment

by:Omar Hernandez
ID: 41779330
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
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 41779342
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
 

Author Closing Comment

by:Omar Hernandez
ID: 41779344
Thanks again Saqib i really appreciate the help you provide.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41779349
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now