Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy data from one sheet to another
Here is my procedure. It quite doesn't work.
Public Sub CopyRecordsfromDatatoDatabase() Dim myArray(7) Dim myColumn As Integer, myRow As Single Dim i As Integer myRow = 2 i = 1 Do For myColumn = 6 To 26 Worksheets("data").Activate With ActiveSheet .Cells(myRow, 5) = myArray(1) .Cells(myRow, 3) = myArray(2) .Cells(myRow, 2) = myArray(3) .Cells(1, myColumn) = myArray(4) .Cells(myRow, myColumn) = myArray(5) .Cells(myRow + 1, myColumn) = myArray(6) .Cells(myRow + 2, myColumn) = myArray(7) End With Worksheets("Database").Activate With ActiveSheet i = i + 1 .Range(.Cells(i, 1), .Cells(i, 7)) = myArray End With Next myColumn myRow = myRow + 3 Worksheets("data").Activate Loop Until Cells(myRow, 1).Value < "" End Sub It cuts all the data from the first ("data") sheet which is okay except for one item I need to be copied repeatedly (Cells(1, myColumn)). It does not copy/write to the second sheet at all because the array is not being populated, but it does overwrite the appropriate cells on the second ("Database") sheet with nothing. Once I get the array to populate, I would need to empty or reset it after each loop, wouldn't I? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copy rows from one Data sheet to another sheet based on cell conte | Excel Discussion (Misc queries) | |||
Copy Data from Sheet 1 to Empty Cell in Sheet 2 | Excel Programming | |||
Auto copy cell data from source sheet to another wrkbook sheet | Excel Programming | |||
How can i copy data from a tabbed working sheet to a summary sheet | Excel Discussion (Misc queries) | |||
how to copy a cell with formula from sheet 1 (data is all vertical) into sheet 2 | Excel Worksheet Functions |