Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-24-2014, 11:20 PM
macropod's Avatar
macropod macropod is offline Find max number of same subsequent character Windows 7 32bit Find max number of same subsequent character Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,523
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


How about:
Code:
Sub GetMaxSpaces()
Dim StrTxt As String, StrTmp As String, i As Long
StrTxt = ActiveDocument.Range.Text: StrTmp = " "
While InStr(StrTxt, StrTmp) > 0
    StrTmp = StrTmp & " "
    i = i + 1
Wend
MsgBox "The maximum space sequence is: " & i
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 05-24-2014, 11:31 PM
NobodysPerfect NobodysPerfect is offline Find max number of same subsequent character Windows 7 64bit Find max number of same subsequent character Office 2010 32bit
Competent Performer
Find max number of same subsequent character
 
Join Date: Jan 2014
Location: Germany
Posts: 136
NobodysPerfect is on a distinguished road
Default

Much faster .

Find, simply is the wrong approach.

You made my (Sun)day. Thx

NP
Reply With Quote
  #3  
Old 05-25-2014, 12:00 AM
NobodysPerfect NobodysPerfect is offline Find max number of same subsequent character Windows 7 64bit Find max number of same subsequent character Office 2010 32bit
Competent Performer
Find max number of same subsequent character
 
Join Date: Jan 2014
Location: Germany
Posts: 136
NobodysPerfect is on a distinguished road
Default

Quote:
You made my (Sun)day. Thx
Not yet ... the next problem to solve: I only want to count the blanks if the text is formatted in a specific style. Text formatted in any other style has to be ignored/skipped.

How can I ensure that only blanks are counted for text in "myCount" style within you super fast code. Maybe it's just too early for programming and my brain is still in sleep mode ...

Thanks again
NP
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find max number of same subsequent character Help!! find two number recurring numbers in row?? carrolld2 Excel 5 06-28-2014 05:43 PM
Find max number of same subsequent character macro to find a character and insert space so autocorrect will expand redzan Word VBA 3 05-22-2014 04:22 PM
Find max number of same subsequent character Help with the "find and replace" option; character problem martinn4 Word 3 02-20-2014 03:52 AM
Find max number of same subsequent character Conditional tied to trying to find a " " space character Dart82 Word VBA 3 10-04-2013 01:47 PM
Concatenated data in subsequent rows doorsgirl Excel 4 09-15-2011 10:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft