word 03 tables format

M

mikenam

Hello everyone. I have several tables in a document and would like to
bold the rows that have text in the second column. If the second column
has numbers (ie 610-8444) then i don't want to bold the row.

This is my start. I am having trouble identifying the row and second
column to use it in a conditional statement.

Dim oTb As Table
'i is the second row of the table
'f is the last row of the table
Dim i As Integer
Dim f As Integer
Dim r As Integer

'do for each table
For Each oTb In ActiveDocument.Tables

'counts the number of rows
f = oTb.Rows.Count

'if there are 7 columns then format the table
If oTb.Columns.Count = 7 Then
'first row till last row
For i = 2 To f
If oTb.Rows(i).Columns(2).IsNumeric = False Then



End If
Next i
End If


Next
End Sub



Thanks
 
D

Doug Robbins - Word MVP

Use the following

Dim i As Long, j as long
Dim crange As Range
For j = 1 to ActiveDocument.Tables.Count
With ActiveDocument.Tables(j)
If .Columns.Count = 7 then
For i = 2 To .rows.Count
Set crange = .Cell(i, 2).Range
crange.End = crange.End - 1
If Not IsNumeric(crange.Text) Then
.rows(i).Range.Font.Bold = True
End If
Next i
End If
End With
Next j


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
M

mikenam

Thanks,

How would i convert to currency?

formatcurrency(oTb.Cell(i, z).Range, 2) < that isn't working
 
D

Doug Robbins - Word MVP

Replace the $ with whatever currency symbol you want to use.

Dim i As Long, j As Long
Dim crange As Range
For j = 1 To ActiveDocument.Tables.Count
With ActiveDocument.Tables(j)
If .Columns.Count = 7 Then
For i = 2 To .rows.Count
Set crange = .Cell(i, 2).Range
crange.End = crange.End - 1
If Not IsNumeric(crange.Text) Then
.rows(i).Range.Font.Bold = True
Else
crange.Text = Format(crange.Text, "$#,###.00")
End If
Next i
End If
End With
Next j


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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

Top