Vba validation issue Help

kamalvenug

New Member
Joined
Dec 7, 2024
Messages
2
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi everybody,

Thanks for the support,please help I have attached the code that I tried doing the below

I have a issue where I have to retain the font color of each words in cell that has delimiter comma.

first i do validation of checking the cell value if the first letter is capital and the Initials are all capital then join them back to display in cell but currently the font color are changing to last word color

eg: Arun a, kmaal k,Jack js

if Arun a is yellow
kmaal k is red
Jack js is saffron

then it should display Arun A, Kmaal K, Jack JS in the same color each word mentioned above however below code is showing all in same color
 

Attachments

  • Screenshot 2024-12-07 162222.png
    Screenshot 2024-12-07 162222.png
    244.1 KB · Views: 5

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi everybody,

Thanks for the support,please help I have attached the code that I tried doing the below

I have a issue where I have to retain the font color of each words in cell that has delimiter comma.

first i do validation of checking the cell value if the first letter is capital and the Initials are all capital then join them back to display in cell but currently the font color are changing to last word color

eg: Arun a, kmaal k,Jack js
VBA Code:
                    Dim cellvalued As String
Dim wordarrayed As Variant
Dim newtext
Dim wordarrayed2 As Variant
Dim Cell As Range
Dim Val
Dim p As Long
Dim orgnal As Long
Dim modcelled As String
cellvalued = Range("h" & t).Value
Set Cell = ThisWorkbook.Sheets("Congress Materials").Range("h" & t)
Val = Cell.Value

wordarrayed = Split(cellvalued, ",")

For p = LBound(wordarrayed) To UBound(wordarrayed)
'orgnal = wordarrayed(p).Font.ColorIndex
orgnal = Cell.Characters(Start:=InStr(Cell.Value, wordarrayed(p)), Length:=Len(wordarrayed(p))).Font.Color
wordarrayed(p) = StrConv(wordarrayed(p), vbProperCase)

wordarrayed2 = Split(wordarrayed(p), " ")
If UBound(wordarrayed2) > 0 Then
wordarr = StrConv(wordarrayed2(o + 1), vbUpperCase)
wordarrayed(p) = wordarrayed2(o) & " " & wordarr
'wordarrayed(p).Characters
End If
'newtext = wordarrayed(p)
Cell.Characters(Start:=InStr(Cell.Value, wordarrayed(p)), Length:=Len(wordarrayed(p))).Font.Color = orgnal
Next p
modcelled = Application.WorksheetFunction.TextJoin(",", True, wordarrayed)

Range("h" & t).Value = modcelled
if Arun a is yellow
kmaal k is red
Jack js is saffron

then it should display Arun A, Kmaal K, Jack JS in the same color each word mentioned above however below code is showing all in same color
 
Upvote 0

Forum statistics

Threads
1,224,787
Messages
6,180,950
Members
453,008
Latest member
GRTMAN

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top