I have a formula in a cell that uses a named range like this:
=”Error with vendor # – ” & VendorCode
Is there a way to make the data represented by the VendorCode named range to be bold faced so that it stands out?
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Formatting (2002)
Here is an example. You can add this to the workbook object in VB of the appropriate sheet (not a regular module):
Option Explicit Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim str1 As String Dim str2 As String If Not Intersect(Target, Range("VendorCode")) Is Nothing Then str1 = "Error with Vendor # - " str2 = Range("VendorCode").Value Application.EnableEvents = False With Range("a1") .Value = str1 & str2 .Characters(Start:=Len(str1) + 1, Length:=Len(str2)). _ Font.FontStyle = "Bold" End With Application.EnableEvents = True End If End Sub
When vendor code is changed, the code runs and changes the contents of cell A1 (change as desired)
Steve
I see that Steve has replied with code that is similar to what is in the workbook in my reply. However, I think that what you were asking in this question was how to format the vendor code as bold manually after you Paste Special the string into a cell. You would do this by selecting the cell, and then select the text that you want to format in the formula bar. Then either click on the formatting you want in the toolbar, or select Cells from the Format menu and select the formatting you want.
Not directly. Depending on whether the cell represented by the name VendorCode contains a constant or a formula, you could use the worksheet change event routine or the worksheet calculate routine to build the string as a constant, put it in the target cell, and format it however you want.
The attached worksheet shows how it would work with a constant in A1 and a formula in A2 and the results in D1 and D2 respectivly.
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.
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.
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.
Notifications