I am very new to VBA, so any help is much appreciated.
I am trying to build a macro that accomplishes the following:
When run a user form opens
The user form asks users to categorize different topics as "Applicable" or "Not Applicable"
Once each topic is categorized, the macro will move all "Not Applicable" topics to the "Not Applicable" section in the document
Cateogrization would be "Applicable" by default
Each topic is set as its own bookmark. I'm stuck on the For each / next portion of the code. I have this so far:
Sub CleanUp()
Dim doc As Document
Dim book As Bookmark
For Each book In ActiveDocument.Range.Bookmarks
If book = "Applicable" Then
Selection.GoTo what;= wdgotobookmark, which:= book
Selection.Cut
Selection.GoTo what:=wdGoToBookmark, Name:="PASTE_HERE"
Selection.PasteAndFormat (wdFormatOriginalFormatting)
Next book
end sub
Two initial questions:
How can I use the optionbutton to set a value for each topic? Can I even use a user form like this? There's about 50 topics, so I wasn't sure if I need to set a variable for each topic.
Private Sub OptionButton2_Click() Set book = "Applicable" End Sub
If I do need to create a variable for each topic/bookmark, is it better to loop with for/next? That way I can set the variable name equal to the counter? For example topic1, topic2, topic3, etc.?