+ Reply to Thread
Results 1 to 9 of 9

macro freezing - too many words?

Hybrid View

  1. #1
    Registered User
    Join Date
    08-09-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2011
    Posts
    13

    macro freezing - too many words?

    Hello!

    I've been using a macro that will find certain words, enlarge them, and make them red so they're easy visible. I've used this for about 30 words and had no problems. I tried using the same macro, but with around 950 words and the editor just freezes and never runs the macro. Is there a workaround for this or are there just too many words?

    Thanks in advance!

    Oh, and here is a sample of the macro:

    Sub HighLight()
    Dim WS As Worksheet, c As Range
    Dim FindWord() As String
    Dim MyStart As Long, MyLength As Long
    ReDim FindWord(1 To 946)
    
    FindWord(1) = "feel" 'change to your preference
    FindWord(2) = "felt"
    FindWord(3) = "think "
    FindWord(4) = "thought"
    FindWord(5) = "ador"
    FindWord(6) = "afraid"
    FindWord(7) = "alright"
    FindWord(8) = "amazed"
    FindWord(9) = "anger"
    FindWord(10) = "appreciate"
    FindWord(11) = "argued"
    FindWord(12) = "awarded"
    FindWord(13) = "awkward"
    FindWord(14) = "bad"
    **up to 946**
    
    For Each WS In Worksheets
    For i = 1 To 946
    With WS.Cells
    Set c = .Find(FindWord(i), LookIn:=xlValues)
    If Not c Is Nothing Then
    firstAddress = c.Address
    Do
    MyStart = InStr(UCase(c.Value), UCase(FindWord(i)))
    MyLength = Len(FindWord(i))
    With c.Characters(Start:=MyStart, Length:=MyLength).Font
    .Size = 13
    .Color = -16776961
    End With
    'c.Interior.ColorIndex = 35 'now green, change to your preference
    Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
    End With
    Next
    Next
    
    End Sub
    Last edited by labmanager; 10-30-2013 at 03:50 PM.

  2. #2
    Forum Contributor
    Join Date
    05-10-2012
    Location
    Paris, France
    MS-Off Ver
    2016/365
    Posts
    123

    Re: macro freezing - too many words?

    Hi labmanager

    Idea : I put the words in a sheet and I will make a loop ;-)

    Try this code
    Sub HighLight()
      Dim WS As Worksheet, c As Range
      Dim FindWord() As String
      Dim MyStart As Long, MyLength As Long
      ReDim FindWord(1 To 946)
      ' I put the words in a sheet and I will make a loop ;-)
      FindWord(1) = "feel"  'change to your preference
      FindWord(2) = "felt"
      FindWord(3) = "think "
      FindWord(4) = "thought"
      FindWord(5) = "ador"
      FindWord(6) = "afraid"
      FindWord(7) = "alright"
      FindWord(8) = "amazed"
      FindWord(9) = "anger"
      FindWord(10) = "appreciate"
      FindWord(11) = "argued"
      FindWord(12) = "awarded"
      FindWord(13) = "awkward"
      FindWord(14) = "bad"
      **up to 946**
      ' Make manual calculation if they are formula
      Application.Calculation = xlCalculationManual
      ' Disable events
      Application.EnableEvents = False
      ' Hidde application
      Application.Visible = False
      
      For Each WS In Worksheets
        For i = 1 To 946
          With WS.Cells
            Set c = .Find(FindWord(i), LookIn:=xlValues)
            If Not c Is Nothing Then
              firstAddress = c.Address
              Do
                MyStart = InStr(UCase(c.Value), UCase(FindWord(i)))
                MyLength = Len(FindWord(i))
                With c.Characters(Start:=MyStart, Length:=MyLength).Font
                  .Size = 13
                  .Color = -16776961
                End With
                'c.Interior.ColorIndex = 35 'now green, change to your preference
                Set c = .FindNext(c)
              Loop While Not c Is Nothing And c.Address <> firstAddress
            End If
          End With
        Next
      Next
      ' Show application
      Application.Visible = True
      ' Make automatic calculation
      Application.Calculation = xlCalculationAutomatic
      ' Enable events
      Application.EnableEvents = True
    End Sub
    A+

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: macro freezing - too many words?

    Hi, labmanager,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    08-09-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2011
    Posts
    13

    Re: macro freezing - too many words?

    I have made the changes. Why can't I see the hidden response?

    Quote Originally Posted by HaHoBe View Post
    Hi, labmanager,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    08-09-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2011
    Posts
    13

    Re: macro freezing - too many words?

    I tried this, but unfortunately the program kept freezing and refused to run.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: macro freezing - too many words?

    try this,
    Hidden until the change

  7. #7
    Registered User
    Join Date
    08-09-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2011
    Posts
    13

    Re: macro freezing - too many words?

    i've made the change, but i still can't see this response.

  8. #8
    Registered User
    Join Date
    08-09-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2011
    Posts
    13

    Re: macro freezing - too many words?

    Sub HighLight()
    Dim WS As Worksheet, c As Range
    Dim FindWord() As String
    Dim MyStart As Long, MyLength As Long
    ReDim FindWord(1 To 946)
    
    FindWord(1) = "feel" 'change to your preference
    FindWord(2) = "felt"
    FindWord(3) = "think "
    FindWord(4) = "thought"
    FindWord(5) = "ador"
    FindWord(6) = "afraid"
    FindWord(7) = "alright"
    FindWord(8) = "amazed"
    FindWord(9) = "anger"
    FindWord(10) = "appreciate"
    FindWord(11) = "argued"
    FindWord(12) = "awarded"
    FindWord(13) = "awkward"
    FindWord(14) = "bad"
    **up to 946**
    
    For Each WS In Worksheets
    For i = 1 To 946
    With WS.Cells
    Set c = .Find(FindWord(i), LookIn:=xlValues)
    If Not c Is Nothing Then
    firstAddress = c.Address
    Do
    MyStart = InStr(UCase(c.Value), UCase(FindWord(i)))
    MyLength = Len(FindWord(i))
    With c.Characters(Start:=MyStart, Length:=MyLength).Font
    .Size = 13
    .Color = -16776961
    End With
    'c.Interior.ColorIndex = 35 'now green, change to your preference
    Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
    End With
    Next
    Next
    
    End Sub

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: macro freezing - too many words?

    Hello labmanager,

    If you are referring to jindon's post, there is no code. I assume the code was not posted beacuse of the infraction and the intent was to come back and add the code after you had added the code tags.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. personal macro workbook freezing
    By craigc3814 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-13-2012, 07:33 AM
  2. Macro Freezing during Copy procedure
    By jacob@thepenpoint in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-18-2012, 10:45 AM
  3. macro keeps freezing
    By theinexplicablefuzz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2011, 03:15 PM
  4. Macro freezing sheet on one pc
    By jsmity in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-03-2009, 08:21 AM
  5. Running Macro Is Freezing Workbook
    By inwalkedbud in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2007, 02:21 PM

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