I have two spreadsheets. #1 is the customer submission form spreadsheet and #2 is a log of all customer data. On #2 I want to type in the customer name in cell A2. (The customer name is also the name of the customer submission spreadsheet. IE Grassland is the name of the company and Grassland_Submission_Form.xls is the name of the customer’s submission spreadsheet which is linked back to the log.) Is there a way to type in the customer name in A2 and have that name inserted to all the links across the row? Thank you.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
macro to insert file name in cell link (Excel 2000)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » macro to insert file name in cell link (Excel 2000)
- This topic has 14 replies, 3 voices, and was last updated 20 years, 4 months ago.
AuthorTopicWScindypositano
AskWoody LoungerJanuary 19, 2005 at 5:47 pm #414778Viewing 1 reply threadAuthorReplies-
WSHansV
AskWoody LoungerJanuary 19, 2005 at 6:51 pm #923139You can create a Worksheet_Change event handler for the Prospect Log worksheet that checks if A2 has changed, and if so, replaces the file name in B2:H2.
– Activate the Visual Basic Editor (Alt+F11)
– Double click Sheet1 (Prospect Log) in the Project Explorer.
– Copy the following code into the module that appears:Private Sub Worksheet_Change(ByVal Target As Range)
Dim strSearch As String, strReplace As String
Dim intPos1 As Integer, intPos2 As Integer
If Not Intersect(Target, Range(“A2”)) Is Nothing Then
strSearch = Range(“B2”).Formula
intPos1 = InStr(strSearch, “[“)
intPos2 = InStr(intPos1 + 1, strSearch, “]”)
strSearch = Mid(strSearch, intPos1 + 1, intPos2 – intPos1 – 1)
strReplace = Range(“A2”) & “_Submission_Form.xls”
If Not strReplace = strSearch Then
Range(“B2:H2”).Replace What:=strSearch, Replacement:=strReplace, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
End If
End If
End SubNote: you’ll get an error message if you type the name of a non-existent file. You could add error handling for this.
-
WScindypositano
AskWoody Lounger -
WSHansV
AskWoody Lounger
-
-
-
WSsdckapr
AskWoody LoungerJanuary 19, 2005 at 6:53 pm #923138How about something like this add to the sheet object?
Option Explicit Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("a2:A65536")) Is Nothing Then Dim rCell As Range Dim sPath As String Dim sFile As String sPath = "c:MyPath" For Each rCell In Intersect(Target, Range("a2:A65536")) sFile = "='" & sPath & "[" & rCell & _ "_Submission_Form.xls]2004 Submission - Page 1'!" Application.DisplayAlerts = False rCell.Offset(0, 1).Formula = sFile & "$D$4" rCell.Offset(0, 2).Formula = sFile & "$C$10" rCell.Offset(0, 3).Formula = sFile & "$J$4" Application.DisplayAlerts = True Set rCell = Nothing Next End If End Sub
When you add or copy anything into A2:A65536 it will add the formula/links to the cells in col b,c and D. Change the path as appropriate.
Steve
-
WScindypositano
AskWoody Lounger -
WSHansV
AskWoody LoungerJanuary 19, 2005 at 7:35 pm #923151Steve anticipated that, I didn’t. You’d have to adapt my code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strSearch As String, strReplace As String
Dim intPos1 As Integer, intPos2 As Integer
Dim rngCell As Range
If Not Intersect(Target, Range(“A2:A65536”)) Is Nothing Then
For Each rngCell In Intersect(Target, Range(“A2:A65536”)).Cells
strSearch = rngCell.Offset(0, 1).Formula
intPos1 = InStr(strSearch, “[“)
intPos2 = InStr(intPos1 + 1, strSearch, “]”)
strSearch = Mid(strSearch, intPos1 + 1, intPos2 – intPos1 – 1)
strReplace = rngCell & “_Submission_Form.xls”
If Not strReplace = strSearch Then
rngCell.Offset(0, 1).Resize(1, 7).Replace What:=strSearch, Replacement:=strReplace, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
End If
Next rngCell
End If
Set rngCell = Nothing
End Sub -
WSsdckapr
AskWoody LoungerJanuary 19, 2005 at 7:48 pm #923155
-
-
WScindypositano
AskWoody Lounger -
WSHansV
AskWoody Lounger -
WSsdckapr
AskWoody Lounger -
WScindypositano
AskWoody Lounger -
WSHansV
AskWoody LoungerJanuary 20, 2005 at 8:20 pm #923498The code Steve and I provided is a worksheet-level event handler. It goes into the module belonging to the worksheet it needs to act on. Right-click the worksheet tab and select View Code to see this module. Alternatively, you can double click the worksheet in the Project Explorer in the Visual Basic Editor.
-
WScindypositano
AskWoody LoungerJanuary 30, 2005 at 10:35 pm #925559When I attempt to change your file location with my file location in the formulas, I get an error message with the formula.
Your formula: =’http://www.wopr.com/w3tfiles/%5BGreenboro_Submission_Form.xls%5D2004 Submission – Page 1′!$D$4
My formula: =C:My documetsCaptives[Greenboro_Submission_Form.xls]2004 Submission – Page 1′!$D$4
Any suggestions? -
WSHansV
AskWoody LoungerJanuary 30, 2005 at 10:43 pm #925560Since you responded to yourself, it’s not clear who the “you” in your post is. The procedure in the workbooks Steve and I attached will only do something if you change a value in column A, and then only in the row of the changed cell(s). It won’t adjust already existing formulas in other rows.
-
-
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows 11 ad from Campaign Manager in Windows 10
by
Jim McKenna
12 hours, 2 minutes ago -
Small desktops
by
Susan Bradley
1 hour, 13 minutes ago -
Totally disable Bitlocker
by
CWBillow
6 hours, 54 minutes ago -
Phishers extract Millions from HMRC accounts..
by
Microfix
20 hours, 42 minutes ago -
Windows 10 22H2 Update today (5 June) says up-to-date but last was 2025-04
by
Alan_uk
22 hours, 34 minutes ago -
Thoughts on Malwarebytes Scam Guard for Mobile?
by
opti1
1 day, 1 hour ago -
Mystical Desktop
by
CWBillow
1 day, 1 hour ago -
Meta and Yandex secretly tracked billions of Android users
by
Alex5723
7 hours, 13 minutes ago -
MS-DEFCON 2: Do you need that update?
by
Susan Bradley
8 minutes ago -
CD/DVD drive is no longer recognized
by
WSCape Sand
1 day, 17 hours ago -
Windows 11 24H2 Default Apps stuck on Edge and Adobe Photoshop
by
MikeBravo
1 day, 19 hours ago -
North Face and Cartier customer data stolen in cyber attacks
by
Alex5723
1 day, 18 hours ago -
What is wrong with simple approach?
by
WSSpoke36
1 day, 10 hours ago -
Microsoft-Backed Builder.ai Set for Bankruptcy After Cash Seized
by
Alex5723
2 days, 5 hours ago -
Location, location, location
by
Susan Bradley
19 hours, 54 minutes ago -
Cannot get a task to run a restore point
by
CWBillow
2 days, 6 hours ago -
Frustrating search behavior with Outlook
by
MrJimPhelps
1 day, 21 hours ago -
June 2025 Office non-Security Updates
by
PKCano
2 days, 17 hours ago -
Secure Boot Update Fails after KB5058405 Installed
by
SteveIT
20 hours, 14 minutes ago -
Firefox Red Panda Fun Stuff
by
Lars220
2 days, 17 hours ago -
How start headers and page numbers on page 3?
by
Davidhs
3 days, 3 hours ago -
Attack on LexisNexis Risk Solutions exposes data on 300k +
by
Nibbled To Death By Ducks
2 days, 6 hours ago -
Windows 11 Insider Preview build 26200.5622 released to DEV
by
joep517
3 days, 12 hours ago -
Windows 11 Insider Preview build 26120.4230 (24H2) released to BETA
by
joep517
3 days, 12 hours ago -
MS Excel 2019 Now Prompts to Back Up With OneDrive
by
lmacri
3 days, 2 hours ago -
Firefox 139
by
Charlie
2 days, 18 hours ago -
Who knows what?
by
Will Fastie
1 day, 21 hours ago -
My top ten underappreciated features in Office
by
Peter Deegan
3 days, 13 hours ago -
WAU Manager — It’s your computer, you are in charge!
by
Deanna McElveen
1 day, 7 hours ago -
Misbehaving devices
by
Susan Bradley
2 days, 9 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.