[RESOLVED] floating command button within a range
Hi everyone,
I found a way of adding a floating command button through googling, but I would like to only assign this to the first 7 columns of the worksheets and have the command button always to the right of the 7th column.
Here is the code I have for now which will put the command button to the right of the active cell. It does not seem to work when I put range into the code.
I am trying to make the command button always appear at the right hand side of the 7th column when the active cell is within the first 7 columns otherwise it will not show up or it would not change its position.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Shapes(1).Left = ActiveCell.Left + ActiveCell.Width + 3
ActiveSheet.Shapes(1).Top = ActiveCell.Top
End Sub
I am not sure if this is achievable.
Thank you.
Re: floating command button within a range
An example:
Code:
Sub Macro1()
Dim shapeLeft As Integer
Dim i As Integer
For i = 1 To 7
shapeLeft = shapeLeft + Columns(i).Width
Next i
ActiveSheet.Shapes(1).Left = shapeLeft
End Sub
Re: floating command button within a range
vb Code:
if target.column > 8 then
' your code
end if