ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Range using variables (https://www.excelbanter.com/excel-programming/347377-select-range-using-variables.html)

StephanieH

Select Range using variables
 
I need to select a range from the active cell 16 rows down and a variable
number of columns to the left. I've named my variable "MyMonths", but I'm
not sure how to incorporate it into a range address.




StephanieH

Select Range using variables
 
Nevermind. I answered my own question.

ActiveCell.Range(Cells(1, 1), Cells(16, MyMonths)).Select



"StephanieH" wrote:

I need to select a range from the active cell 16 rows down and a variable
number of columns to the left. I've named my variable "MyMonths", but I'm
not sure how to incorporate it into a range address.




Jim Thomlinson[_4_]

Select Range using variables
 
Define "variable number of columns to the left". Back to Column A or ??? If
Column A then...

dim rngTo Select as range
dim wks as worksheet

set wks = activesheet
set rngtoSelect = wks.range(activecell, .cells(activecell.row + 16, "A"))

rngtoselect.select
--
HTH...

Jim Thomlinson


"StephanieH" wrote:

I need to select a range from the active cell 16 rows down and a variable
number of columns to the left. I've named my variable "MyMonths", but I'm
not sure how to incorporate it into a range address.




Bob Phillips[_6_]

Select Range using variables
 
Activecell.Offset().MyMonths).Resize(16,MyMonths). Select

--

HTH

RP
(remove nothere from the email address if mailing direct)


"StephanieH" wrote in message
...
I need to select a range from the active cell 16 rows down and a variable
number of columns to the left. I've named my variable "MyMonths", but I'm
not sure how to incorporate it into a range address.






StephanieH

Select Range using variables
 
I thought I had it before, but only close.

It's working now. Thanks Bob and Jim.



"Bob Phillips" wrote:

Activecell.Offset().MyMonths).Resize(16,MyMonths). Select

--

HTH

RP
(remove nothere from the email address if mailing direct)


"StephanieH" wrote in message
...
I need to select a range from the active cell 16 rows down and a variable
number of columns to the left. I've named my variable "MyMonths", but I'm
not sure how to incorporate it into a range address.








All times are GMT +1. The time now is 05:16 PM.

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