matching values and inputing value in the adjacent cell
- From: bundyloco <bundyloco.1say2a_1121583916.1391@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 17 Jul 2005 01:50:17 -0500
Hi,
I posted a question about this last week, but had to remove it because
I accidently included some information that I did not want out on the
web. Here is my code.
I am trying to loop through a colum and look for certain criteria. If
the cell meets the criteria, it inserts a value to the adjent cell in
the next column. However, not all the cells in column a have are filled
in fact, a lot of them are empty, but I want the program to loop through
until the end of the column. Can I just make this an OR statement that
also include a column that always has data so when both are empty
together, I know it is at the end of the range?
When I run the code, it gives me an error for the "i" in the Next i
statement. It also gives me a type mismatch error in the if rows. I can
get this error to stop if I get rid of the OR statement so I'm thinking
that is the problem even though it doesn't make sense to me.
Dim a As String
Dim cntr As Integer
'loop through cells to find product and input the corresonding route
one
'cell to the right
For cntr = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If a = "Product A-1" Or "Product A-2" Then
ActiveCell.Offset(0, 1).Value = "123.6ABC"
ElseIf a = " Product B-0" Or "Product B-1" Then
ActiveCell.Offset(0, 1).Value = "456.6CDE"
ElseIf a = "Product C-1" Then
ActiveCell.Offset(0, 1).Value = "789.1A2BC"
Else
cntr = cntr + 1
End If
Next i
--
bundyloco
------------------------------------------------------------------------
bundyloco's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=23386
View this thread: http://www.excelforum.com/showthread.php?threadid=387816
.
- Follow-Ups:
- Prev by Date: Re: Paste text into a header
- Next by Date: Copy folder and paste to another folder
- Previous by thread: How can I add values in 2 cells using a command button
- Next by thread: Re: matching values and inputing value in the adjacent cell
- Index(es):