|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Code to clear data where there are numbers and data to the right of the numbers
I have a word document and need all the data containing a number and the text to the right of the number to be cleared e.g 1) 2)
|
#2
|
|||
|
|||
Your sample document contains of unrelated lists e.g., A) and 1) are not related. 1) is not the second level of A). So if you stick with that arrangement, you will need something like:
Code:
Sub ClearNumberedList() Dim para As Paragraph For Each para In ActiveDocument.Paragraphs If para.Range.ListFormat.ListType = wdListSimpleNumbering Then If IsNumeric(Left(para.Range.ListFormat.ListString, 1)) And Right(para.Range.ListFormat.ListString, 1) = ")" Then para.Range.Delete End If End If Next para End Sub If you used related lists, it would be as simple as: Code:
Sub ScratchMacro() 'A basic Word Macro coded by Gregory K. Maxey Dim oPar As Paragraph For Each oPar In ActiveDocument.Range.Paragraphs If oPar.Range.ListFormat.ListLevelNumber = 2 Then oPar.Range.Delete End If Next lbl_Exit: Exit Sub End Sub |
#3
|
|||
|
|||
Many Thanks Greg for the help
Your first solution worked perfectly |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Assigning numbers to every group in a set of data | Marcia | Excel | 5 | 03-30-2021 12:37 AM |
How to optimize the data summation code for each row and column in a data rectangle area? | leeqiang | Excel Programming | 5 | 10-04-2020 06:53 PM |
Clear data from unlocked cells | wpryan | Excel Programming | 5 | 02-25-2016 10:51 PM |
Macro to recap data of same numbers | Jasa P | Word VBA | 0 | 06-28-2012 02:41 AM |
How to Insert a Clear, Blank page without Lines and Numbers in a Pleading Document | Dirigo | Word | 5 | 09-30-2011 08:08 AM |