View Full Version : Copying from one spreadsheet to another


Kurdt
09-27-2007, 03:22 PM
I'm creating an Access database that takes a large Excel spreadsheet and breaks it up in to many spreadsheets based on the values in one of the columns. When I cut and paste from the master into one of the smaller versions I end up with JPGs pasted instead of the data. Note that my code is in Access, but the source and destination of the data are in Excel. This is my first post, so it could be the wrong forum for this. Here is the relevant code:

xlMonthlyMaster.Worksheets("InitialAssessments").Range("A" & intRowStart & ":X" & intRowEnd).Copy
xlClientReport.Worksheets("InitialAssessments").Cells(intPasteRow, "A").PasteSpecial (xlPasteValues)

Any help is appreciated.

Thank you,

Curtis

HaHoBe
10-12-2007, 10:05 PM
Hi, Curtis,

maybe use an automation based on

Sub CopyCurtis()
Dim wks As Worksheet
Dim iRow As Integer
Dim iStart As Integer

Application.ScreenUpdating = False
Set wks = ActiveSheet
iRow = 2
iStart = iRow
Do Until IsEmpty(wks.Cells(iRow, 1))
If wks.Cells(iRow, 1) <> wks.Cells(iRow + 1, 1) Then
Worksheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = wks.Cells(iRow, 1)
wks.Rows(iStart & ":" & iRow).Copy Range("A1")
iStart = iRow + 1
End If
iRow = iRow + 1
Loop
Worksheets(1).Select
Set wks = Nothing
Application.ScreenUpdating = True
End Sub
I really wouldn´t use the Paste&Copy but instead prefer to get the values directly form one sheet to another by just copying the values (using Resize for the ranges).

Ciao,
Holger