Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Cycling through one column in a range

Hello,
I have a range that spans several rows and columns. I'm trying to
cycle through the first column in the range so that I can, eventually,
compare it to a value. However, I keep getting a "Type Mismatch" error
in the cycling process. Here's what I have

==========================================
Dim rng1 as range, rng as range, cl as range

Set rng1 = ThisWorkbook.Names("namedrange").RefersToRange
Set rng = rng1.Columns(1)

For Each cl In rng
Debug.Print cl.Value +++++++++ this is where I get the type mismatch
Next cl

===========================================

When I add a watch to rng and expand it, the values that I expect to be
there are there. However, when I add a watch to cl, it appears to just
be a mirror of rng. What would I need to do in order for cl to be one
cell in rng, instead of the entire rng?

Right now, rng1 is 3 columns wide and about 400 rows deep. Any advice
on how I can use the above, or if there is another way I can go about
cycling through the first column of the range?

Thanks to all for the help.

Mike

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Cycling through one column in a range

Mike,
Set rng = rng1.Columns(1).Cells
Jim Cone
San Francisco, USA


----- Original Message -----
From:
Newsgroups: microsoft.public.excel.programming
Sent: Wednesday, December 21, 2005 8:50 AM
Subject: Cycling through one column in a range


Hello,
I have a range that spans several rows and columns. I'm trying to
cycle through the first column in the range so that I can, eventually,
compare it to a value. However, I keep getting a "Type Mismatch" error
in the cycling process. Here's what I have
==========================================
Dim rng1 as range, rng as range, cl as range
Set rng1 = ThisWorkbook.Names("namedrange").RefersToRange
Set rng = rng1.Columns(1)
For Each cl In rng
Debug.Print cl.Value +++++++++ this is where I get the type mismatch
Next cl
===========================================
When I add a watch to rng and expand it, the values that I expect to be
there are there. However, when I add a watch to cl, it appears to just
be a mirror of rng. What would I need to do in order for cl to be one
cell in rng, instead of the entire rng?
Right now, rng1 is 3 columns wide and about 400 rows deep. Any advice
on how I can use the above, or if there is another way I can go about
cycling through the first column of the range?
Thanks to all for the help.
Mike
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
Tab keeps cycling through the same row Mike Excel Discussion (Misc queries) 2 August 14th 08 12:20 AM
cycling through columns? Kirk Excel Programming 2 May 2nd 05 07:51 PM
Cycling through variables. Azza Excel Programming 1 October 14th 04 10:23 PM
Cycling through the cells in a range Wandering mage Excel Programming 4 June 16th 04 08:00 PM
Cycling through worksheets Chris Gorham[_3_] Excel Programming 2 November 5th 03 08:37 PM


All times are GMT +1. The time now is 12:40 PM.

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"