Copy range from one sheet to another, error 1004

sh1ne

New Member
Joined
Jul 3, 2017
Messages
33
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I'm wondering how to fix that, tried many things to declare ranges within sheets but still getting 438/1004 error and can't deal with that.

Sub createLabel()

Dim ws As Worksheet
Dim wsLabel As Worksheet
Dim lastCol As Integer
Dim i As Integer
Dim k As Integer
Dim j As Integer
Dim cell As Range


lastCol = ActiveWorkbook.Worksheets("Cheatsheet").Cells(1, Columns.Count).End(xlToLeft).Column


With ThisWorkbook
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Label"
End With


i = 1
j = i + 2


Worksheets("Label").Activate
Set wsLabel = Sheets("Label")
Worksheets("Cheatsheet").Activate
Set ws = Sheets("Cheatsheet")




For k = 8 To lastCol
Set cell = Worksheets("Cheatsheet").Range(Worksheets("Cheatsheet").Cells(3, k), Cells(3, k))
If InStr(cell.Value, "Part") > 0 Then
Worksheets("Cheatsheet").Range(Worksheets("Cheatsheet").Cells(3, k), Cells(5, k)).Copy
Range(Worksheets("Label").Cells(i, 1), Cells(j, 1)).Paste
i = i + 4
Else
End If
Next k


End Sub

I'm getting error at Paste line
There is last-saved code, I tried many of things just like using "With worksheet" method. Usually I'm trying to deal with problems solo but I know that you're always come with right help and I need that.

Thanks a lot
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this (untested)

Code:
If InStr(cell.Value, "Part") > 0 Then
    Sheets("Cheatsheet").Range(Cells(3, k), Cells(5, k)).Copy Sheets("Label").Cells(i, 1)
    i = i + 4
End If
 
Upvote 0
Try this (untested)

Code:
If InStr(cell.Value, "Part") > 0 Then
    Sheets("Cheatsheet").Range(Cells(3, k), Cells(5, k)).Copy Sheets("Label").Cells(i, 1)
    i = i + 4
End If
Thanks a lot, it's working! : )
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top