Wednesday, 2 October 2013

Finding any text in a column, then searching above/beneath it then adding a result in another cell

Finding any text in a column, then searching above/beneath it then adding
a result in another cell

Ive had help with this code yesterday and have added another part to it.
Here is the code
Sub findtext()
Dim findtext As Range
For Each findtext In Range(ActiveSheet.Range("C3"),
ActiveSheet.Range("C250").End(xlUp)).Cells
If Len(findtext) > 0 Then findtext.Offset(0, 1) = findtext.Offset(-2, 7)
If Len(findtext) > 0 Then findtext.Offset(0, 2) = findtext.Offset(0,
1) + findtext.Offset(0, 0)
Next findtext
End Sub
This is working great.
My data is in lots of 2 (ie C10 has some data, then so does C11, then
nothing till C25 / C26 etc. I want to put the A in E10 and B in E11 - Then
A in E25 and B in E26
I think I need to find the text in Col C then see if there is text above
it, if there is then that would put the B in E11/E26 etc, and if cell
above text is empty but there is text in the cell below then we add the A
Hope this makes sense otherwise ill try explaining again
Thanks!
Something like this, but this is doing that on every check, so its not
working obvoiusly
If Len(findtext) > 0 Then findtext.Offset(0, 2) = "A"
If Len(findtext) > 0 Then findtext.Offset(1, 2) = "B"
Here is a link for my file:
http://www.megafileupload.com/en/file/456565/example1-xlsm.html
I have also included more notes inside the macro of what I need done

No comments:

Post a Comment