![]() |
|
#1
|
|||
|
|||
|
Hello,
I am writing code to scan and selectively delete rows in tables in a word document and I need an if statement that determines if a cell contains a 0 value. The cell may contain 0, 0.0, .0 and so it needs to look at the value and not the text. Is this possible? Thank you for the help. |
|
#2
|
||||
|
||||
|
You don't say which column the 0 values are in. The following macro processes all tables in the document, deleting those rows that have 0 values in column 2. You can change to column reference to suit your needs.
Code:
Sub DeleteTable0Rows()
Dim Tbl As Table, i As Long, Rng As Range
With ActiveDocument
For Each Tbl In .Tables
With Tbl
For i = .Rows.Count To 1 Step -1
Set Rng = .Cell(Row:=1, Columns:=2)
With Rng
.End = .End - 1
If .Text = "0" Or .Text = "0.0" Or .Text = ".0" Then .Rows(1).Delete
End With
Next
End With
Next
End With
Set Rng = Nothing: Set Tbl = Nothing
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| cell value, if statement, read cell |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| determine location of object via calculation | sarahtalbot | Visio | 0 | 01-08-2015 03:27 AM |
| Determine if a shape is selected | Byron Polk | Word VBA | 2 | 08-06-2014 02:26 AM |
Determine Visio 2010 version
|
bbelko | Misc | 1 | 10-24-2013 08:40 AM |
* Determine Capitalization
|
djreyrey | Excel | 8 | 05-03-2011 02:03 PM |
Determine age by using birthdate
|
gdodson | Excel | 1 | 08-11-2006 09:27 PM |