Renaming Worksheets Using Reference

edhead4

New Member
Joined
Feb 25, 2005
Messages
4
I know there are a few posts on this but from the one's I've seen, this is unique...

I have a database that I'm running reports from. I am trying to create a macro that will create a new sheet and name it based on a new value in the new sheet. Here's what it will do:

1. Copy data from current sheet
2. Create a new sheet and paste the data into it
3. change the cell linking the sheet to my master database so that the new sheet shows the new values
4. Rename the new sheet based onthe new value in the linking cell.

I'm okay until the renaming part. I can't get the macro to link to the newly created sheet in order to pick the right value. My macro is in shambles right now, otherwise I would paste it. Any help is greatly appreciated!

thanx!
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Private Sub Worksheet_Change(ByVal Target As Range)
'Sheet Module code, like: Sheet1!
Dim myAddress As String

myAddress = "$B$3"

If Target.Address = myAddress And Range("B3").Value <> "" Then
Range("B3").Select
ActiveSheet.Name = Range("B3").Value
End If
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'ThisWorkbook module code!
Dim myAddress As String
Dim myName As String

myAddress = "$B$3"

If Worksheets(1).Range("B3").Value <> "" Then
Worksheets(1).Range("B3").Select
myName = Selection.Value
Worksheets(1).Name = myName
End If
End Sub


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'ThisWorkbook module code!
Dim myAddress As String
Dim myName As String

myAddress = "$B$3"

If Worksheets(1).Range("B3").Value <> "" Then
Worksheets(1).Range("B3").Select
myName = Selection.Value
Worksheets(1).Name = myName
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,822
Messages
5,598,304
Members
414,224
Latest member
Crazy_FC

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
Top