ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error (https://www.excelbanter.com/excel-discussion-misc-queries/111177-macro-create-new-worksheet-reference-cell-old-worksheet-tab-name-object-required-error.html)

[email protected]

Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error
 
Here is the code:

Dim A As String
A = Range("J3").Value
ActiveSheet.Select
ActiveSheet.Copy , Befo=Sheets(1)
ActiveSheet.Select
Active.Sheet.Name = A
Range("F5").Select

The value in J3 is 10-02 (formatted as text using =TEXT(F4, "MM-DD").
It runs fine until the line "Active.Sheet.Name = A" and then stops with
a 424 error "Object Required". Up to this point the new spreadsheet
has been created but the tab name is still a copy of the old one.
It is supposed to use the text in cell J3...

Lastly I would like the cell F5 in the new worksheet to be the current
date.


CLR

Macro to Create New Worksheet and Reference Cell in Old Worksheet
 
Try changing

Active.Sheet.Name = A
to
ActiveSheet.Name = A

Vaya con Dios,
Chuck, CABGx3


" wrote:

Here is the code:

Dim A As String
A = Range("J3").Value
ActiveSheet.Select
ActiveSheet.Copy , Befo=Sheets(1)
ActiveSheet.Select
Active.Sheet.Name = A
Range("F5").Select

The value in J3 is 10-02 (formatted as text using =TEXT(F4, "MM-DD").
It runs fine until the line "Active.Sheet.Name = A" and then stops with
a 424 error "Object Required". Up to this point the new spreadsheet
has been created but the tab name is still a copy of the old one.
It is supposed to use the text in cell J3...

Lastly I would like the cell F5 in the new worksheet to be the current
date.



CLR

Macro to Create New Worksheet and Reference Cell in Old Worksh
 
Sorry, didn't finish reading the whole post..........


Sub testme()
Dim A As String
A = Range("J3").Value
ActiveSheet.Select
ActiveSheet.Copy , Befo=Sheets(1)
ActiveSheet.Select
ActiveSheet.Name = A
Range("F5").Select
Range("f5").Value = Date
End Sub

This will set the date in F5 as current at the time the macro was run.

Vaya con Dios,
Chuck, CABGx3



"CLR" wrote:

Try changing

Active.Sheet.Name = A
to
ActiveSheet.Name = A

Vaya con Dios,
Chuck, CABGx3


" wrote:

Here is the code:

Dim A As String
A = Range("J3").Value
ActiveSheet.Select
ActiveSheet.Copy , Befo=Sheets(1)
ActiveSheet.Select
Active.Sheet.Name = A
Range("F5").Select

The value in J3 is 10-02 (formatted as text using =TEXT(F4, "MM-DD").
It runs fine until the line "Active.Sheet.Name = A" and then stops with
a 424 error "Object Required". Up to this point the new spreadsheet
has been created but the tab name is still a copy of the old one.
It is supposed to use the text in cell J3...

Lastly I would like the cell F5 in the new worksheet to be the current
date.



[email protected]

Macro to Create New Worksheet and Reference Cell in Old Worksh
 
Thanks Chuck! Working smooth as silk now....


CLR

Macro to Create New Worksheet and Reference Cell in Old Worksh
 
Happy to help........thanks for the feedback.

Vaya con Dios,
Chuck, CABGx3




" wrote:

Thanks Chuck! Working smooth as silk now....




All times are GMT +1. The time now is 04:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com