Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Range Question

Greetings,

This should be simple, however I can't seem to find a simple way to
accomplish this task. All my attempts have ended up in a lot of code. Simply
stated, I have a data table which has variable number of columns. The top
row of cells is a named range e.g TopRow with entries in every cell. The top
row always starts in F7. The table rows extend down 28 rows. There are many
cells in the table which don't have entries.

What I would like to do is create a new range e.g. TableRange which
describes the entire table including TopRow down 28 rows. Then I can work on
the TableRange. My attempts have basically ended up counting each cell left
to right and then down which seems clumsy. I can tell you that the bottom
row cannot be guaranteed to have values in any cell. I was trying a number
of combinations of resize and offset,however I was unable to make them work.

What ideas can you suggest?

Thank you in advance for your help!

Ray


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Range Question

On Sat, 31 Jan 2004 03:07:22 GMT, "Ray Batig"
wrote:

Greetings,

This should be simple, however I can't seem to find a simple way to
accomplish this task. All my attempts have ended up in a lot of code. Simply
stated, I have a data table which has variable number of columns. The top
row of cells is a named range e.g TopRow with entries in every cell. The top
row always starts in F7. The table rows extend down 28 rows. There are many
cells in the table which don't have entries.


What I would like to do is create a new range e.g. TableRange which
describes the entire table including TopRow down 28 rows. Then I can work on
the TableRange.


Do I understand you correctly; the range name TopRow contains only the
columns that you want to add to the new range?

If so, this is one way (Change Sheet2 to wherever the range actually
appears):

Sub CreateTableRange()

Dim l_TopRowStart As Long
Dim l_TopRowCount As Long

l_TopRowStart = Range("TopRow").Column

l_TopRowCount = Range("TopRow").Columns.Count

ActiveWorkbook.Names.Add Name:="TableRange", _
RefersToR1C1:= _
"=Sheet2!R7C" & CStr(l_TopRowStart) _
& ":R34C" _
& CStr(l_TopRowStart + l_TopRowCount - 1)

End Sub


---------------------------------------------------------
Hank Scorpio
scorpionet who hates spam is at iprimus.com.au (You know what to do.)
* Please keep all replies in this Newsgroup. Thanks! *
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Range Question

The first one got away from me.

Range("TopRow").Resize(28).Name = "TableRange"

Demo'd from the immediate window:

Range("F7").Resize(1,20).Name = "TopRow"
? range("TopRow").Address
$F$7:$Y$7
Range("TopRow").Resize(28).Name = "TableRange"
? Range("TableRange").Address
$F$7:$Y$34

--
Regards,
Tom Ogilvy

Ray Batig wrote in message
nk.net...
Greetings,

This should be simple, however I can't seem to find a simple way to
accomplish this task. All my attempts have ended up in a lot of code.

Simply
stated, I have a data table which has variable number of columns. The top
row of cells is a named range e.g TopRow with entries in every cell. The

top
row always starts in F7. The table rows extend down 28 rows. There are

many
cells in the table which don't have entries.

What I would like to do is create a new range e.g. TableRange which
describes the entire table including TopRow down 28 rows. Then I can work

on
the TableRange. My attempts have basically ended up counting each cell

left
to right and then down which seems clumsy. I can tell you that the bottom
row cannot be guaranteed to have values in any cell. I was trying a

number
of combinations of resize and offset,however I was unable to make them

work.

What ideas can you suggest?

Thank you in advance for your help!

Ray




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Range Question

Thank You Tom,

You make it sooooo simple.

Ray
Tom Ogilvy wrote in message
...
The first one got away from me.

Range("TopRow").Resize(28).Name = "TableRange"

Demo'd from the immediate window:

Range("F7").Resize(1,20).Name = "TopRow"
? range("TopRow").Address
$F$7:$Y$7
Range("TopRow").Resize(28).Name = "TableRange"
? Range("TableRange").Address
$F$7:$Y$34

--
Regards,
Tom Ogilvy

Ray Batig wrote in message
nk.net...
Greetings,

This should be simple, however I can't seem to find a simple way to
accomplish this task. All my attempts have ended up in a lot of code.

Simply
stated, I have a data table which has variable number of columns. The

top
row of cells is a named range e.g TopRow with entries in every cell. The

top
row always starts in F7. The table rows extend down 28 rows. There are

many
cells in the table which don't have entries.

What I would like to do is create a new range e.g. TableRange which
describes the entire table including TopRow down 28 rows. Then I can

work
on
the TableRange. My attempts have basically ended up counting each cell

left
to right and then down which seems clumsy. I can tell you that the

bottom
row cannot be guaranteed to have values in any cell. I was trying a

number
of combinations of resize and offset,however I was unable to make them

work.

What ideas can you suggest?

Thank you in advance for your help!

Ray






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Range Question

Range("TopRow").Resize(28).Name = "TableRange"


demo from the immediate window:


Ray Batig wrote in message
nk.net...
Greetings,

This should be simple, however I can't seem to find a simple way to
accomplish this task. All my attempts have ended up in a lot of code.

Simply
stated, I have a data table which has variable number of columns. The top
row of cells is a named range e.g TopRow with entries in every cell. The

top
row always starts in F7. The table rows extend down 28 rows. There are

many
cells in the table which don't have entries.

What I would like to do is create a new range e.g. TableRange which
describes the entire table including TopRow down 28 rows. Then I can work

on
the TableRange. My attempts have basically ended up counting each cell

left
to right and then down which seems clumsy. I can tell you that the bottom
row cannot be guaranteed to have values in any cell. I was trying a

number
of combinations of resize and offset,however I was unable to make them

work.

What ideas can you suggest?

Thank you in advance for your help!

Ray






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
Range Question Peter[_8_] Excel Discussion (Misc queries) 3 December 11th 07 02:37 AM
Range Question N.F[_2_] Excel Discussion (Misc queries) 5 July 28th 07 01:05 AM
Range question in '97 Adam Kroger Excel Discussion (Misc queries) 10 December 12th 05 03:44 AM
If Range.Name question Otto Moehrbach[_5_] Excel Programming 8 November 30th 03 11:05 PM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


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