Hello All, Cant seem to make this bit of code work. I am trying to hold the position of the command button while scrolling through worksheet. The worksheet has freeze pane on row 1 but I don't want the close report button (commandbutton1) to disappear from the viewable area while scrolling. The reason for this is the button is used to show the userform when done viewing the report. Found the code below in a similar post.
Private Sub CommandButton1_Click()
'Closes report and goes back to Userform1
UserForm1.Show
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'With ActiveWindow.VisibleRange.Resize(1, 1).Offset(1, 1)
' ActiveSheet.Shapes("CommandButton1").Top = .Top: ActiveSheet.Shapes("CommandButton1").Left = .Left
With ActiveSheet.Shapes("CommandButton1")
.Top = ActiveCell.Bottom
.Left = ActiveCell.Left + 2 * ActiveCell.Width
End With
End Sub
Bookmarks