Avatar of Omar Hernandez
Omar Hernandez

asked on 

Changing working code for excel vba

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.

User generated image
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
Microsoft ExcelVB Script

Avatar of undefined
Last Comment
Omar Hernandez
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

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
Avatar of Omar Hernandez
Omar Hernandez

ASKER

Hello there Xtermie,thanks for your response. I have tried this, with no luck...
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))
Avatar of Omar Hernandez

ASKER

Thanks for your response Neeraj, i have tried your suggestion, no luck yet friend.
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.
Avatar of Omar Hernandez

ASKER

Hey Neeraj i have tried to change even the row that is on the 32 number, no luck
Then why not upload a sample workbook to see why the code doesn't work for you?
Avatar of Omar Hernandez

ASKER

Forgot about that part :/ , Here you go Neeraj
BK-TO-DO-LIST.xlsm
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
Avatar of Omar Hernandez

ASKER

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
Sorry not getting you here.
Won't it be better if you list your steps when the code doesn't work for you?
ASKER CERTIFIED SOLUTION
Avatar of Omar Hernandez
Omar Hernandez

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
So all resolved?
Omar!
I must say that you poorly described your requirement but anyways glad your issue has been resolved.
Avatar of Omar Hernandez

ASKER

I tried a different approach.
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo