Solved

Changing working code for excel vba

Posted on 2016-09-27
15
22 Views
Last Modified: 2016-10-03
Hello guys, i have tried fixing it my self with no luck, i would really appreciate if someone may help me fix this. Again thanks for your time and help.

Priority.png
Present code
Sub RectangleBeveled6_Click()
Select Case UCase(Cells(ActiveCell.Row, "H"))
    Case ""
        Cells(ActiveCell.Row, "H") = "1"
    Case "1"
        Cells(ActiveCell.Row, "H") = "2"
    Case "2"
        Cells(ActiveCell.Row, "H") = "L"
    Case "L"
        Cells(ActiveCell.Row, "H") = "Z"
    Case "Z"
        Cells(ActiveCell.Row, "H") = ""
End Select

End Sub


****Description. *****
On column "H" there is four option that will be shown here. if i click on the small button on the file.

I would like to replace these option as follow.

1 with First P
2 with Second P
3 with Last P
Z with Z Done
0
Comment
Question by:Omar Hernandez
  • 7
  • 7
15 Comments
 
LVL 18

Expert Comment

by:xtermie
ID: 41819323
Sub RectangleBeveled6_Click()
 Select Case UCase(Cells(ActiveCell.Row, "H"))
     Case ""
         Cells(ActiveCell.Row, "H") = "First P"
     Case "1"
         Cells(ActiveCell.Row, "H") = "Second P"
     Case "2"
         Cells(ActiveCell.Row, "H") = "Last P"
     Case "L"
         Cells(ActiveCell.Row, "H") = "Z Done"
     Case "Z"
         Cells(ActiveCell.Row, "H") = ""
 End Select

 End Sub
0
 

Author Comment

by:Omar Hernandez
ID: 41820979
Hello there Xtermie,thanks for your response. I have tried this, with no luck...
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41821084
In the code offered by xtermie, Tty to replace the following line...
Select Case UCase(Cells(ActiveCell.Row, "H"))

WITH THIS to see if that works as I guess there might be some spaces in the end.
Select Case UCase(LEFT(Cells(ActiveCell.Row, "H"),1))
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Omar Hernandez
ID: 41821102
Thanks for your response Neeraj, i have tried your suggestion, no luck yet friend.
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41821105
Omar!
As per the code, the code will only work for the Active Cell's Row and it will replace the content of column H in that particular row only.
Try selecting any cell on Row32 and see if J32 gets changed as per the code.
0
 

Author Comment

by:Omar Hernandez
ID: 41821114
Hey Neeraj i have tried to change even the row that is on the 32 number, no luck
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41821116
Then why not upload a sample workbook to see why the code doesn't work for you?
0
 

Author Comment

by:Omar Hernandez
ID: 41821117
Forgot about that part :/ , Here you go Neeraj
BK-TO-DO-LIST.xlsm
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41821125
I misread the code.
The code works on column H not on column J.
If you select a cell in Row86 and while H86 is 1, the code will change it's content to "Second P" as per the code.
Isn't it what you trying to achieve?
BK-TO-DO-LIST.xlsm
0
 

Author Comment

by:Omar Hernandez
ID: 41821138
Hey there Neeraj, no luck. If you click on the button shown on the pic on top, it works with no prob, but when it has to do with changing the one letter or number to a whole word it gives me an inconvenience. ***The actual code works with any row
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41821145
Sorry not getting you here.
Won't it be better if you list your steps when the code doesn't work for you?
0
 

Accepted Solution

by:
Omar Hernandez earned 0 total points
ID: 41821164
Hello there Neeraj, thanks again for your help, on my way creating a video i tried to add an additional letter to the code it worked, then i tried to keep all of them with ether one style capital letter or small letter and it worked. The code that was this.

Sub RectangleBeveled6_Click()
 Select Case UCase(Cells(ActiveCell.Row, "H"))
     Case ""
         Cells(ActiveCell.Row, "H") = "FIRST P"
     Case "FIRST P"
         Cells(ActiveCell.Row, "H") = "SECOND P"
     Case "SECOND P"
         Cells(ActiveCell.Row, "H") = "LAST P"
     Case "LAST P"
         Cells(ActiveCell.Row, "H") = "ZDONE"
     Case "ZDONE"
         Cells(ActiveCell.Row, "H") = ""
 End Select

 End Sub
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41821165
So all resolved?
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41821168
Omar!
I must say that you poorly described your requirement but anyways glad your issue has been resolved.
0
 

Author Closing Comment

by:Omar Hernandez
ID: 41826031
I tried a different approach.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel formula - data format 5 22
Cost allcocation ... 10 23
Add Attendee Macro need not halt for Acknowledgement 12 24
Calculate waiting times that spans two days 9 33
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
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 …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 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