Help on error 1004

Closed
iworrell Posts 1 Registration date Monday March 13, 2017 Status Member Last seen March 13, 2017 - Updated by ac3mark on 13/03/17 at 04:38 PM
 Blocked Profile - Mar 13, 2017 at 04:39 PM
Excel Hello,

When I run the following code, I keep getting an error: Run-time error '1004': Application-defined or object-defined error.

This is occurring when the value of MyCell goes from having content, in my case a product code like AB-1234 to a value of ""

CODE:
Dim MyCell As Range, MyRange As Range

Set MyRange = Sheets("Summary").Range("A10")
Set MyRange = Range(MyRange, MyRange.End(xlDown))

For Each MyCell In MyRange
Sheets(9).Copy After:=Sheets(Sheets.Count) 'Create a new worksheet as a copy of Sheet number 9 in this example
Sheets(Sheets.Count).Name = MyCell.Value 'Renames the new worksheets
Next MyCell

Any ideas as to how to fix this?

Thanks!

Ian


Related:

1 response

Blocked Profile
Mar 13, 2017 at 04:39 PM
Well, you need to trap whether a cell has a value. I am certain you are trying to compare a NULL value!
1