+ Reply to Thread
Results 1 to 6 of 6

Find and Format Macro

  1. #1
    Registered User
    Join Date
    02-17-2012
    Location
    Birmingham, AL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Find and Format Macro

    I am trying to create a macro that searches my spreadsheet for anything between parentheses and changes text size by -1 (or to 12...whichever). I have tried several scripts but cannot get anything to work. All of my parentheses are in one column, but they are not the only text in the column [eg. John Smith (abc123)]. I need to reduce (abc123) down one text size to 12. This script also needs to find all instances and apply to all. I am somewhat new to macros but am finding that they make me so much more productive. Any help would be greatly appreciated.

  2. #2
    Registered User
    Join Date
    02-17-2012
    Location
    Birmingham, AL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Find and Format Macro

    This is what I have so far...even though it gives me an error on the With .Selection line.

    Sub FindSpecial()
    ' Keyboard Shortcut: Ctrl+Shift+Q
    With .Selection
    With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "\(*\)"
    .Replacement.Text = "^&"
    .Replacement.Font.Size = 12
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
    End With
    End With
    End Sub
    I can't get past the compile error at the With .Selection line to see if this actually does what I want. I'm thinking that the replacement text still needs to be "\(*\)" . Is this correct? Like I said, I am very new to this but am trying to learn.

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Find and Format Macro

    hi dbutler85, can you post sample file with original data and data you need to obtain as a result (5-10 rows will be enough)?

  4. #4
    Registered User
    Join Date
    02-17-2012
    Location
    Birmingham, AL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Find and Format Macro

    I'm sorry, I can't. It contains private medical information. But I can give an example.

    Date Last, First (MRN1234) Med Info
    Date Last, First (ABC4321) Med Info
    Date2 Last Name, First (BFR0492) Med Info

    I want to take what is in parenthesis and format the font to be one size smaller. The problem that I am having is that a macro isn't editing just part of the cell, it is applying the change to the entire cell. Is this enough info?

  5. #5
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Find and Format Macro

    I think this code will do what you want...

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-17-2012
    Location
    Birmingham, AL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Find and Format Macro

    Thank you Chance. That works. I changed "Sheet2.Range" to "ActiveSheet.Range" in both places and it works perfectly. Thank you so much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1