Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default traversing through a filtered range based on another filtered range

i have two filtered ranges that i'm going through that are in the sam
worksheet. they are just different columns in the worksheet. i'm tryin
to put this into code

if a value is found in filteredrange1 then goto the same row i
filteredrange2 and copy its value

right now i can go through filteredrange1 a row at a time, but i wan
to go through both filteredranges the same row at the same time

this is the code that i'm using so far, which does not work because th
if the rows in filteredrange2 aren't together testvar will be som
hidden data that shouldn't be used
-----------------------------------
dim filteredrange1 as range
dim filteredrange2 as range
dim counter as integer
dim testvar as string

counter =0

'Traverse range and get value
For Each rng In filteredrange1
If rng = "Value" Then

testvar = filteredrange2(counter)

counter = counter + 1

msgbox testvar

Next rng
-------------------------------------

please help.

Thanks in advanc

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default traversing through a filtered range based on another filtered range

just refer to the the cell relative to the cell in the filterrange1

For Each rng In filteredrange1
If rng = "Value" Then

testvar = rng.offset(0,10)
msgbox testvar
End if
Next

change the 10 to reflect the offset from the filteredrange1 column.

--
Regards,
Tom Ogilvy


"zestpt " wrote in message
...
i have two filtered ranges that i'm going through that are in the same
worksheet. they are just different columns in the worksheet. i'm trying
to put this into code

if a value is found in filteredrange1 then goto the same row in
filteredrange2 and copy its value

right now i can go through filteredrange1 a row at a time, but i want
to go through both filteredranges the same row at the same time

this is the code that i'm using so far, which does not work because the
if the rows in filteredrange2 aren't together testvar will be some
hidden data that shouldn't be used
-----------------------------------
dim filteredrange1 as range
dim filteredrange2 as range
dim counter as integer
dim testvar as string

counter =0

'Traverse range and get value
For Each rng In filteredrange1
If rng = "Value" Then

testvar = filteredrange2(counter)

counter = counter + 1

msgbox testvar

Next rng
-------------------------------------

please help.

Thanks in advance


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default traversing through a filtered range based on another filtered range

thats so simple i wish i had through of it. what would i do if the tw
ranges weren't on the same worksheet or workbook even

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default traversing through a filtered range based on another filtered range

testvar =
Workbooks("Book2.xls").Worksheets("Sheet2").Cells( rng.row,"C").Value

to get a value from column C of sheet2 of Book2.xls for the same row.

--
Regards,
Tom Ogilvy

"zestpt " wrote in message
...
thats so simple i wish i had through of it. what would i do if the two
ranges weren't on the same worksheet or workbook even?


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default traversing through a filtered range based on another filtered range

thanks tom, one thing though. what if the rows don't match but the tw
filtered ranges have the same numbre of rows. how can i travers
through both of them at the same time to and compare values withou
using a counter for one of them

--
Message posted from http://www.ExcelForum.com

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
traversing a filtered range (excel 2007) parahumanoid Charts and Charting in Excel 3 November 2nd 09 08:11 PM
Sum a filtered range Peter Excel Discussion (Misc queries) 2 April 30th 09 07:57 AM
Return filtered values into report worksheet based on filtered valueon the data worksheet dicko1 Excel Worksheet Functions 1 April 21st 09 12:27 AM
How to copy a filtered range ? gaftalik Excel Discussion (Misc queries) 2 November 25th 05 04:56 PM
filtered range MarkJ Excel Programming 7 June 26th 04 10:49 PM


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