Macro to run relative to current selected cell
I need a macro to run relative to the current selected cell so that, if I
click the macro button the (eg.) whole current row will be selected along with the four below, etc. - and not the the specific row from which I started recording the macro. Can anyone suggest a way? Is there a code that refers to the current position? Many thanks, Mary |
Macro to run relative to current selected cell
Sub selectrngfromactivecell()
ActiveCell.Resize(4, 1).EntireRow.Select End Sub or Sub srfac() Rows(ActiveCell.Row).Resize(4).Select End Sub -- Don Guillett SalesAid Software "MahD" wrote in message ... I need a macro to run relative to the current selected cell so that, if I click the macro button the (eg.) whole current row will be selected along with the four below, etc. - and not the the specific row from which I started recording the macro. Can anyone suggest a way? Is there a code that refers to the current position? Many thanks, Mary |
Macro to run relative to current selected cell
One way:
Option Explicit Sub testme() ActiveCell.Resize(5, 1).EntireRow.Select 'do you want to go to column A of that first row? 'ActiveCell.EntireRow.Cells(1).Activate End Sub MahD wrote: I need a macro to run relative to the current selected cell so that, if I click the macro button the (eg.) whole current row will be selected along with the four below, etc. - and not the the specific row from which I started recording the macro. Can anyone suggest a way? Is there a code that refers to the current position? Many thanks, Mary -- Dave Peterson |
Macro to run relative to current selected cell
Simply using your arrow keys to navigate and pressing ctrl-c while recording
will select a relative range provided the relative reference button is selected. On executing the macro it will select the range relative to where your cursor is at that time. I have not, however, found a way to take it a step further and name such a range relatively. "MahD" wrote: I need a macro to run relative to the current selected cell so that, if I click the macro button the (eg.) whole current row will be selected along with the four below, etc. - and not the the specific row from which I started recording the macro. Can anyone suggest a way? Is there a code that refers to the current position? Many thanks, Mary |
All times are GMT +1. The time now is 11:38 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com