I am copying a a range of cells and pasting them depending on a value in a range. For example If a cell contained a "R" then My code would move up one cell and one to the right and copy as far as the end of range. (be5)
It would then paste to cells to the right of where "R" value is.
I can do this by using:
For Each Cell In Range("f5:be5"
If Cell.Value = "R" Then
Range(Cell.Offset(-1, 1), Cells(4, "BE"
).Copy Destination:=Cell.Offset(0, 1)
End If
Next
My problem is that there may be more than one "R" in the range I am checking. Using the above code it only finds the first "R" and then pastes over the rest. I want it to choice the last "R" and then Copy and Paste from there onwards. This is what I've tried for this problem.
Dim str As String
For Each Cell In Range("f5:be5"
If Cell.Value = "R" Then
str = Cell.AddressLocal
Range(str.Value.Offset(-1, 1), Cells(4, "BE"
).Copy
_ Destination:=str.Value.Offset(0, 1)
End If
Next
My problem here is Where and How to use the str. It doesn't work as is.
Any sugestions??
Thanks for reading
S.
It would then paste to cells to the right of where "R" value is.
I can do this by using:
For Each Cell In Range("f5:be5"
If Cell.Value = "R" Then
Range(Cell.Offset(-1, 1), Cells(4, "BE"
End If
Next
My problem is that there may be more than one "R" in the range I am checking. Using the above code it only finds the first "R" and then pastes over the rest. I want it to choice the last "R" and then Copy and Paste from there onwards. This is what I've tried for this problem.
Dim str As String
For Each Cell In Range("f5:be5"
If Cell.Value = "R" Then
str = Cell.AddressLocal
Range(str.Value.Offset(-1, 1), Cells(4, "BE"
_ Destination:=str.Value.Offset(0, 1)
End If
Next
My problem here is Where and How to use the str. It doesn't work as is.
Any sugestions??
Thanks for reading
S.