Consulting

Results 1 to 4 of 4

Thread: copying cells

  1. #1
    VBAX Newbie
    Joined
    Aug 2008
    Posts
    4
    Location

    copying cells

    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.

  2. #2
    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

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Newbie
    Joined
    Aug 2008
    Posts
    4
    Location
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •