MS Word VBA to delete empty lines -
i new vba macros have word 2016 template , has following sections:
base amount: $ service fee: $ sales tax % $ other tax %: $ tax 2 %: $
my goal if amount missing of lines, delete line. tried recording macro , making changes no luck.
updated: below modified version of code spin thru rows of table (in ms-word) , delete every row contains '$' in column 3 , column 4 empty.
option explicit ' subroutine spin thru rows of data in table in ms-word (except first row, header). ' if column 3 contains '$' , column 4 empty, row deleted. ' rows '$' in column 3 , empty cell 4 deleted. sub test() dim long 'dim char string selection.tables(1) = .rows.count 1 step -1 'char = .cell(i, 3).range.text 'debug.print asc(mid(char, 1, 1)) & vbtab & asc(mid(char, 2, 1)) '& vbtab & asc(mid(char, 3, 1)) 'debug.print ">" & .cell(i, 2).range.text & "<" if len(.cell(i, 4).range.text) = 2 , left(.cell(i, 3).range.text, 1) = "$" .rows(i).delete end if next end end sub
Comments
Post a Comment