|
-
Apr 13th, 2005, 02:08 PM
#1
Thread Starter
New Member
help for a highlighter
this is one of my first brush ups with VBA(and excel, for that matter), so I don't know much about the language.
nycase, I'm supposed to write a macro that will check the text in a certain cell to see if there are any specific words(which I define), and turn them Red.
I've thought of a way to do this, but I need to be able to define which a place within a cell. ex. if <> is a cell, then <Hello world, how are you today> I would need to say "from space 6 onwards check if...., then from space 13 onwards, check if....." etc.
can anyone explain how to do this? thanks alot.
if you know a good way of making this macro, please tell me that as well ^_~
-
Apr 13th, 2005, 02:19 PM
#2
Re: help for a highlighter
Welcome to the Forums.
So this will only check one cell, correct?
Usually the easiest way to determine how to access something programmatically, you record a macro
doing your task, stop it and check the generated code in the VBA IDE.
Now, since your needing to do some searching in the cell before you do anything, it would be easier to just
record a macro changing the cells backcolor. Then we can use that as astarting place.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 13th, 2005, 06:29 PM
#3
Re: help for a highlighter
This should get you started. It highlights the word "World!" in cell C6.
VB Code:
Private Sub HighLightMe()
'C6 contains "Hello World!" and highlights "World!"
Dim iStart As Integer
ActiveSheet.Range("C6").Select
iStart = InStr(1, ActiveCell.Value, "World!")
If iStart > 0 Then
'Turn off coloring for any previous finds
Selection.Font.ColorIndex = xlAutomatic
'Turn on coloring for the found word (World!)
ActiveCell.Characters(Start:=iStart, Length:=iStart + Len("World!")).Font.ColorIndex = 3
End If
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|