0

I need to write a macro that for example, would copy the value from column A where the condition of cheese was met, and then pasted this value into the adjacent cell in the next column. Where would you start with this?

enter image description here

Community
  • 1
  • 1
80gm2
  • 202
  • 5
  • 15

1 Answers1

2

Without a macro:

In B2 enter:

=IF(A2="CHEESE",A2,"")

and copy down

With a macro:

Sub Cheesey()
    For Each r In Intersect(ActiveSheet.UsedRange, Range("A:A"))
        If r.Text = "CHEESE" Then
            r.Offset(0, 1) = "CHEESE"
        End If
    Next r
End Sub
Gary's Student
  • 95,722
  • 10
  • 59
  • 99
  • Use caution with UsedRange http://stackoverflow.com/questions/11886284/usedrange-count-counting-wrong – ApplePie Jan 13 '15 at 18:03