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
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

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...
 

Watch MrExcel Video

Forum statistics

Threads
1,108,624
Messages
5,523,966
Members
409,547
Latest member
AW2020

This Week's Hot Topics

Top