Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2016, 02:09 PM
bgranzow bgranzow is offline Determine if a cell contains a 0 value Windows 8 Determine if a cell contains a 0 value Office 2013
Novice
Determine if a cell contains a 0 value
 
Join Date: Jan 2014
Posts: 12
bgranzow is on a distinguished road
Default Determine if a cell contains a 0 value


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.
Reply With Quote
  #2  
Old 01-07-2016, 03:50 PM
macropod's Avatar
macropod macropod is offline Determine if a cell contains a 0 value Windows 7 64bit Determine if a cell contains a 0 value Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Tags
cell value, if statement, read cell

Thread Tools
Display Modes


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 if a cell contains a 0 value Determine Visio 2010 version bbelko Misc 1 10-24-2013 08:40 AM
Determine if a cell contains a 0 value * Determine Capitalization djreyrey Excel 8 05-03-2011 02:03 PM
Determine if a cell contains a 0 value Determine age by using birthdate gdodson Excel 1 08-11-2006 09:27 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft