none
Delete cell contents RRS feed

  • Question

  • I have a Word table that has two cells. I want to delete the contents of cell 2 if cell 1 has a value between 1-5. I've not done anything like this before.

    Thanks in advance

    Tuesday, March 8, 2011 2:10 PM

Answers

  • Here is an example:

     

    Sub test()
      
      Dim objTable As Table
      Set objTable = ActiveDocument.Tables(1)
      
      strCellContents = Left(objTable.Cell(1, 1).Range.Text, _
        Len(objTable.Cell(1, 1).Range.Text) - 2)
      
      If IsNumeric(strCellContents) Then
    
        dblCellValue = CDbl(strCellContents)
        If dblCellValue > 1 And dblCellValue < 5 Then
          objTable.Cell(1, 2).Range.Text = ""
        End If
      
      End If
    
    End Sub
    

    Uros Calakovic
    Tuesday, March 8, 2011 8:15 PM