replace button

MrCo0ol

New Member
Joined
Sep 23, 2014
Messages
3
I want to create a button that when some one click the button, it will replace "A" to "AP"in a specific column

Actully the case is i want to make a approve button for my manager to approve leave. We mark the leave record "A" if the manager agree he click the button it wil turn AP, for slick leave, mark S , when click the button it turn SP.
Since one button only refer to one coulnm(one person) the other column remain unchange. Pls help, is urgent
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

ParamRay

Well-known Member
Joined
Aug 6, 2014
Messages
1,195
.
.

Add a Command Button (ActiveX Control) to your worksheet with the following code (which should be placed in the code module corresponding to that specific worksheet).

Then select the cells containing your "A" or "S" values and click the command button. "A" will be replaced with "AP" and "S" will be replaced with "SP".

Code:
Private Sub CommandButton1_Click()

    If TypeName(Selection) = "Range" Then
        Dim Cell As Range
        For Each Cell In Selection
            With Cell
                Select Case .Value
                    Case Is = "A": .Value = "AP"
                    Case Is = "S": .Value = "SP"
                End Select
            End With
        Next Cell
    End If

End Sub
 

MrCo0ol

New Member
Joined
Sep 23, 2014
Messages
3
I want to create a button that when some one click the button, it will replace "A" to "AP"in a specific column

Actully the case is i want to make a approve button for my manager to approve leave. We mark the leave record "A" if the manager agree he click the button it wil turn AP, for slick leave, mark S , when click the button it turn SP.
Since one button only refer to one coulnm(one person) the other column remain unchange. Pls help, is urgent

Someone help me please=[
 

MrCo0ol

New Member
Joined
Sep 23, 2014
Messages
3
It works but can you make it to find "A" or "S" in a specific column, if it find A replace to ap if it find s replace to sp.
Thank you for yor help
 

ParamRay

Well-known Member
Joined
Aug 6, 2014
Messages
1,195
.
.

Select the column and then click the command button...
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,598
Messages
5,832,644
Members
430,150
Latest member
amitk1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top