Any way to delete characters from a 255+ character string in a given cell, while maintaining formatting?
example:
Range("A1").value = "Lathe-CNC-Primary1 | Inspection-In Process1 | OV - Heat Treat0 | Deburring1 | Lathe-CNC-Primary0 | Honing0 | Lathe-CNC-Primary0 | Deburring1 | Inspection-In Process1 | OV - F.P.I0 | Inspection-In Process1 | OV - Nitride0 | Inspection-In Process1 | Grinding Thru Feed1 | Inspection-In Process0 | 0V - Coating0 | Inspection-Final0"
Range("A1").Characters(Start:=1, Length:=17).font.bold = True
Range("A1").Characters(Start:=17, Length:=1).delete 'Does Nothing
I am using the 1's and 0's in this string (comes from a SQL statement) to format the word it's attached to, then deleting the 1 or 0.
desired result for the string in Range("A1"):
Lathe-CNC-Primary | Inspection-In Process1 | OV - Heat Treat0 | Deburring1 | Lathe-CNC-Primary0 | Honing0 | Lathe-CNC-Primary0 | Deburring1 | Inspection-In Process1 | OV - FPI0 | Inspection-In Process1 | OV - Nitride0 | Inspection-In Process1 | Grinding Thru Feed1 | Inspection-In Process0 | 0V - Coating0 | Inspection-Final0
Thanks, Josh
not sure what's your actual goal
you could either
use Replace()
method after your formatting:
With Range("A1") Replace what:="1 |",replacement:=" |", LookAT:=xlPart Replace what:="0 |",replacement:=" |", LookAT:=xlPart End With
Use Mid()
function:
With Range("A1") .Value = Mid(.Value, Start:=1, Length:=17) & Mid(.Value, Start:=18) '<--| "deletes" character in position 18 End With
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.