PDA

View Full Version : copying cells



Lieke
10-22-2008, 01:04 AM
Hi,

Can anyone help me with the following problem?
I have my data in three columns, but now in need to copy data from 1 specific cell in the third column to 49 cells in the first column, but for a large number of cells:

I have to copy the contents of cell C1 to cells A2 through A51, then the contents of cell C52 to A53 through A102, the contents of cell C103 to A104 to A153, the contents of cell C154 to A155 through A204 and so on, until the end of sheet.

Can anyone figure out a way to do this with VBA?

Thanks,

Lieke.

sujittalukde
10-22-2008, 01:47 AM
I am not a very professional VBA programmer but I have tried some bit. Hope this will help you:


Sub CopyCellls()
LastCellInCol_C = Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
For i = 1 To LastCellInCol_C Step 51
Range("C" & i).Select
C_Row = ActiveCell.Row
Selection.Copy
Range("A" & C_Row + 1, "A" & C_Row + 50).Select
ActiveSheet.Paste
Next i
Application.CutCopyMode = False
End Sub

Bob Phillips
10-22-2008, 02:05 AM
Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For i = 1 To LastRow Step 51

.Cells(i + 1, "A").Resize(51).Value = .Cells(i, "C").Value
Next i
End With

End Sub

Lieke
10-22-2008, 02:15 AM
Thanks a lot, both of you. I'm using the code posted by xld, sujittalukde I got an error message while running yours. But thanks again for helping me out!