Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2015, 10:45 PM
FredSmith99 FredSmith99 is offline Increment numbering: But in the order they are inserted Windows 7 32bit Increment numbering: But in the order they are inserted Office 2007
Novice
Increment numbering: But in the order they are inserted
 
Join Date: Oct 2015
Posts: 3
FredSmith99 is on a distinguished road
Default

Hi Paul,
thank you for your code. It looks very good and has similarities to the way I have finally chosen (we worked in parallel): My data are identified by a prefix "D#", so
- in a first loop I determine the maximum ID that is available in the document,
- then those data that do not yet have an ID are assigned with one in Loop 2
Thanks for the feedback,
Fred


Here my approach:
Code:
 
Sub AddDataID()
NumberOfData = 0
DataMaxID = 0
AllDataHaveID = True
With Selection 'Look for D# in the document and determine the maximum ID that was already assigned
    .HomeKey Unit:=wdStory
    With .Find
        .Text = "D#??????"
        .Forward = True
        .MatchWildcards = True
    End With
    Do While .Find.Execute 'Loop 1: Determine the maximum ID
        NumberOfData = NumberOfData + 1
        FirstSpace = InStr(1, Selection, " ") 'Per definition there is a " " after the ID
        DataNumberFound = Val(Mid(Selection, 3, FirstSpace - 3))
        If DataNumberFound = 0 Then AllDataHaveID = False 'Not all requirements have an ID yet
        If DataNumberFound > DataMaxID Then DataMaxID = DataNumberFound
    Loop
End With
'Then loop 2 to assign those data that do not have an ID yet an ID starting from DataMaxID
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Increment numbering: But in the order they are inserted Loop - Row increment jrt Excel Programming 1 04-16-2015 01:46 PM
Increment Numbers Darbsp Word 3 03-10-2015 05:25 AM
Increment numbering: But in the order they are inserted List Style Numbering picks up out of order number from LATER list spthomas Word 12 12-16-2013 05:23 PM
Increment numbering: But in the order they are inserted Word Heading Bullet Numbering increment SASE1984 Word 1 02-10-2012 01:06 PM
Increment Numbers Help Jazz43 Word 2 07-30-2010 02:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:37 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