Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
André - Brazil
 
Posts: n/a
Default Can I use variables in a Range function?

I´m triyng to use a variable content in a Range function without success,
Example:

LINHAREF = 10
Do While LINHAREF < 40
Lk = "K" + Str(LINHAREF)
MsgBox Range(Lk)
LINHAREF = LINHAREF +1
Loop

  #2   Report Post  
Duke Carey
 
Posts: n/a
Default

You've DIMmed LINHAREF as an Integer, right?

Change it to: Lk = "K" & LINHAREF

Works for me.



"André - Brazil" wrote:

I´m triyng to use a variable content in a Range function without success,
Example:

LINHAREF = 10
Do While LINHAREF < 40
Lk = "K" + Str(LINHAREF)
MsgBox Range(Lk)
LINHAREF = LINHAREF +1
Loop

  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

You can also use cells().

LINHAREF = 10
Do While LINHAREF < 40
MsgBox cells(linharef,"K").value
LINHAREF = LINHAREF +1
Loop

André - Brazil wrote:

I´m triyng to use a variable content in a Range function without success,
Example:

LINHAREF = 10
Do While LINHAREF < 40
Lk = "K" + Str(LINHAREF)
MsgBox Range(Lk)
LINHAREF = LINHAREF +1
Loop


--

Dave Peterson
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
Passing a range name as an argument to the Index Function Michael Sharpe Excel Discussion (Misc queries) 3 September 5th 12 01:33 PM
clock Wildman Excel Worksheet Functions 2 April 26th 05 10:31 AM
Function to determine if any cell in a range is contained in a given cell [email protected] Excel Worksheet Functions 3 February 7th 05 04:19 PM
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function Oscar Excel Worksheet Functions 2 January 11th 05 11:01 PM
Formula to list unique values JaneC Excel Worksheet Functions 4 December 10th 04 12:25 AM


All times are GMT +1. The time now is 05:57 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"