PDA

View Full Version : [SOLVED] Runtime error 1004



heroofgoodwi
12-15-2017, 03:41 AM
Been trying to debug this all afternoon and been having no luck although I suspect the answer is bemusing and simple. I keep encountering a runtime error '1004' at the line below. If anyone has a solution it would be greatly appreciate.


.Range(Cells(x, 5), Cells(x, 13)).PasteSpecial , x1PasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False



Sub FillSummaryData()

Dim x As Integer
Dim counter As Integer
Dim reportws As Worksheet
Dim summarydataws As Worksheet
'Dim NextRow As Integer


Set reportws = Sheets("Report") 'define report sheet
Set summarydataws = Sheets("SummaryData") 'define summary report data sheet

reportws.Select 'activate report ws
Cells(2, 2).Value = 1 'set control counter to zero
counter = 0 'set counter to 1
'DestFolder = SelectAFolder

For x = 1 To 52 '1 for each budget item
Application.ScreenUpdating = False 'turn off screen updating
counter = counter + 1
Cells(2, 2).Value = counter
Application.ScreenUpdating = True


reportws.Select
Range("P15:X15").Copy

x = x + 3
summarydataws.Select
With ActiveSheet
.Range(Cells(x, 5), Cells(x, 13)).PasteSpecial , x1PasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End With
x = x - 3





Next x
End Sub

mancubus
12-15-2017, 04:28 AM
change x1PasteValues to xlPasteValues

is it ok now?

mancubus
12-15-2017, 04:37 AM
below code should produce the desired output.



Sub vbax_61578_FillSummaryData()

Dim i As Long

With Worksheets("Report")
For i = 1 To 52
.Cells(2, 2).Value = i
.Calculate
Worksheets("SummaryData").Range(Cells(i + 3, 5), Cells(i + 3, 13)).Value = .Range("P15:X15").Value
'Worksheets("SummaryData").Range("E" & i + 3 & ":M" & i + 3).Value = .Range("P15:X15").Value 'same as above line
Next i
End With

End Sub

heroofgoodwi
12-15-2017, 04:51 AM
The code below works perfectly. Thank you mancubus



Sub vbax_61578_FillSummaryData()

Dim i As Long

With Worksheets("Report")
For i = 1 To 52
.Cells(2, 2).Value = i
.Calculate
'Worksheets("SummaryData").Range(Cells(i + 3, 5), Cells(i + 3, 13)).Value = .Range("P15:X15").Value
Worksheets("SummaryData").Range("E" & i + 3 & ":M" & i + 3).Value = .Range("P15:X15").Value 'same as above line
Next i
End With

End Sub

mancubus
12-15-2017, 07:57 AM
you are welcome.

pls mark the thread as solved for future references to the thread.