VBA code for creating floating button in excel sheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If (Target.Column < 2 And Target.Row < 2) Then Exit Sub
With ActiveSheet.Shapes("CommandButton1")
.Top = Target.Offset(, 0).Top
.Left = Target.Offset(, 0).Left
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If (Target.Column < 2 And Target.Row < 2) Then Exit Sub
With ActiveSheet.Shapes("CommandButton1")
.Top = Target.Offset(, 0).Top
.Left = Target.Offset(, 0).Left
End With
End Sub
No comments:
Post a Comment