Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Cesar Gonzalez   on Jan 31 In MS Office Category.

  
Question Answered By: Helga Miller   on Jan 31

I'm assuming that you mean the data  you want copied  is actually in Column A
and not B as stated....(and if that's not the case you can easily adapt the
code). Hopefully this code will help  you out.

***************
Public Sub newbie()
Dim year As Integer
Dim row As Integer

row = 2 'start at row 2 (that's assuming column titles are in row 1)

For Each cell  In Range("b2:b30") 'make range  larger if spreadsheet  is
larger
If cell.Value2 = 2001 Then
Range("a" & row).Copy
Range("c" & row).PasteSpecial xlPasteValues
End If

If cell.Value2 = 2002 Then
Range("a" & row).Copy
Range("d" & row).PasteSpecial xlPasteValues
End If
row = row + 1 'move to the next row
Next cell 'check the next row's year

End Sub

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 


Tagged: