run-time error '1004'

New Contributor

any body can help

run-time error'1004'.JPG

 

Sub Customer()
'
' Customer Macro
'

'
    Range("D3:D8").Select
    Selection.Copy
    ActiveWindow.ScrollWorkbookTabs Sheets:=1
    Sheet10.Select
    Range("B2:B3").Select
    Selection.End(xlDown).Select
    Range("B4").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
    Range("B12").Select
    Sheet9.Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Range("D3").Select
End Sub
2 Replies

@AHMED_KARRAM 

It isn't really necessary to select ranges in a macro.

Sub Customer()
'
' Customer Macro
'

'
    Sheet9.Range("D3:D8").Copy
    Sheet10.Range("B4").End(xlDown).Offset(1, 0).PasteSpecial _
        Paste:=xlPasteValues, SkipBlanks:=False, Transpose:=True
    Sheet9.Range("D3:D8").ClearContents
End Sub

@AHMED_KARRAM 

 

Is there any data below B4? When you select B4 and hit Ctrl+Down Arrow, does it take you to the last row of the spreadsheet? If you've already selected the last physical row of the worksheet, then Offset(1,0).Select will fail with a 1004 error code.

Range("B4").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1").Select