![]() |
setting range from activecell in macro
Hi,
I am trying to select a range of cells after selecting a cell based on an activecell.offset. For example, a line in my code looks like this: ActiveCell.Offset(2, -3).Select Now I want to select a range of three cells (the selected cell and one cell before and after the selected cell). The absolute location will not always be the same, therefore can not select range based on absolute cell references (i.e. A1:A3 or .cells(1,3),.cells(3,3) for example). Can't figure out how to do it. Any help?? |
setting range from activecell in macro
Giz,
Use the Resize method: ActiveCell.Offset(0, -1).Resize(1, 3).Select ActiveCell.Offset(-1, 0).Resize(3, 1).Select Note that you rarely need to select anything within code to make changes.... HTH, Bernie MS Excel MVP "Giz" wrote in message ... Hi, I am trying to select a range of cells after selecting a cell based on an activecell.offset. For example, a line in my code looks like this: ActiveCell.Offset(2, -3).Select Now I want to select a range of three cells (the selected cell and one cell before and after the selected cell). The absolute location will not always be the same, therefore can not select range based on absolute cell references (i.e. A1:A3 or .cells(1,3),.cells(3,3) for example). Can't figure out how to do it. Any help?? |
All times are GMT +1. The time now is 08:57 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com