![]() |
Form Button - Select Row
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. |
Form Button - Select Row
You can try this
Sub Button1_Click() Dim rw As Long rw = Range(ActiveSheet.Shapes(Application.Caller).TopLe ftCell.Address).Row Range(Cells(rw, "A"), Cells(rw, "D")).Select End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Paul Brown" wrote in message ... 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. |
Form Button - Select Row
Thanks Ron,
Exactly what I was looking for - works a treat. Paul. "Ron de Bruin" wrote in message ... You can try this Sub Button1_Click() Dim rw As Long rw = Range(ActiveSheet.Shapes(Application.Caller).TopLe ftCell.Address).Row Range(Cells(rw, "A"), Cells(rw, "D")).Select End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Paul Brown" wrote in message ... 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. |
Form Button - Select Row
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 -- tony h ------------------------------------------------------------------------ tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074 View this thread: http://www.excelforum.com/showthread...hreadid=503367 |
Form Button - Select Row
Thanks Tony.
Paul. "tony h" wrote in message ... 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 -- tony h ------------------------------------------------------------------------ tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074 View this thread: http://www.excelforum.com/showthread...hreadid=503367 |
All times are GMT +1. The time now is 07:08 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com