VBA help finding a word then copy cell above

Solved/Closed
weenie - Sep 10, 2010 at 11:51 AM
 weenie - Sep 17, 2010 at 07:00 PM
Hello,
I don't know where to begin writing a macro for the following: I have 2007excel & In column A I have these numbers in parentheses and the word "vto". What I would like to do is look through entire column A and the numbers of rows can vary. To look for the word "vto" and once it finds it to copy the cell below it (it can also be cell below so it does not matter) then paste into the cell where "vto" is. Any help woud be great!! Thank you
Below is a sample of my column
A
(20/5.5)
(20/5.5)
(20/5.5)
(20/5.5)
(20/5.5
(20/1.0)
(20/1.0)
(20/1.0)
(20/1.0)
vto
(20/1.0)
(20/1.0)
(20/1.0)
(20/1
(20/1.0
(20/0.8)
(20/0.8)
(20/0.8)
(20/0.8)
vto
(20/0.8)
(20/0.8)
Thank you,
Irene
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Sep 14, 2010 at 09:29 AM
Hi Irene,

Try this code:
Sub test()
Set MyRng = Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp))
For Each cell In MyRng
    If cell.Value = "vto" Then
    cell.Value = cell.Offset(-1, 0).Value
        End If
    Next
End Sub

Let me know how this works for you.

Best regards,
Trowa
0
Thank you.
0