Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default refering to a range with a variable

I'm looking for a way to refer to a range with a variable. Let me
demonstrate.

Dim MyVar
MyVar = ActiveCell.Value
Range("A14").Select

I've tried this:

Dim MyVar
MyVar = ActiveCell.Value
Range("A(MyVar)").Select

But (of course) it doesn't work; however this is essentially what I
need.

How can I make this happen?


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default refering to a range with a variable

Hi
try
sub foo()
Dim rng as range
set rng = activecell
msgbox rng.value
end sub

--
Regards
Frank Kabel
Frankfurt, Germany

I'm looking for a way to refer to a range with a variable. Let me
demonstrate.

Dim MyVar
MyVar = ActiveCell.Value
Range("A14").Select

I've tried this:

Dim MyVar
MyVar = ActiveCell.Value
Range("A(MyVar)").Select

But (of course) it doesn't work; however this is essentially what I
need.

How can I make this happen?


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default refering to a range with a variable

Dim MyVar as String

Myvar = ActiveCell.Address
Range("A14").Select
Range(MyVar).Select

If you want to select a cell in column A where the specific row number is
specified in the activecell

myVar - ActiveCell.Value
Range("A" & myVar).Select

or

Cells(ActiveCell.Value, "A").Select

--
Regards,
Tom Ogilvy

"eyecalibrate " wrote in
message ...
I'm looking for a way to refer to a range with a variable. Let me
demonstrate.

Dim MyVar
MyVar = ActiveCell.Value
Range("A14").Select

I've tried this:

Dim MyVar
MyVar = ActiveCell.Value
Range("A(MyVar)").Select

But (of course) it doesn't work; however this is essentially what I
need.

How can I make this happen?


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you name a worksheet by refering to a cell reference or range o2bing Excel Discussion (Misc queries) 10 March 21st 08 07:18 AM
Refering to a named range in a chart: 2007 fruitticher Excel Worksheet Functions 1 September 14th 07 06:52 PM
OFFSET() not working within a SUMPRODUCT() when refering to a range in a pivot table Conan Kelly Excel Worksheet Functions 6 April 11th 07 12:32 AM
Change the Range refering to a Name TonTon165 Excel Discussion (Misc queries) 2 June 27th 06 03:28 PM
Simple problem refering to variable in For ... Next loop ... Chris Excel Programming 1 July 15th 03 01:00 AM


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"