#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA-

Dim Rng as Range
Dim strName As Object
Set strName = Worksheets("12 15 03 07 KWSC1_1a").Range("O2")

How can I assign a variable to the range, rather than having the "02
cell reference? I've seen the following:

Dim Rng as Range
Dim myRange As Object
Set myRange = Worksheets("Sheet1").Range(Cells(1,1).Cells(10,5))

...as a way to use Cells and thus vary the column & row.

How can I set the range to something like:
Range(Cells(1,1))?

Thank

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel VBA-

Almost there,

Cells is a range, so just use

Cells(1,1) for a single cell.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"waveracerr " wrote in message
...
Dim Rng as Range
Dim strName As Object
Set strName = Worksheets("12 15 03 07 KWSC1_1a").Range("O2")

How can I assign a variable to the range, rather than having the "02"
cell reference? I've seen the following:

Dim Rng as Range
Dim myRange As Object
Set myRange = Worksheets("Sheet1").Range(Cells(1,1).Cells(10,5))

..as a way to use Cells and thus vary the column & row.

How can I set the range to something like:
Range(Cells(1,1))?

Thanks


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel VBA-

.... or even

Cells(1,"A") to be more Excel aware.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
Almost there,

Cells is a range, so just use

Cells(1,1) for a single cell.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"waveracerr " wrote in message
...
Dim Rng as Range
Dim strName As Object
Set strName = Worksheets("12 15 03 07 KWSC1_1a").Range("O2")

How can I assign a variable to the range, rather than having the "02"
cell reference? I've seen the following:

Dim Rng as Range
Dim myRange As Object
Set myRange = Worksheets("Sheet1").Range(Cells(1,1).Cells(10,5))

..as a way to use Cells and thus vary the column & row.

How can I set the range to something like:
Range(Cells(1,1))?

Thanks


---
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



All times are GMT +1. The time now is 09:01 AM.

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"