|
Subject:
|
select cell directly underneath command button
|
|
Posted By:
|
jcellens
|
Post Date:
|
4/13/2006 5:19:41 PM
|
how do i code a command button so that no matter what the active cell is, when the button is clicked, the cell that the command button is positioned in gets selected. by the way, the button ultimately adds another line somewhere above itself so the button will not always be in the exact same cell. thanks
|
|
Reply By:
|
maccas
|
Reply Date:
|
4/19/2006 4:04:28 AM
|
You need to use the TopLeftcell property of the CommandButton. The following code is written on the assumption that the command button is contained within one cell, if it is in more than one cell then you may need to modify as appropriate
Private Sub cmdTest_Click()
Dim i As Long
cmdTest.TopLeftCell.Select
i = cmdTest.TopLeftCell.Row
ActiveSheet.Rows((i - 1) & ":" & (i - 1)).Insert Shift:=xlDown
End Sub
HTH, Maccas
|