Dropdown selection changes the colour of the cell or deletes a row

B

boredofcities

I have a table that contains a dropdown list with 5 selections. The 1st
selection is a blank " ", 2nd "Phase 1", 3rd "Phase 2", 4th "Phase 3" and 5th
"N/A". When either of the first four options are selected, I would like the
cell that the dropdown box is in to change colour reflecting on the decision.
I could do with using the RGB colour scale if possible, but if the N/A is
selected then I need the row in the table to be deleted. There are 46 rows in
the table which need to contain one of these dropdown lists with the same
options.

Is what I'm asking even possible and if so where do I start?

Thanks in advance for the help

Matt
 
J

Jean-Guy Marcil

boredofcities was telling us:
boredofcities nous racontait que :
I have a table that contains a dropdown list with 5 selections. The
1st selection is a blank " ", 2nd "Phase 1", 3rd "Phase 2", 4th
"Phase 3" and 5th "N/A". When either of the first four options are
selected, I would like the cell that the dropdown box is in to change
colour reflecting on the decision. I could do with using the RGB
colour scale if possible, but if the N/A is selected then I need the
row in the table to be deleted. There are 46 rows in the table which
need to contain one of these dropdown lists with the same options.

Is what I'm asking even possible and if so where do I start?

Yes.

However, a few questions first:

What types of dropdown are we talking about?
How did you insert them in your document?
What Word version?
 
B

boredofcities

Jean-Guy, in response to your above questions;

The dropdown lists are the drop-down form fields inserted with the forms
tools bar in word. I originally chose these because of the option to run a
macro on entry or exit of the dropdown list via the properties, but I had no
joy with that.

The version of word I am using is 2000, but I do have access to 2003 and
2007 though other computers that aren't mine. If it is easier to use either
of the later editions of word I can make arrangements to use which every you
may recommend.

Thanks for your response Jean-Guy and I hope the information I provided is
what you require.

Matt
 
J

Jean-Guy Marcil

boredofcities was telling us:
boredofcities nous racontait que :
Jean-Guy, in response to your above questions;

The dropdown lists are the drop-down form fields inserted with the
forms tools bar in word. I originally chose these because of the
option to run a macro on entry or exit of the dropdown list via the
properties, but I had no joy with that.

The version of word I am using is 2000, but I do have access to 2003
and 2007 though other computers that aren't mine. If it is easier to
use either of the later editions of word I can make arrangements to
use which every you may recommend.

Thanks for your response Jean-Guy and I hope the information I
provided is what you require.

And, just to make sure we are on the same page, you are aware that by using
those formfields you have to lock your document for forms, which will reduce
the accessibility to many features, right?
I mean, you do want to create a locked form, right?
 
B

boredofcities

Yes, it is a locked form that I'm creating. I have already inserted text
form fields that duplicate the information inserted into them, into other
form fields contained in the document. There are other text form fields that
calulate all the values in a table to give a total, as well as a percentage.

I would like to keep the original structure if possible. I know I can
protect certain sections of the document so I could leave this Section
unprotected (Section 3), but if it is making my goal difficult then I suppose
I will just have to change it.
 
J

Jean-Guy Marcil

boredofcities was telling us:
boredofcities nous racontait que :
Yes, it is a locked form that I'm creating. I have already inserted
text form fields that duplicate the information inserted into them,
into other form fields contained in the document. There are other
text form fields that calulate all the values in a table to give a
total, as well as a percentage.

I would like to keep the original structure if possible. I know I can
protect certain sections of the document so I could leave this Section
unprotected (Section 3), but if it is making my goal difficult then I
suppose I will just have to change it.

OK, try this code in the Exit even of each dropdown formfield:

Sub DropDownCode()

Dim celTarget As Cell

With Selection.FormFields(1)
Set celTarget = .Range.Cells(1)
ActiveDocument.Unprotect
Select Case .DropDown.Value
Case "1"
celTarget.Shading.BackgroundPatternColor = wdColorWhite
Case "2"
celTarget.Shading.BackgroundPatternColor = wdColorBlue
Case "3"
celTarget.Shading.BackgroundPatternColor = wdColorRed
Case "4"
celTarget.Shading.BackgroundPatternColor = wdColorOrange
Case "5"
celTarget.Range.Rows(1).Delete
End Select
ActiveDocument.Protect wdAllowOnlyFormFields, True
End With

End Sub
 
B

boredofcities

That has worked like a treat, it's just what I wanted. Thanks for you time
and help Jean-Guy.
 

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