• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Change macro to format cell on click Button

Danilão

New Member
Hi everybody ,
I would like to change code so that instead selecting the cell to press the button, just by pressing the button, execute at once .
 

Attachments

  • PA.xlsm
    26.4 KB · Views: 9
As far as I understand your question give this a try:
Code:
Sub CreateButton()
ActiveSheet.Range("N" & ActiveSheet.Buttons(Application.Caller).TopLeftCell.Row).Select
With Selection
    .Offset(0, -3).Font.Color = RGB(0, 176, 80)
    .Offset(0, -3).Font.Bold = True
    .Offset(0, -3).ClearComments
    If Len(.Offset(0, -3).Value) > 0 Then .Offset(0, -3).AddComment
    .Offset(0, -3).Comment.Shape.AutoShapeType = msoShapeRoundedRectangle
    .Offset(0, -3).Comment.Text Text:=UCase(Environ("username")) & Chr(10) & "Low in " & Format(Now())
     With .Offset(0, -3).Comment.Shape.TextFrame
        .Characters(1, Len(Environ("USERNAME"))).Font.Bold = True
        .AutoSize = True
    End With
End With
End Sub
 
As far as I understand your question give this a try:
Code:
Sub CreateButton()
ActiveSheet.Range("N" & ActiveSheet.Buttons(Application.Caller).TopLeftCell.Row).Select
With Selection
    .Offset(0, -3).Font.Color = RGB(0, 176, 80)
    .Offset(0, -3).Font.Bold = True
    .Offset(0, -3).ClearComments
    If Len(.Offset(0, -3).Value) > 0 Then .Offset(0, -3).AddComment
    .Offset(0, -3).Comment.Shape.AutoShapeType = msoShapeRoundedRectangle
    .Offset(0, -3).Comment.Text Text:=UCase(Environ("username")) & Chr(10) & "Low in " & Format(Now())
     With .Offset(0, -3).Comment.Shape.TextFrame
        .Characters(1, Len(Environ("USERNAME"))).Font.Bold = True
        .AutoSize = True
    End With
End With
End Sub
Thanks a lot , Belleke !!!
Perfect !!!!
 
Back
Top