View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
MIguel MIguel is offline
external usenet poster
 
Posts: 33
Default VBA code does not copy and paste to next row for each zip code

Hi, I started to learn VBA in excel and I'm trying to do the following. I
want to copy and paste a table for each 3-digit zip code (006 to 300). In
other words, I want to copy and paste the table for the first zip code (006),
and then copy and paste the same table but using the next 3-digit zip code
(007) right below the previous zip code . My VBA code is below, but it's not
working right. It does copy and paste in the same place over and over for
each zip code instead of going down to the next row and do the same trick.
Here's what I'm trying to do:

006 120
006 140
: :
006 9974
007 120
007 140
: :
007 9974
008 120

and so on

My VBA code is shown below:

Dim i As Integer
For i = 6 To 300


ActiveCell.Range("a:a").Value = i
Range("B1").Select
Sheets("Sheet2").Select
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False


Next i

End Sub


I would appreciate any help.
Thanks