Hyperlink Code For Sheet Names With Spaces Or Dashes
I believe I have 99% of what I need. The code below has one bug. (See just the underlined text for a very quick overview. The rest is detail.)
My goal is to generate a TOC that:
1) has the VBA run from my Personal Workbook.
2) can be run in any worksheet of any open workbook.
3) can be run in a worksheet of any name.
4) will insert itself at the currently active cell.
5) has entries hyperlinking to the referenced worksheets - of any name.
Right now, I'm stuck with the last point. The macro below will generate the TOC at the currently active cell. The TOC will be hyperlinks to the referenced worksheets.
However, if the referenced worksheet contains a space, dash, or other special character then the generated hyperlink is broken. For example, if the referenced worksheet is "sheet1" then the hyperlink generated works just fine. However, if the referenced worksheet is "sheet-1" then the generated hyperlink doesn't work.
Dim objSheet As Object
Dim intRow As Integer
Dim strCol As Integer
Set objSheet = Excel.Sheets
intRow = ActiveCell.Row 'Start writing in active row
strCol = ActiveCell.Column 'Start writing in active column
For Each objSheet In ActiveWorkbook.Sheets
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
objSheet.Name & "!A1", TextToDisplay:=objSheet.Name
intRow = intRow + 1
View Complete Thread with Replies
Related Forum Messages:
Sheet Names With Spaces In VBA
I have been using the code below for a form. But now I need to change the sheet name to have spaces. But when I do. I comes up with the Run Time 1004 error on the “Ctrl.Text = Range(Ctrl.Tag).Text '*** “ line.
Why is it that this line is not allowing me to have spaces?
Private Sub Load_Controls()
Dim Ctrl As Control
For Each Ctrl In UserForm1.Controls
If Ctrl.Tag "" Then
Ctrl.Text = Range(Ctrl.Tag).Text '***
Newly Created Tab Names Placed As Hyperlink On Content Sheet
I attach an example worksheet with the code I have thus far.
In my workbook I have other sheets, one of which changes and updates a specific one each time a new client's data is entered on said other sheet. Because I want to save the specific client's data and not lose it when another client's stuff is entered on this other sheet, I copy the sheet where the data is summarised (I called this sheet "Sheet to Copy From") to a newly inserted sheet and use Paste Special, Values Only to change all functions /f ormulae / Links ect to values.
I then change the name of the sheet to the name of the client.
I then use this sheet name / cell value to polulate a range on another sheet (Next Empty Cell) as a Hyperlink to the newly created sheet above. This sheet I called "Table of Contents".
how to code the hyperlink. Using Macro Recorder uses the specific case's names, but the Tab name to be used as Hyperlink value will always be the name of a new client,
Referencing Sheet Code Names By Variable
I have a set of worksheets (Sheet31 through Sheet49 by codename) produced by a machine in the lab. I want to create a summary sheet that references cells in those worksheets.
Rather than go through the annoyance of doing this manually 40+ times I'm working on creating a macro to populate the summary sheet for me.
This is what I have so far
For J = 31 To 49
ResultSht = SheetJ.Name
It hangs up on the "SheetJ.Name" however. My objective is to be using the object SheetJ, where the object SheetJ is the codename of the results sheet I'm trying to reference (for example, in the first pass through the loop it would be Sheet31). Could someone point out my mistake in this object reference?
VBA Code For Listing The Sheet Names Of Deleted Sheets
I have a workbook with 20+ sheets in it, I add sheets and delete sheets on a daily basis, except for one sheet that is like my summary sheet.
Is there a code, formula, or magic spell that will list the names of the sheets that I have deleted? For instance, if my workbook has 50 sheets and I delete 49 of them, I want to see cells A1 thru A49 (or where ever I wish to place them) filled with the names of the sheets I just deleted.
Hyperlink In Cell Have Email CODE But Hyperlink Is Not Clickable
I have this code that looks through my worksheet once the conditions are met it will email, and in column "M" I put a hyperlink to where the document is stored. All works as far as the email format, even grabs the hyperlink but it’s not clickable in the email.
Here is the code.
I am outlook 07 and vista 07.
Const Startingrow = 11 'Data starts on row ##
Const AlarmDelay = 183 'send warning
'References needed :
'Microsoft Outlook Object Library
Dim i As Long
Dim j As Long
Dim msg As Long
Dim Lastrow As Long
Dim WhoTo As String
Dim SubjectLine As String
Dim MessageBody As String
Dim olMail As Outlook.MailItem
Dim olApp As Outlook.Application
Dim strLink As String
Hyperlink Index To Changing Sheets Tab Names
I have a long list of tabs listing "projects" which have changing names - on the first sheet, I want to have the table of contents automatically update and link to each tab - I want the user to only have to change the tab name to have the table of contents and link update -
Create Array Of File Names/sheet Names
Two part question:
1) I'm relatively new to arrays, but what I need to do is generate a list of file names and the sheets within each one. I would like to use an array for this, but since I don't have much experience.... well....that's why I'm here. Can someone point me in the right direction?
2) And the second part of this.... I was planning on using the FileSystemObject to determine the files in a selected folder and loop through that list of files, opening each one and harvesting the required info (file name and all sheet names). Should I use the FSO or is there something built into Excel that might be better (and also limit the number of dependencies for this little "project" of mine).
Code To Remove Extra Spaces From Data.
I have a macro which opens one excel file, then copies the data into another, dead easy. However the first file is 'downloaded' from a bespoke package, where (for whatever reason) the package appends a number of spaces (" ") after data in one of the columns,
So sometimes the data will contain one, ten or more extra spaces (no telling how many) ie, it could look like "AB ", "AB ", or "AB " etc
Ideally What i need is a small bit of code that once the data has been imported to my sheet it can run and 'strip' extra spaces from the column, lets say column f, to leave all the data in this column to look like:
I am drawing a blank, any simple lines of code?
Put Hyperlink Code In This Button Code
Dim Lr As Long
Lr = Cells(Rows.Count, "A").End(xlUp).Row
If IsNumeric(Cells(Lr, "A")) Then
Cells(Lr + 1, "A").Value = Cells(Lr, "A").Value + 1
This adds 1 to the previous cell and displays in the next available cell.
How could I make it sao that when this number enters in the cell it hyperlinks automatically to the master file?
Before this button was introduced I used this:
Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error GoTo Err_App_WorkbookBeforeSave
Dim hl As Hyperlink
For Each hl In Me.Hyperlinks
If Wb.FullName = hl.Address Then
Application.EnableEvents = False
Cancel = True..............
Remove All The Dashes
Have a column containing data which may have 1-3 dashes locates within
each cell value.
Would like to remove all the dashes "unless" the last dash to the right
is followed by a just a single digit. The results would be as follows:
On the example data, it kept 2 of the dashes in the cell values,
because the were only one digit away from the extreme right, but
removed all others.
Return Cells That Have Exactly 3 Dashes
I have a column of data (column A) with cells that have IDs (alpha-numeric) that contain anywhere between 0 to 5 dashes. Since this column will change weekly, I want to dynamically pull only those cells that contain 3 dashes.
I would only want to have returned 10648145-3026718-t526363536m since it contains 3 dashes. Do you know of a nifty formula for doing this? I think an array would get me the dynamic piece (so they are not spaced out).
Want To Add Dashes To Cell Text...
I have a column of city names, some are one word and others are two or more. I am trying to take the city name and add it to another word, add dashes in between them and make everything lower case. For example:
Column 1, Cell 1 is: San Diego
I'd like it to look like: books-san-diego (books being the keyword I'd like to insert before the city.)
Open Hyperlink In Cell With Macro Code
how to open a Hyperlink directly. I have writen some code which allows me to copy over certain cells from a large list of hyperlinked files. However I am struggling to figure out how to open the hyperlink without actually writing the hyperlink address into the code. The hyperlinks are the file names and not the file paths. In essence I'm aiming to just get the macro to "click" the hyperlink to open it. Once the file is open the rest of my code will work, it is just this one sticking point.
Hyperlink Same Sheet
This HAS to be a simple fix. Could not find a string with this solution in it yet.
Trying to set up a hyperlink to reference another location in the same sheet.
Used the example in Excel as a model to set this up so placed this formula in cell B1:
this defaults to =hyperlink(Sheet1!a1,"LINK") since Book1 is the current wb.
clicking on "link" in cell B1 produces "Cannot open specified file" error.
I need the hyperlink to be dynamic, so I can't use the CTRL+K hyperlink function.
Hyperlink To Sheet
on sheet 1, i have 6 combo boxes ... one for each semester of Grade 8, Grade 9, and Grade 10.
Each is completely independent of all the others and each shows the subject codes for that grade in that semester.
what I would like to do is ..
if I click on (let's say ) box 3, and choose the 4th subject code down the box, I would like to be 'teleported' to sheet that bears that same subject code.
Is this possible, and is it a problem that the other 5 combo boxes will still have a subject code in their display window from previous viewings ?
Format Cells With Dashes Between Alphanumerics
I'm trying to find a way to have excel 2003 format the data I put in a cell to auto insert dashes every five characters. I'm entering product keys for the software we have on hand, and it would be a little quicker if I could simply have excel auto format the data entered in to include dashes every five characters.
- I would enter: D5ATT3D28F6F44536489413E2 (This is a fake, non-working product key, I just typed in random numbers a letters.)
-Excel would format it like: D5ATT-3D28F-6F445-36489-413E2
How Do I Get The Dashes To Not Count As A Digit/number?
I have this script that does what i need it to do but one thing, I need the script to count the numbers as digits only and not the dashes in the format.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Intersect(Target, Range("I21:I24")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Application.EnableEvents = False
If (Len(Target) > 11) Or (Len(Target) < 10) Then
MsgBox "Not a valid number of characters, please try again"
Target.Value = vbNullString...................
Reference Different Sheet For Hyperlink
I'm working on a formula to get the the path of a picture on a different sheet in a workbook. I am trying to get use the hyperlink function to reference that cell on the the other sheet. It looks right but I get an error saying that it cannot open the specified file.
This is what my formula looks like:
I need it to actually get the actual text value of the cell I am trying to reference. How would I do that?
Hyperlink 120,000 Cells In One Sheet
I have a excel worksheet (2000 format generated by java excel api)that needs to hyperlink roughly 120,000 cells. After hyperlinking exactly 65534 cells, the remaining cells are just underlined blue text w/o hyperlinks. Even when it's saved as Excel 2007 worksheet, I was unable to add anymore hyperlinks manually.
I don't know if there is a way to make it work?
There are 30,970 rows and 11 columns in the sheet.
Is there any solution that does not involve spliting sheet, greatly increasing # of columns, or greatly increasing # of rows.
Hyperlink To Top Position Of Sheet
I have an index on sheet 1 that hyperlinks to various cells on sheet 2.
Some of the links end up as the last visible active cell on sheet 2.
How can I have the linked cells in sheet 2 be the uppermost visible active cell below row 1 which is frozen.
Picture Hyperlink To Different Sheet
One picture where i have added " sheet hyperlink" to excist sheet.
But how i´m trying to do same issue with application what i have made with VB, but there is two big walls .
VB application should work right this
User create picture name it "test". The user make sheet hyperlink with VB application and in sametime born new sheet named "test". Now we have picture what include link to test sheet.
Updating A Hyperlink When A Sheet Name Changes
For the last few weeks this has been the place to be ;-). I have a question. Is there anyway to update a hyperlink automatically if the name of the sheet changes?
I have about 70 sheets and the names change every 22 days so I have it now for the value in the cell to update every time the sheet name is change but the hyperlink still is looking for the old sheet name.
Hyperlink Problem If Space In Sheet Name
I've a problem using hyper link when I've a space between sheet name…… Please guide me in this regard.
Where A5 is First Sheet Name "Jan" and B5 is second part of sheet name "Expense".
It works properly but when i've space in sheet name then unable to work. I've used below format but still no luck
Also, If I have space in file name than its also not working.
Please give the solution in both cases of Space in File name & space in sheet name in my attached file.
Saved Sheet To Create Hyperlink
I have a workbook for Purchase orders.
how it works at the moment is when I fill in the Purchase prder sheet then save it, I have a macro that
Copies Sheet "Purchase Order" creates a new sheet to paste it to then also copies some details to A Sheet called "Register.
I would like to be able to (if possible)
1/ automaticly create a hyperlink between the P/o Nomber stored on the register as it is storing the new sheet &
2/ automaticly change the sheet tab to reflectthe P/order number in Cell G8
I have very little knowlage of VBA & am learning how to record macros so please be gentle.
here is the macro I recorded ....
Moving Position On Sheet After Hyperlink
There might be a really easy solution to this, I'm just having a tough time figuring it out. I have hyperlinks that link to cells on another sheet in the same workbook. I would like, after the cell is selected, for the selection to be positioned at the top of the sheet.
Prevent Hyperlink Breaking On Sheet Name Change
I have a workbook with a template worksheet. I can generate new worksheets using the Template, and create hyperlink to the new worksheet (Let's call it "New"). However, if an user changes the name of the worksheet from "New" to "SomethingElse", then the hyperlink breaks. How do I get the hyperlink to be automatically updated to "SomethingElse"?
Run Code On Worksheets With Certain Tab Names
My Thread title should have read covert code TO run on all worksheets with same word in Name. I have had a look at some other pieces of code in this forum but they are quite the same as I want to do....I have tried a few things but each time I get an error ...so for sure I am not modifying the code quite right, I ahve been missing something for what I now want it to do. So I wonder if someone could Please review these two pieces of code...they of course are both for running on just one worksheet in a wookbook.
I would like them both be able to run, still as tow separete pieces of code as they are, on all and only worksheets that have in their worksheet name a key word in this case the word "Region" and that those worksheets all in a single workbook but the workbook does have other worksheets in it I dont want the code to run one on - but those worksheets do not have in their worksheet name the word "Region".
Dim r As Range, txt As String, ws1 As Worksheet, i As Long
Set ws1 = Sheets(1)
.CompareMode = vbTextCompare
For i = 16 To 21
For Each r In ws1.Range(ws1.Cells(6, i), ws1.Cells(Rows.Count, i).End(xlUp))
If r.Value <> "" Then
If Not .exists(r.Value) Then
.Add r.Value, Nothing
txt = txt & "," & r.Address(0, 0)
If Len(txt) > 245 Then
txt = "": .RemoveAll: Goto Again
End If .............
Summary Sheet Of Sheet Tab Names
I’ve had a look through the forum and on some of the guides/FAQ but thanks to my ineptitude I have been unable to adapt any of the examples to my specific situation.
What I’m after is this: I need to create a summary sheet for a work book with a variable number of tabs. All I need the summary sheet to do is to make a table of the name of the tab and then cell A17. How would I go about doing this and is it possible to save this macro to my machine/all workbooks instead of just the one?
Code To Update With Names From Ranges
I need my SQL server query to update with names from a range. e.g. pinnog as shown below is a name defined range called Name1 and smithb will be Name 2.
Can someone with me with this code as I am not sur ehow to lookup ranges in VBA.
My code is below ...
VBA Code- To Pull All The Names Of The Worksheets In A Workbook
I just started playing with creating my own macros. I've written a macro to pull all the names of the worksheets in a workbook, now what I want to do is write a piece of code that will pull data from a cell in those worksheets.
So for instance I have all my worksheet names in cell A1 to A10, I want to pull the data from cell E1 from every worksheet in A1 to A10. Can someone help me with a sample code to work with. I'm still reading Power Progamming haven't gotten so far yet.
Parse Worksheet Names Directly In Code
I am trying to add new worksheets at the end of the existing ones, with the name "Scenario " & i (i being an integer for the next scenario).
My idea is to parse the Worksheet names, counting how many times the string "Scenario " appears, and then add a new Worksheet with that name and index i+1. Here is the
Public Sub store_data_Click()
Dim NameWS, prev_sheet As String
Dim iprev, iws, iscenario As Integer
iscenario = 1
For iws = 1 To Worksheets.Count
If Find(Sheets(iws).Name, "Scenario ") = True Then
iscenario = iscenario + 1
1.- Find (8th line) does not seem to be the right procedure to use; how could I do this in a clean/direct (i.e. not writing the names into a dummy worksheet and using the find function) way?
2.- How could I substitute the new Worksheet ("Scenario " & i) formulas for values without having to select all the cells and then use paste values (not so elegant).
3.- Connecting to a previous post: How could I define *exactly* the position to paste "Autoshape 1"?
Delete All Range Names Macro Code
I have written VBA code which is operated every month. This code deletes several range names in a target spreadsheet, performs other actions - including extracting certain areas to different spreadsheets and then closes the spreadsheet without saving.
The range names in the target spreadsheet are required for ongoing use, so can not be deleted permanently.
Is there any code that deletes all range names in one go? At present my code includes the results of recording a macro wherein I delete each range name in turn - creating script over 100 lines long.
Look Up Sheet Names
In Column A row 4 of sheet1 I have an account name, for example Sonic, and I have a sheet named the account name, Sonic. In Column B row 4, of sheet1, I would like to return the value in Column B row 3 in sheet named Sonic, or the account named sheet.
I have about 50 different account names along Column A in sheet1, and the same account name sheets opened in the same workbook. Is there a good formula or vba code that will work for all the values in Column A of sheet1 to look for the same named sheet and return the values off of that? Note: on the account sheets in Column A it says ‘Account’ for all of them.. this wasn’t a mistype
2007 VBA - Code For E-Mailing Files To Names In A Range
I have some code to email a single, different excel file to multiple Outlook recipients. I am using Outlook 2003, and Excel 2007. I always use Compatability mode in Excel as 2007 is not widely used.
The code is shown below. What I can't understand is why it fails at the code highlighted red. It tells me that there is Run-time Error '13': Type Mismatch, but I can't see the issue.
Formula Containing Sheet Names
I have done a formula for Abbott as shown below however I actually have about 50 sheets with names. I have the names listed in column A. Is there a formula that instead of typing Abbott as shown I can use the cell in column A to generate a code ?
Duplication Of Sheet Names
I made a macro that will name the current sheet whatever text is found in cell B2 on that sheet. This works great unless that sheet name already exists.
If the sheet name already exists, is there a way to rename it as Cell B2 plus the number 2 after the title so it doesn't cause an error?
"Smith, Bob" is a sheet name, so the macro would make the new sheet name "Smith, Bob 2"
Alternatively, how could I give a pop-up telling about the error and deleting the current sheet instead of renaming it with a "2"?
"Sorry, 'Smith, Bob' already exists. Deleting new sheet." as a popup and have it delete the current sheet.
Sheet Names Add Conditionally
I want to add to it so that if the "Name" entered into the target cell is longer then the maximum allowd length it inserts an abreviation of the words (and increments where nessisary)
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
On Error GoTo StandardName
If Target.Address = "$B$4" Then Sh.Name = Target
Sh.Name = "Sheet1"
Variable Sheet Names In VBA
Running Windows CP; Excel 2003
The Board looks full of some interesting issues today.
I'm working on a workbook that hides and unhides a lot of columns depending on the month the user has selected. No problems here.
The sheets are named regionally, ie National 2008, California 2008 etc. The user is able to select the month and the year from separate combo boxes.
So when 2009 comes around I will need to rewrite many lines of code to point the VBA to the new worksheet names like National 2009, California 2009. My question is, is there a way to reference either variable worksheet names in the VBA or some other manner in which to write the code so I don't need to rewrite every year change?
I currently reference the sheets something like Sheets ("National 2008").Range("H:H").EntireColumn.Hidden=True
Change Sheet Names
I have got a workbook with about 200 sheets... Sheet1 > Sheet200
i need to delete about 100 sheets... sheet100 > sheet200
i then need to add the sheets back in but when i do the sheet numbers start from Sheet201... how do i get it to start from Sheet101 again or can i use some vba to change them later?