Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions, OSR, & D&D Variants
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions, OSR, & D&D Variants
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Upgrade your account to a Community Supporter account and remove most of the site ads.
Community
General Tabletop Discussion
*Geek Talk & Media
Microsoft Excel VBA Questions
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="RedAnt84" data-source="post: 5107846" data-attributes="member: 88446"><p>I wouldn't say I have "working knowledge" of VBA, but I've coded a couple of personal projects in it. Currently I'm working on a parsing/printing Java program that involves 4e statblocks.</p><p></p><p>The main function you're looking for is StrComp(string1, string2). You have to match the strings exactly. It returns 0 if they equal, or -1/1 if they're not (depends on if one comes after/before the other)</p><p></p><p>Basically, you'll want to grab the powers, split them by the newline character (vbCrLf), run through each power, and check to see if it starts with a power type. Then you'll bold that line in the comments. This is my first time working with comments, so hope it works.</p><p></p><p>References:</p><p></p><p><a href="http://www.freevbcode.com/ShowCode.Asp?ID=2856" target="_blank">Check if a String Starts or Ends With a Given Set of Characters</a></p><p><a href="http://www.contextures.com/xlcomments03.html" target="_blank">Excel Comments VBA</a> (for the comments and bolding part)</p><p></p><p>Here's my test code. Enter 'a', 'r', or 'm' to get a bold line:</p><p></p><p> [code]Dim cmt As Comment</p><p> Dim startsWith As Boolean</p><p> Dim toCompare As String</p><p> Dim originalString As String</p><p> </p><p> originalString = "a Power" & vbCrLf & "r Power" & vbCrLf & "m Power"</p><p></p><p> toCompare = InputBox("Compare your text to: " & vbCrLf & originalString)</p><p></p><p> Dim powerSplit() As String</p><p> powerSplit = Split(originalString, vbCrLf)</p><p> Dim power As Variant</p><p> </p><p> Set cmt = ActiveCell.Comment</p><p> If cmt Is Nothing Then</p><p> ActiveCell.AddComment _</p><p> Text:=originalString</p><p> Set cmt = ActiveCell.Comment</p><p> End If</p><p> </p><p> For Each power In powerSplit</p><p> startsWith = False</p><p> If (Len(toCompare) <= Len(power)) Then</p><p> startsWith = StrComp(toCompare, Left(power, Len(toCompare))) = 0</p><p> 'format the lines of text</p><p> If (startsWith) Then</p><p> cmt.Shape.TextFrame.Characters(InStr(1, originalString, power), Len(power)).Font.Bold = True</p><p> End If</p><p> End If</p><p> </p><p> </p><p> Next power[/code]Instead of the InputBox, you'll check to see if each power starts with an a, c, m, or r, followed by a space</p><p></p><p>I don't have Monster Tools available, but the things I've had to watch out for concerning powers (from pdfs) are: capital/lower cases, power names not getting correctly copied over ("aPower" instead of "a Power"), and when power types equal "none" (e.g. Goblin Tactics)</p><p></p><p>Hope this helps. First comment, ho! <img src="https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f642.png" class="smilie smilie--emoji" loading="lazy" width="64" height="64" alt=":)" title="Smile :)" data-smilie="1"data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="RedAnt84, post: 5107846, member: 88446"] I wouldn't say I have "working knowledge" of VBA, but I've coded a couple of personal projects in it. Currently I'm working on a parsing/printing Java program that involves 4e statblocks. The main function you're looking for is StrComp(string1, string2). You have to match the strings exactly. It returns 0 if they equal, or -1/1 if they're not (depends on if one comes after/before the other) Basically, you'll want to grab the powers, split them by the newline character (vbCrLf), run through each power, and check to see if it starts with a power type. Then you'll bold that line in the comments. This is my first time working with comments, so hope it works. References: [URL="http://www.freevbcode.com/ShowCode.Asp?ID=2856"]Check if a String Starts or Ends With a Given Set of Characters[/URL] [URL="http://www.contextures.com/xlcomments03.html"]Excel Comments VBA[/URL] (for the comments and bolding part) Here's my test code. Enter 'a', 'r', or 'm' to get a bold line: [code]Dim cmt As Comment Dim startsWith As Boolean Dim toCompare As String Dim originalString As String originalString = "a Power" & vbCrLf & "r Power" & vbCrLf & "m Power" toCompare = InputBox("Compare your text to: " & vbCrLf & originalString) Dim powerSplit() As String powerSplit = Split(originalString, vbCrLf) Dim power As Variant Set cmt = ActiveCell.Comment If cmt Is Nothing Then ActiveCell.AddComment _ Text:=originalString Set cmt = ActiveCell.Comment End If For Each power In powerSplit startsWith = False If (Len(toCompare) <= Len(power)) Then startsWith = StrComp(toCompare, Left(power, Len(toCompare))) = 0 'format the lines of text If (startsWith) Then cmt.Shape.TextFrame.Characters(InStr(1, originalString, power), Len(power)).Font.Bold = True End If End If Next power[/code]Instead of the InputBox, you'll check to see if each power starts with an a, c, m, or r, followed by a space I don't have Monster Tools available, but the things I've had to watch out for concerning powers (from pdfs) are: capital/lower cases, power names not getting correctly copied over ("aPower" instead of "a Power"), and when power types equal "none" (e.g. Goblin Tactics) Hope this helps. First comment, ho! :) [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Geek Talk & Media
Microsoft Excel VBA Questions
Top