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

I need some advice and help to solve this problem. There have to be several
ways, however, I just can't seem to get anything to work.

Here is what I have in a worksheet:

A B C D
1
2
3
4 txt1
5 txt2
6 txt3

Cells B4:B6 are in range MyRange

What I am trying to do is compare TestText to values in MyRange. When the
values match, ( i.e. TestText = txt2) I want to write a second
variable,Result, in the same row as the match (5 in this case) and in
column D. This is the core of a comparison test to fill in the column D
blanks based on a list of TestText values.

I tried this:

For each cell in Range("MyRange")
If TestText = Range.Cells.Value Then
Worksheets("MyWorkSheet").Cells( Range.Cells.Row.Value,4) =
Result
Endif
Next

I am thinking that Range.Cells.Row.Value should equal 5 for the example.

I can't get this to work so obviously I do not understand. How can this be
corrected or rewritten to meet my needs?

Thanks in advance for your help, and Merry Christmas.

Ray


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Best Way Question

Ray,

Assuming txt1, etc., are in column A, then this should work. (I changed the
range name to "cel" to avoid confusion with the reserved word "Cells":

For each cel in Range("MyRange")
If TestText = cel.Value Then
cel.offset(0,3) = Result
Endif
Next

hth,

Doug


"Ray Batig" wrote in message
nk.net...
I need some advice and help to solve this problem. There have to be

several
ways, however, I just can't seem to get anything to work.

Here is what I have in a worksheet:

A B C D
1
2
3
4 txt1
5 txt2
6 txt3

Cells B4:B6 are in range MyRange

What I am trying to do is compare TestText to values in MyRange. When

the
values match, ( i.e. TestText = txt2) I want to write a second
variable,Result, in the same row as the match (5 in this case) and in
column D. This is the core of a comparison test to fill in the column D
blanks based on a list of TestText values.

I tried this:

For each cell in Range("MyRange")
If TestText = Range.Cells.Value Then
Worksheets("MyWorkSheet").Cells( Range.Cells.Row.Value,4) =
Result
Endif
Next

I am thinking that Range.Cells.Row.Value should equal 5 for the example.

I can't get this to work so obviously I do not understand. How can this

be
corrected or rewritten to meet my needs?

Thanks in advance for your help, and Merry Christmas.

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
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
where can I see my question and answer? Yesterday I ask a question IP Excel Discussion (Misc queries) 2 May 10th 08 04:08 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM
Question Philip Excel Discussion (Misc queries) 1 May 6th 05 09:24 AM


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