VBA error

G

Guest

I get an error, "Run-time error '1004': Application-defined or object-defined
error" when I run the following macro:

Sub Sheet_Names()
Dim ws As Worksheet
With Worksheets.Add
.Name = "Sheet Names"
.Move before:=Worksheets(1)
End With
Sheets("Sheet Names").Activate
Range("a1").Activate
For Each ws In Worksheets
If ws.Name <> "Sheet Names" Then
ActiveCell.Formula = ws.Name
ActiveCell.Offset(1, 0).Select
End If
Next
End Sub

What does this error mean and how can I resolve it? The macro is supposed
to create a list of tab names in the workbook.

Thanks,

Dave
 
G

Guest

this is a problem which occassionally shows up when you copy sheets often
without saving the workbook
try saving thew workbook and try running the macro again. It works fine for
me 2003
 
G

Guest

Thanks. So, basic question: how do you know when a block of code should be
contained in its own module?

Dave
--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


Ron de Bruin said:
Hi dave

Copy the macro in a normal module and not in a sheet module
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top