Drop down boxes in VBA

Hi

I have two different drop down boxes on two different sheets. I want to make 
a macro that will automatically change the second drop down box when someone 
manually updates the first drop down box. I am currently using the code below 
but it only works for the first person ("Adrienne Zwarts"). Can anyone help 
me?

Sub Adviser()

Dim Adviser(2) As String
Dim i As Integer
Dim var

Adviser(0) = "Adrienne Zwarts"
Adviser(1) = "Andrew Cuttriss"
Adviser(2) = "Anna Tapp"

Sheets("Cover Letter").Select
If Range("D22") = Adviser(i) Then
    Sheets("Nov09").Select
    Selection.AutoFilter Field:=2, Criteria1:=Adviser(i)


End If

End Sub

P.S. I'm very new to this
0
Utf
1/11/2010 11:15:01 PM
excel.programming 6508 articles. 1 followers. Follow

1 Replies
1522 Views

Similar Articles

[PageSpeed] 54

Modify this:

If Range("D22") = Adviser(i) Then
    Sheets("Nov09").Select
    Selection.AutoFilter Field:=2, Criteria1:=Adviser(i)

End If

To this:

For i = 0 To 2
    If Range("D22") = Adviser(i) Then
         Sheets("Nov09").Select
         Selection.AutoFilter Field:=2, Criteria1:=Adviser(i)
    End If
Next

But it will still only match one of the three names.  Why don't you explain 
what you are trying to do and maybe someone can give you a solution that 
will use all three names.






"Haden" <Haden@discussions.microsoft.com> wrote in message 
news:A28B2FB4-6AD0-4CA2-AB5E-62027A801E26@microsoft.com...
> Hi
>
> I have two different drop down boxes on two different sheets. I want to 
> make
> a macro that will automatically change the second drop down box when 
> someone
> manually updates the first drop down box. I am currently using the code 
> below
> but it only works for the first person ("Adrienne Zwarts"). Can anyone 
> help
> me?
>
> Sub Adviser()
>
> Dim Adviser(2) As String
> Dim i As Integer
> Dim var
>
> Adviser(0) = "Adrienne Zwarts"
> Adviser(1) = "Andrew Cuttriss"
> Adviser(2) = "Anna Tapp"
>
> Sheets("Cover Letter").Select
> If Range("D22") = Adviser(i) Then
>    Sheets("Nov09").Select
>    Selection.AutoFilter Field:=2, Criteria1:=Adviser(i)
>
>
> End If
>
> End Sub
>
> P.S. I'm very new to this 


0
JLGWhiz
1/11/2010 11:41:24 PM
Reply:

Similar Artilces:

VBA
Please Help Me... How can I use DoCmd.RunCommand acCmdExport to export a Predetermined list of tables from one MDB file to a the another MDB file without prompting the user for a file name or location and to allow automatic replacement of existing tables??? I have created a button and started the VBA so that the data can be archived on an as needed basis, but I can't figure out exactly how to pass the parameters to the command that I am trying to use. Thank you... Hi You can use import or export - it's almost the same. have a look at an answer I gave a while ago http://...

drag and drop
Using office XP I cannot drag and drop items from one folder to another in outlook 2002. Any ideas? Thanks ...

Combo Box Problem
Hi friends can anyone tell me how i can add a string to combo box runtime . i have used one editbox and one combo box in my program. i need to insert string of edit box in combo box when user clicks on button. i have tried to used getdlgitem method but i was failed then i try to use member variable of combobox "CComboBox m_c;" and try to add string by m_c.AddString(m_e) [m_e is member variable of textbox]but it didnt work so plz tell me how i can here is my program UpdateData(1); m_c.AddString(m_e); but it didn't work then i try getdlgitem UpdateData(1); CComboBox *c...

Drop Down List #9
I am trying to create a drop down list using two worksheets. How would I create this. One sheet would where the final product is and the other would be where the data is being kept. Watch this 5 min video: How to setup a data validation drop down list: http://youtube.com/watch?v=t2OsWJijrOM -- Biff Microsoft Excel MVP "Vincent Kerzman" <Vincent Kerzman@discussions.microsoft.com> wrote in message news:B2DAA48B-0BD2-4932-AE91-B86D55B8D8A6@microsoft.com... >I am trying to create a drop down list using two worksheets. How would I > create this. > > One s...

Drag and drop of eMail to own application
Hi everybody, i like to drag and drop an eMail of Outlook ( Express & Xp ) and Thunderbird into my own application ( MFC ). There'in the dropped eMail should be readed and the subject, body text, Recepiant, ... should be displayed into textboxes. I can check the different formats of the Drag-Event or Clipboard data. An Outlook Express mail is stored in plaintext into the clipboard, so it's seriously possible to extract it. But with Outlook XP Mails i see only the name of a .eml file ( the of file which would be saved on the Destop for example ) But how to extract the data? Do...

drop down calendar #4
In a cell I want to have a drop down calendar of the current month. I downloaded a template of a calendar and tried data valadation but it only displayed the source range. Any ideas? TIA http://www.windowsdevcenter.com/pub/a/windows/2004/04/27/excelhacks.html "Ray A" wrote: > In a cell I want to have a drop down calendar of the current month. I > downloaded a template of a calendar and tried data valadation but it only > displayed the source range. Any ideas? > TIA > Ray See Ron de Bruin's site for this. http://www.rondebruin.nl/calendar.htm Gord D...

drop down data want to choose more than one item for cell
I have a drop down box that i want folks to be able to choose more than one item from the box to go into the cell. Multiselect from a DV dropdown is possible using VBA. See Debra Dalgleish's site for a downloadable sample workbook with event code. http://www.contextures.on.ca/excelfiles.html#DV0017 Note that you can have the selections in an adjacent cell or in the same cell. Gord Dibben MS Excel MVP On Fri, 26 Feb 2010 12:40:08 -0800, FranW <FranW@discussions.microsoft.com> wrote: >I have a drop down box that i want folks to be able to choose more than...

Setting recordsource property in VBA Access 2007
I'm trying to create a report in Access 2007. I cannot figure out how to set the recordsource propery in code. I either get #Name? if the property is not set at design or I get the original dataset base on the value of recordsource at designed, not the value that I set in the report_Open event. Does anyone know what I need to do to be able to set the recordsource property in code? Thanks, Kevin KMcHenry wrote: >I'm trying to create a report in Access 2007. I cannot figure out how to set >the recordsource propery in code. > >I either get #Name?...

Add New Worksheet Using VBA
Hi Can anyone tell me how to add a new worksheet and rename it using VBA. Thanks for the help. Cheers!! -- Hani Muhtadi ------------------------------------------------------------------------ Hani Muhtadi's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26794 View this thread: http://www.excelforum.com/showthread.php?threadid=477226 Worksheets.Add.Name = "mysheet" -- HTH RP (remove nothere from the email address if mailing direct) "Hani Muhtadi" <Hani.Muhtadi.1x40mb_1129658709.0692@excelforum-nospam.com> wrote in message news...

Drop Down List #2
Hi All Can this be done, as I am struggling. I have data in sheet B and want to create a drop down list in sheet A from this data, and I can't make it happen, I can create a drop down list in sheet A from data in sheet A but not from sheet B Could anyone help please Cheers Steve Name the range on the other sheet, and you can refer to it in the data validation dialog box. There are instructions here: http://www.contextures.com/xlDataVal01.html Steve wrote: > I have data in sheet B and want to create a drop down list in sheet A from > this data, and I can't make it h...

can i create a modalless dialog Box in the worker thread.
hi guys, is it possible to create a modalless dialog box in the worker thread, actually we have try this but we got error that is" you cannot create object with new operator in the worker thread " but i don't know what is the actual reason behind this. actually i am trying to create a modalless dialog box from main dialog box and i want to perform openGL programing on both the dialog box in such a manner so that they do not collapse or crash each other because at one time only one rendering device context should reside in the memory if we want to create more then one device con...

Question of drop-down listbox
Hello, Is it possible to have listbox or combobox with Auto HScroll (ES_AUTOHSCROLL) capabilities. Thank You! I don't get it. ES_AUTOHSCROLL is an Edit control style, how would it apply to a listbox or combobox? What are you trying to do? AliR. "Ririko Horvath" <horvathr@securemethods.com> wrote in message news:uHUo%23OyLFHA.3336@TK2MSFTNGP10.phx.gbl... > Hello, > > Is it possible to have listbox or combobox with Auto HScroll > (ES_AUTOHSCROLL) capabilities. > > Thank You! > > I'm soory for not expressing my question properly...

Multiple Check Boxes in Form
Hello All, I need advice on how to setup a form with multiple check boxes correctly. I have created a table that houses most of the data but I want each check box to be linked to a specific ID. However, there will be multiple check boxes linked to 1 ID. Can someone give me direction as to how I can achieve this? Thanks, Tammy Watts You said nothing about your table structure. What are the field names and datatype? When you same 'linked to a specific ID' do you mean a unique record? -- Build a little, test a little. "MsWatts" wrote: > H...

VBA code for MsgBox AND WorkSheet Active at same time
Need the VBA code to assist me with the following: I want to use a message box to instruct the user to select a range, and be able to do so, on the worksheet with the message box.still on top. If I may, in addition, I would like to capture that range to a variable to be used subsequently in the following VBA code. Is this possible? TIA Dennis on the VBE toolbox select refedit and put it in a userform. for more info look in Help. Dennis wrote: > Need the VBA code to assist me with the following: > > I want to use a message box to instruct the user to select a range, and b...

Legend Key Box
Is it possible to resize a legend key box to blow up the size and make more visible ? Yes. Select it and it will show size handles which you can grab and use to stretch the box. -- David Biddulph "tara" <tara@discussions.microsoft.com> wrote in message news:3C3A07FF-F910-4E09-9489-ED11EFF87529@microsoft.com... > Is it possible to resize a legend key box to blow up the size and make > more > visible > ? The size of the legend key varies with the font size of the legend entries. There is no way to increase the legend key's size while keeping the legen...

reporting on drop-down values
We created drop-downs and wish to add the values to a report, but of course the extentionbase tables only show the numbers. Is there a specific table where all the actual text values are stored? Hi use the stringmaps table to get the description of picklist values. I hope it helps. -- Singh http://mscrmshop.blogspot.com MSCRM Consultant Orion Enterprise Sydney "TheWkndr" wrote: > We created drop-downs and wish to add the values to a report, but of course > the extentionbase tables only show the numbers. Is there a specific table > where all the actual text values a...

List Box to show your Order
At the Moment I have a query that lists my Horses on my form I have a Text box next to each horse so depending what number I put in my text Box gives me a Printing Order, This is for Printing Worksheets, What I am trying to Achieve is say to list Boxes and you highlight a Horse a click the arrow to send it to another Listbox on the same form then print the Order in list Box2, Once you select a record and click it to List Box 2 it disappears from list box 1, Any Ideas how to start this? -- Thanks in advance for any help with this......Bob MS Access 2007 accdb Windows XP Home...

Search combo boxes
I am trying to use a form as a search form and to update records based on two combo boxes but I am running into issues. Using help on other posts here, I was able to get the combo boxes to work, or so I thought. The initial entry gives me the correct results but then I can page down and scroll through all the records in the form's record source. This is the code I have used on the Update event of the second combo box: Private Sub cboBLNum_AfterUpdate() With Me.RecordsetClone .FindFirst "[LoadNum] = " & Me!cboLoadNum & _ ...

Drop user or alias before dropping login
I am trying to delete a user, and I get this error: Login is aliased or mapped to a user in one or more databases. Drop the user or alias before dropping the login. Any advice? Hi Caroline, GO to SQL server --> logins and select the user and open check the properties of the login and see what database access the users has. If any uncheck all the database access and drop the user. Also make sure from the GP front end you have unchecked the company access too. If still you get errors go to each database on the server and make sure they are not in the users list in the databases. ...

Message box shadow
I have a spreadsheet that when a macro displays a message box and one moves the message box by clicking on it with the mouse and dragging it across the screen it leaves a trail of hundreds of message boxes behind it. Does anyone know what causes this and how I can prevent this happening. -- with kind regards Spike Hi Spike, I have seen this behavior, it is not a error in your macro! The reason might be that the video cart can not cope with the changes. Upgarde the hardware or add some memory to the videocard and the problem could be solved. HTH, Wouter I have disco...

Displaying the contents of a query cell in a text box in my form
Hi everyone! I have a question, and it most likely a simple solution, but is giving me fits here. I have a form, and oh what a form it is. Everything works like a charm. BUT... On Wed, 05 Dec 2007 23:22:46 GMT, chris23892 wrote: > Hi everyone! I have a question, and it most likely a simple solution, but is > giving me fits here. > > I have a form, and oh what a form it is. Everything works like a charm. BUT... I'll see your but and raise you two! -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail well, that was helpful...... fredg wrote: &g...

Drop down list 04-23-10
How do you display drop down list button even if the cell is not selected? You can't. Perhaps you've seen the button created from a AutoFilter ot PivotTable? -- Best Regards, Luke M "DLB" <DLB@discussions.microsoft.com> wrote in message news:F248BA68-6874-4712-876D-CF2890DD0BF1@microsoft.com... > How do you display drop down list button even if the cell is not selected? Use a combo box from the Forms toolbar. The drop down arrow is always visible. -- Biff Microsoft Excel MVP "DLB" <DLB@discussions.microsoft.com> wro...

Report Text box
I have a report that i would like to have some text with a delivery day that is from the query the reportis based on So i need a text box in the report somthing like below but it does not work = You parcel will be delivered on [DeliveryDay] at [Deliverytime] Please can somesone tell me how i edit the code to work Thanks SImon On Mon, 15 Oct 2007 11:12:08 -0700, Simon wrote: > I have a report that i would like to have some text with a delivery > day that is from the query the reportis based on > > So i need a text box in the report somthing like below but it does not > ...

combo box 01-31-08
Thank you I have combo box Control Source= Row source type= table \query row source = SELECT tblClient.IDClient FROM tblClient; I want if the user type one of the IdClient in the combo box message box appear ("the number you type already exists" ) I don't get the point. If you'll creating the one as you stated below you're creating another table which same as your table source. and of course if you have a creating a source like below all the content of combo box were exist. I suggest you to make a primary key for the uniqueness of every record. a wrote: &g...

Maximize box with all windows
Hello. I have dialog box with few resourses (edit boxes, list boxes etc) and I added in properties of dialog box option : Maximize box. But when I try to do this (push square in right top corner) then maximize only main dialog box, but other reseourses like edit box and list boxes have orginal size. How to do that all components expand when I maximize dialog window ? ovverride the OnSize method and resize the controls per your desire ..... "Mammoth" <cactusek@gmail.com> wrote in message news:1171021945.301283.205810@p10g2000cwp.googlegroups.com... > Hello. > I have dia...