PDA

View Full Version : New to VBA - Please Help!



VickyC
02-28-2006, 03:30 AM
Good Morning,

I am fairly new to VBA and am having problems with finding the correct code information.

I have a table and in the 4th Row I need to look up and see if in column 2 is = to 0.00 to delete the entire row.

Is anybody able to help me?:help

Many thanks in advance.

Vicky

Jacob Hilderbrand
02-28-2006, 09:09 AM
Try this macro:


Option Explicit

Sub Macro1()

Dim CheckVal As String

'Get the value of the cell
CheckVal = ActiveDocument.Tables(1).Cell(4, 2).Range.Text

'Remove the two hidden table characters
CheckVal = Left(CheckVal, Len(CheckVal) - 2)

'Delete the row if needed
If CheckVal = "0.00" Then
ActiveDocument.Tables(1).Rows(4).Delete
End If

End Sub

VickyC
02-28-2006, 10:05 AM
Thank you so much, that works perfectly.

I really appreciate your help. :clap:

Vicky