Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Newbie question about iteration technique?


Given a fixed range, say A1:AD120.

The range is sorted by the contents of column "L" (which happens to get its
value by linking to a named range in other workbooks if that's important).
Column "L" can only hold one of three possible values, say "A", "B", and
"C".


The problem at hand is to write code that will return the row number that
contains the first instance of each value. There is not necessarily a value
"A".

Being a VBA novice, can someone please show me the most efficient way I
might do this? Do I have to iterate over each row?

TIA





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Newbie question about iteration technique?

Dim res as Variant
res = Application.Match("A",Range("L1:L120"),0)
if not iserror(res) then
rwA = res
end if
res = Applicaton.match("B",Range("L1:L120"),0)
if not iserror(res) then
rwB = res
end if
res = Application.match("C",Range("L1:L120"),0)
if not iserror(res) then
rwC = res
End if

Regards,
Tom Ogilvy

"Karl Thompson" wrote in message
...

Given a fixed range, say A1:AD120.

The range is sorted by the contents of column "L" (which happens to get

its
value by linking to a named range in other workbooks if that's important).
Column "L" can only hold one of three possible values, say "A", "B", and
"C".


The problem at hand is to write code that will return the row number that
contains the first instance of each value. There is not necessarily a

value
"A".

Being a VBA novice, can someone please show me the most efficient way I
might do this? Do I have to iterate over each row?

TIA







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Newbie question about iteration technique?

Thank you.


"Tom Ogilvy" wrote in message
...
Dim res as Variant
res = Application.Match("A",Range("L1:L120"),0)
if not iserror(res) then
rwA = res
end if
res = Applicaton.match("B",Range("L1:L120"),0)
if not iserror(res) then
rwB = res
end if
res = Application.match("C",Range("L1:L120"),0)
if not iserror(res) then
rwC = res
End if

Regards,
Tom Ogilvy

"Karl Thompson" wrote in message
...

Given a fixed range, say A1:AD120.

The range is sorted by the contents of column "L" (which happens to get

its
value by linking to a named range in other workbooks if that's

important).
Column "L" can only hold one of three possible values, say "A", "B", and
"C".


The problem at hand is to write code that will return the row number

that
contains the first instance of each value. There is not necessarily a

value
"A".

Being a VBA novice, can someone please show me the most efficient way I
might do this? Do I have to iterate over each row?

TIA









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
Newbie question wayne New Users to Excel 6 June 27th 08 02:23 PM
Newbie Question Terri[_2_] New Users to Excel 8 February 23rd 08 12:21 AM
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Newbie question: Berra Charts and Charting in Excel 2 December 11th 06 10:00 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM


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