Cell referencing

D

Doc60

I am trying to have code in a macro look at a particular row/column in a
table and determine if it is has nothing it to move to another part of the
code to continue the macro. Not sure how to do this. If you can help, please
be specific with instructions (code).

Thanks
 
H

Helmut Weber

Hi Doc60,

just to get you started:

Sub Test40089()
With ActiveDocument.Tables(1)
If Len(.Cell(2, 2).Range) = 2 Then
MsgBox "Empty"
' what now
End If
End With
End Sub

If a cell's range has a length of 2,
then it consists of nothing but the end-of-cell mark,
which is chr(13) & chr(7).



--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
D

Doc60

I don't think this is what I am looking for. I want to do something like this,

If Cell 5,7 is " " then goto... meaning another part of the code to
continue.

So what I am trying to do is have the macro look at a cell determine if
there is a number in it, if not move to another part of the code to continue
the macro.

Thank you
 
H

Helmut Weber

Hi Doc60,

maybe something along these lines:

Sub Macro2()
Dim oTbl As Table
Dim sTmp As String
Set oTbl = ActiveDocument.Tables(1)
With oTbl
sTmp = .Cell(2, 2).Range.Text
sTmp = Left(sTmp, Len(sTmp) - 2)
If IsNumeric(sTmp) Then
MsgBox "number"
' your code
Else
' do nothing or whatever
End If
End With
End Sub

Though numbers aren't just digits,
e.g "2E3" is numeric!

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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