VBA Find/Select Worksheet with Range as Name

jrepko11

New Member
Joined
Nov 10, 2011
Messages
25
Hello,

I am creating a workbook that will allow multiple users to work at once. When the workbook opens, a template is copied and pasted as a new sheet with their name as the sheet name. The workbook_open macro looks at their windows username in a list and then creates the sheet for their name (a column over). This is working fine.

I am also creating a macro for when they save the workbook. I first need their worksheet to be activated so that the right data is copied and pasted with the save button. Here is the code I have. I'm wondering if I can call up a worksheet that has a range as a name?

Sub TestSave()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim rng As Range

With Worksheets("Associates").Range("A:A")
Set rng = .Find(What:=UserNameWindows, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
Application.Goto rng, True
Selection.Activate

Dim Name As Range
Set Name = ActiveCell.Offset(0, 1)
End If
End With
Worksheets(Name).Activate

End Sub

I thought about using location, as the sheet pastes before the "Associates" sheet when they open the book, but if the book is shared, I'm not sure if their specific sheet will always be the one in front of "Associates"

Any ideas would help, please let me know if you have questions. Thanks!!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,216,158
Messages
6,129,207
Members
449,493
Latest member
JablesFTW

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