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
-
Extended Windows Built-in Disk Cleanup Utility
by
bbearren
54 seconds ago -
Win 11 24H2 June 2025 Update breaks WIFI
by
dportenlanger
10 hours, 21 minutes ago -
Update from WinPro 10 v. 1511 on T460p?
by
CatoRenasci
7 hours, 39 minutes ago -
System Restore and Updates Paused
by
veteran
12 hours, 51 minutes ago -
Windows 10/11 clock app
by
Kathy Stevens
6 hours, 53 minutes ago -
Turn off right-click draw
by
Charles Billow
16 hours, 5 minutes ago -
Introducing ChromeOS M137 to The Stable Channel
by
Alex5723
19 hours, 36 minutes ago -
Brian Wilson (The Beach Boys) R.I.P
by
Alex5723
2 hours, 41 minutes ago -
Master patch listing for June 10, 2025
by
Susan Bradley
21 hours, 13 minutes ago -
Suggestions for New All in One Printer and a Photo Printer Windows 10
by
Win7and10
6 minutes ago -
Purchasing New Printer. Uninstall old Printer Software First?
by
Win7and10
1 day, 3 hours ago -
KB5060842 Issue (Minor)
by
AC641
1 day, 7 hours ago -
EchoLeak : Zero Click M365 Copilot leak sensitive information
by
Alex5723
1 day, 10 hours ago -
24H2 may not be offered June updates
by
Susan Bradley
2 hours, 57 minutes ago -
Acronis : Tracking Chaos RAT’s evolution (Windows, Linux)
by
Alex5723
1 day, 22 hours ago -
June 2025 updates are out
by
Susan Bradley
11 hours, 12 minutes ago -
Mozilla shutting Deep Fake Detector
by
Alex5723
2 days, 13 hours ago -
Windows-Maintenance-Tool (.bat)
by
Alex5723
1 day, 23 hours ago -
Windows 11 Insider Preview build 26200.5641 released to DEV
by
joep517
2 days, 16 hours ago -
Windows 11 Insider Preview build 26120.4250 (24H2) released to BETA
by
joep517
2 days, 16 hours ago -
Install Office 365 Outlook classic on new Win11 machine
by
WSrcull999
2 days, 16 hours ago -
win 10 to win 11 with cpu/mb replacement
by
aquatarkus
2 days, 8 hours ago -
re-install Windows Security
by
CWBillow
2 days, 19 hours ago -
WWDC 2025 Recap: All of Apple’s NEW Features in 10 Minutes!
by
Alex5723
2 days, 23 hours ago -
macOS Tahoe 26
by
Alex5723
2 days, 17 hours ago -
Migrating from win10 to win11, instructions coming?
by
astro46
8 hours, 3 minutes ago -
Device Eligibility for Apple 2026 Operating Systems due this Fall
by
PKCano
2 days, 7 hours ago -
Recommended watching : Mountainhead movie
by
Alex5723
2 days, 8 hours ago -
End of support for Windows 10
by
Old enough to know better
7 hours, 28 minutes ago -
What goes on inside an LLM
by
Michael Covington
8 hours, 25 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.