Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Getting a range using row & col numbers?

Is this an efficient way to do this? (Code means nothing except
to illustrate)

' Get a certain range using passed-in row and column values
Function getRange(r as integer, c as integer) as Range
const maxr = 10
const maxc = 10
dim rng as Range
rng = Range(Cells(r, c), Cells(maxr, maxc))
end Function

IOW is this a good way to refer to a Range instead of doing
Range("A1:J10") syntax. I DO want the function signature to
have a row and column parms, unless there's a better generic
way.

Thsnks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Getting a range using row & col numbers?


Function getRange(ByRef r As Long, ByRef c As Long) As Excel.Range
Set getRange = Range(Range("J10"), Cells(r, c))
End Function

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Net Doe"
wrote in message
Is this an efficient way to do this? (Code means nothing except
to illustrate)

' Get a certain range using passed-in row and column values
Function getRange(r as integer, c as integer) as Range
const maxr = 10
const maxc = 10
dim rng as Range
rng = Range(Cells(r, c), Cells(maxr, maxc))
end Function

IOW is this a good way to refer to a Range instead of doing
Range("A1:J10") syntax. I DO want the function signature to
have a row and column parms, unless there's a better generic
way.
Thsnks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Getting a range using row & col numbers?

But this limits it to "J10". I want tp"fully" parameterize
the start/stop rows/cols, so the ByRef r and c are not
even necessary. I should have pseudo-coded it
this way

' Give me the Range of cells from (r1,c1) to (r2,c2)
Function getRange(r1 as integer, c1 as integer _
r2 as integer, c2 as integer) as Range
dim rng as Range
rng = Range(Cells(r1, c1), Cells(r2, c2))
end Function

"Jim Cone" wrote in message
...

Function getRange(ByRef r As Long, ByRef c As Long) As Excel.Range
Set getRange = Range(Range("J10"), Cells(r, c))
End Function

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Net Doe"
wrote in message
Is this an efficient way to do this? (Code means nothing except
to illustrate)

' Get a certain range using passed-in row and column values
Function getRange(r as integer, c as integer) as Range
const maxr = 10
const maxc = 10
dim rng as Range
rng = Range(Cells(r, c), Cells(maxr, maxc))
end Function

IOW is this a good way to refer to a Range instead of doing
Range("A1:J10") syntax. I DO want the function signature to
have a row and column parms, unless there's a better generic
way.
Thsnks!




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
How to select top six numbers from a of range of random numbers Jack M Taylor Excel Worksheet Functions 4 January 30th 07 09:18 PM
two columns range of numbers need to list all numbers in the range arsovat New Users to Excel 2 October 30th 06 08:21 PM
split range of numbers in two columns to as many as numbers in ran arsovat Excel Discussion (Misc queries) 2 October 30th 06 03:57 PM
Count comma separated numbers, numbers in a range with dash, not t Mahendra Excel Discussion (Misc queries) 0 August 8th 05 05:56 PM
How to add the 10 smallest numbers out of a range of 20 numbers. JPreeshl Excel Worksheet Functions 3 July 10th 05 02:01 PM


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