Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to step through top row of a Range object

Excel 2000
Windows 2k Pro

Suppose I have a Range variable MyRange, and it is set to a table on Sheet1.

Dim MyRange As Range, cell As Range
Dim a As Integer

Set MyRange = Range("A1").CurrentRegion

Now I want to step through the headers for this range, and the headers are
all in row 1. How would I do this? I tried:

a = 0
For Each cell in MyRange.Rows(1)
a = a + 1
[more code]
Next cell

I'm know that the "MyRange.Rows(1)" part of the For-Next loop is wrong - how
should it be? Any help appreciated.

-gk-


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to step through top row of a Range object

One way

Set myrange = Range("A1").CurrentRegion
For Hcell = 1 To myrange.Columns.Count
MsgBox Cells(1, Hcell)
Next


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"TBA" wrote in message ...
Excel 2000
Windows 2k Pro

Suppose I have a Range variable MyRange, and it is set to a table on Sheet1.

Dim MyRange As Range, cell As Range
Dim a As Integer

Set MyRange = Range("A1").CurrentRegion

Now I want to step through the headers for this range, and the headers are
all in row 1. How would I do this? I tried:

a = 0
For Each cell in MyRange.Rows(1)
a = a + 1
[more code]
Next cell

I'm know that the "MyRange.Rows(1)" part of the For-Next loop is wrong - how
should it be? Any help appreciated.

-gk-




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How to step through top row of a Range object

Another way:

Option Explicit
Sub testme01()

Dim a As Long
Dim cell As Range
Dim myRange As Range

Set myRange = Range("a1").CurrentRegion

a = 0
For Each cell In myRange.Rows(1).Cells
MsgBox cell.Address
a = a + 1
'[more code]
Next cell

End Sub


TBA wrote:

Excel 2000
Windows 2k Pro

Suppose I have a Range variable MyRange, and it is set to a table on Sheet1.

Dim MyRange As Range, cell As Range
Dim a As Integer

Set MyRange = Range("A1").CurrentRegion

Now I want to step through the headers for this range, and the headers are
all in row 1. How would I do this? I tried:

a = 0
For Each cell in MyRange.Rows(1)
a = a + 1
[more code]
Next cell

I'm know that the "MyRange.Rows(1)" part of the For-Next loop is wrong - how
should it be? Any help appreciated.

-gk-


--

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
Creating a Drop Down List with Step by Step Instructions for 2007 remarkable Excel Worksheet Functions 2 March 22nd 09 04:36 AM
Dynamic Step Chart using range names Michel Gerday Charts and Charting in Excel 6 March 1st 06 12:50 AM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Alan Beban[_3_] Excel Programming 0 August 1st 03 01:24 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


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