Form Button - Select Row

  • Thread starter Thread starter Paul Brown
  • Start date Start date
P

Paul Brown

Hello all,

I'm looking to create a macro which will run from a Form Button. Form
buttons will be located at the end of each row. How can I make the form
button select the cells in the row that the form button is on? For example
if the active cell is c12 and I press the form button at the end of row 5
the macro runs fine but it runs on the data in row 12 rather than row 5
(basically it copies that data and moves it somewhere else).

Any help appreciated.

Paul.
 
You can try this

Sub Button1_Click()
Dim rw As Long
rw = Range(ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address).Row
Range(Cells(rw, "A"), Cells(rw, "D")).Select
End Sub
 
Sub button1_click()
Dim shp As Shape
Dim rng As Range

Set shp = ActiveSheet.Shapes(Application.Caller)

Set rng = shp.BottomRightCell.EntireRow
rng.Select




End Sub

run from the click event
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top