Find First Clear Cell in a Word Table

N

norm

Hi,

In a workbook I have a table with two columns and 366 rows. The firs
column is filled with dates, one for each day of the year. The secon
column has diary entries.
Can somebody please help me with a macro which, after I open the wor
book each day, will allow me to click a button, say, and go directly t
the first clear cell in the second column of the table. At present
am scrolling, scrolling and it gets more tedious as the yea
progresses!
All help will be gratefully appreciated.
sincerely,
nor
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

What is the format of the dates? Assuming that you want to go to the row
for the current date (or at least very near it) it may be easier to use a
macro that finds the current date and then selects the cell on that row in
the adjacent column.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
N

norm

Hi Doug,

The format of the dates in my first column is:
Wednesday, March 03, 2004
and so on.
Finding the current date and moving across one cell would work. Ho
does a macro to do that look. I will need some help with it.

Sincerely
nor
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Use

Dim myrange As Range, today As String
today = Format(Date, "dddd, MMMM dd, yyyy")
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=today, MatchWildcards:=False,
Wrap:=wdFindStop, Forward:=True) = True
Set myrange = Selection.Range
myrange.End = myrange.End + 1
myrange.Collapse wdCollapseEnd
myrange.Select
Loop
End With


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
N

norm

Hi Doug,

I made a simple table in Word consisting of two columns and a few rows
I filled the first column with a series of sequential dates includin
today's date.
I then copied the script that you gave me into a macro as follows:

Sub Macro1()
'
' Macro recorded March 05, 2004
'

Dim myrange As Range, today As String
today = Format(Date, "dddd, MMMM dd, yyyy")
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=today, MatchWildcards:=False,
Wrap:=wdFindStop, Forward:=True) = True
Set myrange = Selection.Range
myrange.End = myrange.End + 1
myrange.Collapse wdCollapseEnd
myrange.Select
Loop
End With


End Sub

However, when I run the macro it reports a problem. A compile error
syntax error with the Do While line, the 11th line.
Can you help with this? Also, is the detail correct in the 7th lin
setting up the "today" variable.

Thank you for your assistance,
Nor
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

These two lines in the email message represent one single command, so you
need to get them back into a single line

Do While .Execute(FindText:=today, MatchWildcards:=False,
Wrap:=wdFindStop, Forward:=True) = True

The command in the seventh line will set the today variable to Saturday,
March 06, 2004, which I believe was the format that you indicated.
--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
N

norm

Hi Doug,

I've just had a relook at this macro and I now understand Line 7 an
can see how it works. I still have a problem trying to understand wh
there is a compile/ syntax error on the 11th Line? I hope you ca
help.

sincerely,
Nor
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Looks like you have not seen my response, probably because you are accessing
the newsgroups through Rubin's crappy website. You should either connect to
the newsgroups via the msnews.microsoft.com newserver or via the web
interface at

http://communities.microsoft.com/newsgroups/default.asp

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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