VBA code for drop down menu problem.

R

Roger Govier

Hi

Remove Data Validation from column C and F on Sheet APP Groups
Use the following formula in cell C3
=IF(B3="","",VLOOKUP(B3,'APP Sheets'!C:D,2,0))

Copy as appropriate to other cells as required.

--
Regards
Roger Govier

mj_bowen said:
Hi,

Basically if any of the names is selected in any of the drop down cells,
then the score that is next to that cell eg, 1a,2b, 3c, 4c is shown next
to
the appropriate name in the APP sheets tab!

I have attached a copy of the worbook;
http://www.box.net/shared/hxr0isxpfi

I've tried all sorts but can't seem make it work!

Matt

This thread is also posted on
http://www.mrexcel.com/forum/showthread.php?p=2202650&posted=1#post2202650

__________ Information from ESET Smart Security, version of virus
signature database 4832 (20100203) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4832 (20100203) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
M

mj_bowen

Hi Roger,

Thank you for the message, however, I need the drop down menu in the cells
in column C and F on 'Sheet APP' groups. It is the data in APP groups that is
entered into APP sheets!

For example if Bernie is in 'Group one' on the APP group tab
his score may be 2a (which is fed into cell D15 on the APP sheet tab). The
next day he may be in Group 3 and have the score of 1a, which updates onto
cell D15 on the APP sheet tab.

this would also apply to the other names in the file!

Any advice would be warmly welcomed!

Here is an updated version!
http://www.box.net/shared/hxr0isxpfi

regards,
Matt
 
R

Roger Govier

Hi Matt

I had not even looked to see if there was any VBA in the workbook - I was
just giving a formula solution.
I have uploaded a new version of the book with revised event code at
http://www.box.net/shared/iuudnyqz1g

The revised code is
Private Sub Worksheet_Change(ByVal Target As Range)
Dim name As String, group As String
Dim wsg As Worksheet, wss As Worksheet, tr As Long, tc As Long

Set wsg = ThisWorkbook.Sheets("APP Groups")
Set wss = ThisWorkbook.Sheets("APP Sheets")
tc = Target.Column

Select Case tc

Case 2, 5

If Not Intersect(Target, Range("names_range")) Is Nothing Then
name = Target.Value
Application.EnableEvents = False

If WorksheetFunction.CountIf(Range("B3:E5"), name) > 1 Then
MsgBox "You have entered name " & name & " more than once"
Target.Value = ""
GoTo exit_Sub
End If

End If
GoTo exit_Sub

Case 3, 6

If Not Intersect(Target, Range("names_range").Offset(0, 1)) Is
Nothing Then
name = Target.Offset(0, -1)
Application.EnableEvents = False
name = Target.Offset(0, -1)
group = Target.Value
On Error Resume Next
tr = Application.Match(name, wss.Range("C:C"), 0)
On Error GoTo 0
If tr > 0 Then
wss.Cells(tr, "D") = group
Else
tr = wss.Cells(Rows.Count, 3).End(xlUp).Row + 2
wss.Cells(tr, "C") = name
wss.Cells(tr, "D") = group
End If
End If

Case Else
End Select
exit_Sub:
Application.EnableEvents = True
End Sub

The reason why you had to select a name again, before their group was
updating, was because you were only applying event code to the Name entry,
not the Group entry.
I created a new dynamic range range called Names in column A of APP Sheets
(hide the column if you wish, or move it elsewhere) so you can add any
number of new Names that you wish.

Equally, you can add those new names in column C and the code will enter a
group for them in column D.
If the new name has not been added in column C, then the code will generate
a new pair of entries 2 rows below your last entry on the sheet.


--
Regards
Roger Govier

mj_bowen said:
Hi Roger,

Thank you for the message, however, I need the drop down menu in the cells
in column C and F on 'Sheet APP' groups. It is the data in APP groups that
is
entered into APP sheets!

For example if Bernie is in 'Group one' on the APP group tab
his score may be 2a (which is fed into cell D15 on the APP sheet tab). The
next day he may be in Group 3 and have the score of 1a, which updates onto
cell D15 on the APP sheet tab.

this would also apply to the other names in the file!

Any advice would be warmly welcomed!

Here is an updated version!
http://www.box.net/shared/hxr0isxpfi

regards,
Matt



__________ Information from ESET Smart Security, version of virus
signature database 4833 (20100203) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4833 (20100203) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
T

Tiana Tozer

I'm trying to create dependent drop-downs with complex sentences so for example if in the first box someone choses Objective 3

Objective 3 - Concrete improvements in sectors


Then I want them to only be able to choose from the five sub-objectives that belong to Objective 3.

3.1 Improved health services
3.2 Improved WASH service and infrastructure
3.3 Improved access to sanitation services
3.4 Improved education services and infrastructure
3.5 Improved livelihood opportunities

Then I want them to have program component selections based on the sub-objective they choose. I can do it if I just limit my entries to one-word, but I would like to have sentences for more clarity.

Any suggestions?

Sincerely,

Tiana Tozer




mj_bowen wrote:

VBA code for drop down menu problem.
03-Feb-10

Hi

Basically if any of the names is selected in any of the drop down cells
then the score that is next to that cell eg, 1a,2b, 3c, 4c is shown next t
the appropriate name in the APP sheets tab

I have attached a copy of the worbook
http://www.box.net/shared/hxr0isxpf

I have tried all sorts but cannot seem make it work

Mat

This thread is also posted o
http://www.mrexcel.com/forum/showthread.php?p=2202650&posted=1#post2202650

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Image2HTML Image to HTML Conversion Reloaded
http://www.eggheadcafe.com/tutorial...aa-3582341d35bb/image2html-image-to-html.aspx
 
M

mj_bowen

Dear Roger,

Thank you for your help...it works really well..I'm going to try and adapt
the code and apply it to my assessment file!

Thanks again,

Matt Bowen - Infant teacher, UK
 

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