VBA run-time 1004 error

Kimberly1

New Member
Joined
Dec 8, 2006
Messages
3
I am a very novice VBA user.
I am making schedule worksheets for 3 different shifts. I want pages to name themselves based on data in a cell.
Using View Code on a page tab, I have this entered:

Private Sub Auto_Open()
ActiveSheet.Name = ActiveSheet.Range("IA2").Value
End Sub

When building, I tried saving this in Workbook in the Project-VBA Project window but it wouldn't run when I opened the notebook. Somehow I figured out how to save it as a module under that workbook. And it ran beautifully...every time.

Then I copied the Workbook for the other two shifts in the same folder. In the Project-VBA Project window, it showed the module under each project.

Then when I tried any of the workbooks, I got Run-Time Error "1004" Application-defined or object-defined error.

I have tried saving the formula in a page, in the workbook, taking it out and reentering it. No luck...same error.

Can anyone help?
Kimberly
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Kimberly

That code will run when the workbook opens.

When do you actually want it to run.

By the way using Auto_Open is only still available due to backward compatibility, it has been superseded by the workbook Open event.

As to the error, that could be because you don't have a valid name in IA2.
 
Upvote 0
Thanks for the info about Workbook open. I will try to make that change. But I don't think that is my problem here. There is a valid name in IA2 - no characters, just letters.
I would have prefered something that changes the sheet name as the value in IA2 changed, but could not figure out a way to do it except using the Auto_Open.
 
Upvote 0
Kimberley

When do you want this to happen?

The code you posted would only work on the active sheet.

And it will look at IA2 in the active sheet, and that might not be the sheet you want as far as VBA is concerned.
 
Upvote 0
What I want it to do...

Sorry for the delay. I was off sick. The code that I posted was the best that my limited abilities could put together. Saving and opening on a page that needed a name change was part of my instructions to the users and it isn't that big of a problem because page names won't change that often.

If you know something that does all pages at once, that would be great. I am open to suggestion.
 
Upvote 0

Forum statistics

Threads
1,215,694
Messages
6,126,250
Members
449,305
Latest member
Dalyb2

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