VBA Code to Operate on a Specific Selected Cell

R

RSBrunton

I would like to be able to 'toggle' the font color of a selected cell (not
the entire task) between two colors. The cell being selected could be
different for any given time that the code is to run.

I have investigated the use of ActiveCell, which identifies the 'row' in the
schedule, but not the specific cell (i.e. field) that is active.

Question: Is it possible to programmatically determine what specific cell is
selected?

Extended Question: When multiple cells are selected, how to cycle through
all selected cells.
 
J

John

RSBrunton said:
I would like to be able to 'toggle' the font color of a selected cell (not
the entire task) between two colors. The cell being selected could be
different for any given time that the code is to run.

I have investigated the use of ActiveCell, which identifies the 'row' in the
schedule, but not the specific cell (i.e. field) that is active.

Question: Is it possible to programmatically determine what specific cell is
selected?

Extended Question: When multiple cells are selected, how to cycle through
all selected cells.

RSBrunton,
Well it's very easy to set the color of any single or group of selected
field cells, but toggling is not quite so simple. That's because the
Project object model does not provide for any means to read the current
font color. However, not to thwarted, you could use the following code:

Sub FontToggle()
Dim t As Task
For Each t In ActiveSelection.Tasks
If t.Flag1 = True Then
Font Color:=pjRed
t.Flag1 = False
Else
Font Color:=pjGreen
t.Flag1 = True
End If
Next t
End Sub

However, I've got to question if it really makes sense to use VBA for
something that is very easy to do manually. After all, the user will
need to select the field cell or group of cells anyway. Setting the font
color is just a menu item away.

Nonetheless, hope this helps.
John
Project MVP
 
M

Mike Glen

Hi ,

Try posting on the developer newsgroup. Please see FAQ Item: 24. Project
Newsgroups. FAQs, companion products and other useful Project information
can be seen at this web address: http://project.mvps.org/faqs.htm

Mike Glen
Project 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