I want the code to check every cell in in the range “A3:AAA3” for a specific text. If the cell contains that text, I want it to copy the text in the cell on the right, to two rows above (see below for illustration):
The copied text will be a date.
I have already got a piece of code which identifies every column with this text and sets the column width:
Dim c as Range
For Each c In Range("A3:AAA3").Cells
If c.Value = "TEXT" Then
c.EntireColumn.ColumnWidth = 4
End If
Next c
I can use copy and paste if the cell is already selected:
Dim s As Range
Set s = Selection.Cells(1)
s.Offset(0, 1).Copy
s.Offset(-2, 0).PasteSpecial xlPasteAll
And I feel like I should be able to combine the two into something like the below so that it selects the cell with the text, and copies and pastes the cell next to it, and then loops onto the next one (something like below?), but all my attempts aren’t working – it’s not coming up with an error message, just not doing anything.
Dim c As Range
For Each c In Range("A3:AAA3").Cells
If c.Value = "TEXT" Then
c.Select
c.Offset(0, 1).Copy
c.Offset(-2, 0).PasteSpecial xlPasteAll
End If
Next c
Thoughts? I’m sure it’s a very simple solution but I’m a bit stuck.