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
-
Very Quarrelsome Taskbar!
by
CWBillow
49 minutes ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
3 hours, 33 minutes ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
4 hours, 52 minutes ago -
Is your battery draining?
by
Susan Bradley
20 minutes ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
6 hours, 49 minutes ago -
Weasel Words Rule Too Many Data Breach Notifications
by
Nibbled To Death By Ducks
7 hours, 25 minutes ago -
Windows Command Prompt and Powershell will not open as Administrator
by
Gordski
10 hours, 40 minutes ago -
Intel Management Engine (Intel ME) Security Issue
by
PL1
1 hour, 23 minutes ago -
Old Geek Forced to Update. Buy a Win 11 PC? Yikes! How do I cope?
by
RonE22
3 hours, 54 minutes ago -
National scam day
by
Susan Bradley
6 hours, 50 minutes ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
4 hours, 5 minutes ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
1 day, 8 hours ago -
Tools to support internet discussions
by
Kathy Stevens
1 day, 15 hours ago -
How get Group Policy to allow specific Driver to download?
by
Tex265
23 hours, 34 minutes ago -
AI is good sometimes
by
Susan Bradley
1 day, 15 hours ago -
Mozilla quietly tests Perplexity AI as a New Firefox Search Option
by
Alex5723
1 day, 5 hours ago -
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
2 days, 15 hours ago -
June KB5060842 update broke DHCP server service
by
Alex5723
2 days, 14 hours ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
2 days, 18 hours ago -
Excessive security alerts
by
WSSebastian42
1 day, 9 hours ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
3 days, 4 hours ago -
Ben’s excellent adventure with Linux
by
Ben Myers
1 hour, 15 minutes ago -
Seconds are back in Windows 10!
by
Susan Bradley
2 days, 15 hours ago -
WebBrowserPassView — Take inventory of your stored passwords
by
Deanna McElveen
1 day, 8 hours ago -
OS news from WWDC 2025
by
Will Fastie
18 hours, 52 minutes ago -
Need help with graphics…
by
WSBatBytes
1 day, 23 hours ago -
AMD : Out of Bounds (OOB) read vulnerability in TPM 2.0 CVE-2025-2884
by
Alex5723
3 days, 19 hours ago -
Totally remove or disable BitLocker
by
CWBillow
2 days, 18 hours ago -
Windows 10 gets 6 years of ESU?
by
n0ads
2 days, 21 hours ago -
Apple, Google stores still offer China-based VPNs, report says
by
Nibbled To Death By Ducks
4 days, 6 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.