Question posted 2012 · +4 upvotes
I have excel cells which contain entries like this:
name/A/date
name/B/date
name/C/date
Cell content is displayed on multiple lines in the same cell. I would like to make only “name” bold for all entries. I recorded a macro and I think the solution must be something like this:
ActiveCell.FormulaR1C1 = "name/A/date" & Chr(10) & "name/B/date" & Chr(10) & "name/C/date"
With ActiveCell.Characters(Start:=25, Length:=4).Font
.FontStyle = "Bold"
End With
What I don’t know is how to get the start value and the length of each entry. Anyone got an idea?
Accepted answer +7 upvotes
Have it now:
lngPos = InStr(ActiveCell.Value, "/")
With ActiveCell.Characters(Start:=1, Length:=lngPos - 1).Font
.FontStyle = "Bold"
End With
Top vba Q&A (6)
- Difference between Visual Basic 6.0 and VBA +122 (2009)
- VBA – how to conditionally skip a for loop iteration +116 (2011)
- VBA: Test if string begins with a string? +53 (2013)
- html parsing of cricinfo scorecards +47 (2012)
- Code to loop through all records in MS Access +46 (2011)
- Access VBA | How to replace parts of a string with another string +44 (2011)
vba solutions on this site
.