batch editing a document

  • Thread starter Thread starter shem
  • Start date Start date
S

shem

does anyone know how to bold a document on alternate lines? for example if i
have 10 lines, and i want the odd number lines batch bolded while even
numbers remain the same, is there a formula i can use in either word or
excel? any help or idea would be appreciated?
 
Sub boldit()
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
For i = 1 To nLastRow Step 2
Cells(i, 1).EntireRow.Font.Bold = True
Next
End Sub
 
Hi,

You can do this without VBA by using conditional formatting. Assuming you
are using 2003 or earlier this would do it:

1. Select the range you want formatted.
2. Choose Format, Conditional Formatting
3. From the first drop down choose Formula is
4. In the next box enter =MOD(ROW(),2)
5. Click the Format button and on the Font tab choose Bold (or whatever)

The above formula bolds all Odd numbered rows, to do Even numbered rows use
=MOD(ROW(),2)=0

In 2007:
1. Select the range
2. Choose Home, Conditional Formatting, New Rule
3. Choose Use a formula to determine which cell to format
4. In the Format values where this formula is true box enter the same
formulas as above
5. Click the Format button and on the Font tab choose Bold (or whatever)


Cheers,
Shane Devenshire
Microsoft Excel MVP
 
Adding to Shane's suggestion.

=MOD(SUBTOTAL(3,$A1:$A$2),2)=0

Will survive filtering while the =MOD(ROW(),2) will not.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top