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
-
Turning off OneDrive
by
CWBillow
2 hours, 21 minutes ago -
June 2025 updates are out
by
Susan Bradley
2 hours, 7 minutes ago -
Mozilla shutting Deep Fake Detector
by
Alex5723
12 hours, 38 minutes ago -
Windows-Maintenance-Tool (.bat)
by
Alex5723
12 hours, 41 minutes ago -
Windows 11 Insider Preview build 26200.5641 released to DEV
by
joep517
15 hours, 10 minutes ago -
Windows 11 Insider Preview build 26120.4250 (24H2) released to BETA
by
joep517
15 hours, 12 minutes ago -
Install Office 365 Outlook classic on new Win11 machine
by
WSrcull999
15 hours, 9 minutes ago -
win 10 to win 11 with cpu/mb replacement
by
aquatarkus
7 hours, 2 minutes ago -
re-install Windows Security
by
CWBillow
18 hours, 26 minutes ago -
WWDC 2025 Recap: All of Apple’s NEW Features in 10 Minutes!
by
Alex5723
22 hours, 7 minutes ago -
macOS Tahoe 26
by
Alex5723
16 hours, 21 minutes ago -
Migrating from win10 to win11, instructions coming?
by
astro46
4 hours, 25 minutes ago -
Device Eligibility for Apple 2026 Operating Systems due this Fall
by
PKCano
6 hours, 53 minutes ago -
Recommended watching : Mountainhead movie
by
Alex5723
7 hours, 37 minutes ago -
End of support for Windows 10
by
Old enough to know better
7 hours, 33 minutes ago -
What goes on inside an LLM
by
Michael Covington
1 hour, 47 minutes ago -
The risk of remote access
by
Susan Bradley
6 hours, 42 minutes ago -
The cruelest month for many Office users
by
Peter Deegan
13 hours, 49 minutes ago -
Tracking protection and trade-offs in Edge
by
Mary Branscombe
11 hours, 52 minutes ago -
Supreme Court grants DOGE access to confidential Social Security records
by
Alex5723
1 day, 20 hours ago -
EaseUS Partition Master free 19.6
by
Alex5723
21 hours, 8 minutes ago -
Microsoft : Edge is better than Chrome
by
Alex5723
2 days, 9 hours ago -
The EU launched DNS4EU
by
Alex5723
2 days, 22 hours ago -
Cell Phone vs. Traditional Touchtone Phone over POTS
by
280park
2 days, 12 hours ago -
Lost access to all my networked drives (shares) listed in My Computer
by
lwerman
3 days, 3 hours ago -
Set default size for pasted photo to word
by
Cyn
3 days, 9 hours ago -
Dedoimedo tries 24H2…
by
Cybertooth
2 days, 22 hours ago -
Windows 11 Insider Preview build 27871 released to Canary
by
joep517
4 days, 8 hours ago -
Windows 11 ad from Campaign Manager in Windows 10
by
Jim McKenna
2 days, 1 hour ago -
Small desktops
by
Susan Bradley
13 hours, 22 minutes 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.