ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Macro ActiveCell.Offset (https://www.excelbanter.com/excel-programming/373083-vba-macro-activecell-offset.html)

Ted Mercer

VBA Macro ActiveCell.Offset
 
I am trying to find out why I am able to select a single cell Range in a
Macro but not a multi cell one. For example: ActiveCell.Offset(-2,
Counter1).Select This works. Single cell.
ActiveCell.Offset(-2, Counter1):ActiveCell.Offset(-1, Counter1).Select
This does not work. Multi cell, with or without enclosing end brackets.
Counter is the count in a For/Next loop.
I also tried using relative RC notation but had the same problem.
Your help would be appreciated.



Bob Phillips

VBA Macro ActiveCell.Offset
 
Range(ActiveCell.Offset(-2, Counter1),ActiveCell.Offset(-1,
Counter1)).Select

or

ActiveCell.Offset(-1, Counter1).Resize(2).Select

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ted Mercer" wrote in message
...
I am trying to find out why I am able to select a single cell Range in a
Macro but not a multi cell one. For example: ActiveCell.Offset(-2,
Counter1).Select This works. Single cell.
ActiveCell.Offset(-2, Counter1):ActiveCell.Offset(-1, Counter1).Select
This does not work. Multi cell, with or without enclosing end brackets.
Counter is the count in a For/Next loop.
I also tried using relative RC notation but had the same problem.
Your help would be appreciated.





Dave Peterson

VBA Macro ActiveCell.Offset
 
How about:

Range(ActiveCell.Offset(-2, Counter1), ActiveCell.Offset(-1, Counter1)).Select

Or even:

ActiveCell.Offset(-2, Counter1).Resize(2, 1).Select



Ted Mercer wrote:

I am trying to find out why I am able to select a single cell Range in a
Macro but not a multi cell one. For example: ActiveCell.Offset(-2,
Counter1).Select This works. Single cell.
ActiveCell.Offset(-2, Counter1):ActiveCell.Offset(-1, Counter1).Select
This does not work. Multi cell, with or without enclosing end brackets.
Counter is the count in a For/Next loop.
I also tried using relative RC notation but had the same problem.
Your help would be appreciated.


--

Dave Peterson


All times are GMT +1. The time now is 01:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com