Help on error 1004

[Closed]
Report
Posts
1
Registration date
Monday March 13, 2017
Status
Member
Last seen
March 13, 2017
-
 Blocked Profile -
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


1 reply


Well, you need to trap whether a cell has a value. I am certain you are trying to compare a NULL value!
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month