PDA

View Full Version : Solved: Search through range and fill corresponding offset?



sleepy_think
05-09-2008, 07:04 AM
Hi all new to the forums, and I need your help!


I need a code that does the following:

cycle through a range (m3:m50)

check the cells for a specific data

if it is in the cell then populate another range (e3:e50) (the corresponding cell only) with a specific line of text.

Please help!

Simon Lloyd
05-09-2008, 07:17 AM
How about this:

Sub Fill_Offset()
Dim Rng As Range, MyCell As Range
Set Rng = Range("M3:M50")
For Each MyCell In Rng
If MyCell.Value = "Fred" Then
MyCell.Offset(0, -8).Value = "Entry Found"
End If
Next MyCell
End Sub

sleepy_think
05-09-2008, 07:45 AM
i understand till the "fred" part but how can this stick "entry found" in the corresponding cell in range E?

lets look at it like this:

range E is blank

range M has the data

when Fred is located in M then the program populates the same row in E with whatever text I want (embedded in the program)

dont i need something to cycle through the E range as the M range then output too it?

thanks for your help BTW

Simon Lloyd
05-09-2008, 07:55 AM
Did you run the code in a test workbook? i think not! try it and your questions will be answered.

sleepy_think
05-09-2008, 07:56 AM
NM you were right I am still a newb lol thx!

Simon Lloyd
05-09-2008, 07:58 AM
Your welcome!, if your question has been solved please mark it solved using thread tools at the top of this window!

sleepy_think
05-09-2008, 08:02 AM
one more question, now how would the else if statement work...

if M doesnt equal fred, then check if it equal to bob if it is equal to bob type entry found2

thanks

Simon Lloyd
05-09-2008, 08:05 AM
I could do that for you but just try a little research on Case Select this is better than IF,ElseIf,Else,Then

sleepy_think
05-09-2008, 08:07 AM
thanks