ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   referencing worksheet as a variable (https://www.excelbanter.com/excel-programming/296494-referencing-worksheet-variable.html)

crew3407

referencing worksheet as a variable
 
Hello, this is my first post on the website, and I am a newbie at this.
I am trying to do a couple things I guess. First of all, in a macro,
am trying to get a hyperlink to reference a worksheet in the sam
workbook. The catch is, I have a userform where you have two tex
boxes where you input someones first name and someone's last name. Th
last name is stored in a variable. I want to use that variable t
reference the new worksheet that is created with that last name as th
worksheet name.

Sub OK_Click()

Dim f As String
Dim c As String

f = First.Text 'reference to my textbox
c = Last.Text

Bob Phillips[_6_]

referencing worksheet as a variable
 

activeworkbook.worksheets.add.name=c

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"crew3407 " wrote in message
...
Hello, this is my first post on the website, and I am a newbie at this.
I am trying to do a couple things I guess. First of all, in a macro, I
am trying to get a hyperlink to reference a worksheet in the same
workbook. The catch is, I have a userform where you have two text
boxes where you input someones first name and someone's last name. The
last name is stored in a variable. I want to use that variable to
reference the new worksheet that is created with that last name as the
worksheet name.

Sub OK_Click()

Dim f As String
Dim c As String

f = First.Text 'reference to my textbox
c = Last.Text




crew3407[_2_]

referencing worksheet as a variable
 
I guess I wasn't clear enough? Or maybe I don't understand the answe
given.

I was able to add in the sheet already (I used "Move and copy..." t
keep formatting the same.) Then I changed the name of the sheet so i
would be all uppercase. What I'm having trouble is with th
hyperlinking

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:="'UCase(c)'!A1", TextToDisplay:=UCase(c)

What do I put in the SubAddress so that the Hyperlink that is create
will have the correct reference to the sheet that I just created an
named by running the macro? I tried putting 'c' in for the workshee
name but it didn't work. Am I just missing something?

Thanks

--
Message posted from http://www.ExcelForum.com


crew3407[_3_]

referencing worksheet as a variable
 
Thanks Bob for helping. I actually figured this one out. Thanks agai
everyone

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 06:44 PM.

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