LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to define a range using variables

Try this syntax

Sub atlanticcable()
Dim myrange As Range
x = "A"
y = "B"
Set myrange = Range(x & "1:" & y & "1")
myrange.Select
End Sub

Mike

"Givnik" wrote:

How do I assign a range dynamically ie using a string variable, basically I
have a sheet that varies in the number of rows and I do a for next loop but
as yet have not worked out the syntax for how to use a variable in the Range
command... Range("x2:x10").Cells
Code so far

For Each cell In Range("x2:x10").Cells
If cell.PrefixCharacter = "'" Then
cell.Value = cell.Value
End If
Next cell

is it posisble to have something like:
strRange = "X2:X189"
For Each cell In Range(strRange).Cells

 
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
Using variables to define a range of cells? Matt[_39_] Excel Programming 2 July 24th 06 09:29 PM
VERY Basic Define Variables Help Needed BEEJAY Excel Programming 12 September 30th 05 08:10 PM
How to use variables to define range Dolemite Excel Programming 4 August 12th 05 06:12 PM
How do you define variables in excel? BigRon Excel Discussion (Misc queries) 6 April 16th 05 08:47 PM
Could we define series variables in one statement? Together[_7_] Excel Programming 1 March 1st 04 07:04 AM


All times are GMT +1. The time now is 03:13 PM.

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

About Us

"It's about Microsoft Excel"