+ Reply to Thread
Results 1 to 7 of 7

How to create a macro that goes through every item of a dropdown list

  1. #1
    Registered User
    Join Date
    08-25-2023
    Location
    Austria
    MS-Off Ver
    Office 365
    Posts
    3

    Question How to create a macro that goes through every item of a dropdown list

    Hello
    I have a price list with different discount rates (5 pieces) with a dropdown field.
    I want a macro that goes through this dropdown list and changes the discount name and the date in the footer of the price list.

    how can i put those lines in a for or while loop with the dropdown cell calles "Rabatt"
    'C2 = date for example: 2023-08

    ' Changing date and Pricelistname in footer
    Please Login or Register  to view this content.
    i hope it is understandable, thank you in advance.
    Last edited by AliGW; 08-25-2023 at 06:48 AM. Reason: Code tags added - please review the forum rules.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,845

    Re: How to create a macro that goes through every item of a dropdown list

    Welcome to the forum.

    Please review the forum rules, especially the rule about code tags. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: How to create a macro that goes through every item of a dropdown list

    Maybe:
    Please Login or Register  to view this content.
    Artik

  4. #4
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: How to create a macro that goes through every item of a dropdown list

    To answer the specific question about how to cycle through the options in a dropdown list:
    Please Login or Register  to view this content.
    Last edited by AliGW; 08-28-2023 at 09:15 AM. Reason: Please do NOT quote unnecessarily! Use the QUICK REPLY button instead.
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  5. #5
    Registered User
    Join Date
    08-25-2023
    Location
    Austria
    MS-Off Ver
    Office 365
    Posts
    3

    Re: How to create a macro that goes through every item of a dropdown list

    Thank you for your answers. I have rewritten the code but I still have problems with the line according to excel

    Please Login or Register  to view this content.
    any ideas why?

  6. #6
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: How to create a macro that goes through every item of a dropdown list

    What error message are you getting? That line runs fine for me so it's something in your file structure; can't tell without seeing the file.

    The code as written won't execute because you missed the "r" from dropDownCell in the first line after For i = etc. Also saveLocation is not defined (string) and Type:=x1TypePDF should be Type:=xlTypePDF (you have the number 1 instead of the letter L in lower case).

    In the immediate window before executing that line, what is dropDownCell.Address and dropDownCell.Validation.Formula1?

  7. #7
    Registered User
    Join Date
    08-25-2023
    Location
    Austria
    MS-Off Ver
    Office 365
    Posts
    3

    Re: How to create a macro that goes through every item of a dropdown list

    I'm getting runtime error 1004
    and the row:dropDownValues = Split(dropDownCell.Validation.Formula1, ",") is marked yellow
    thanks for the info with the "r", it doesnt't even come that far^^
    That with the savelocation works in an other marco i did in the same file, but i will change that too.

    you were completly right with the adress problem - i had the wrong cell - its not Rabatt it is D13.

    now it runs a little bit further the problem now is, that it sets the dropdownlist to #WERT and because of that the macro stops...

    i would love to show you the file but it is a company file.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Issues with Macro to create individual pdf files for each item on item validation list
    By maldo81 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-10-2021, 02:58 PM
  2. [SOLVED] adding an item to a dropdown list via the dropdown list
    By Learning ExL in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-22-2020, 02:32 PM
  3. macro to unhide row when a dropdown list item is selected
    By ahng in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2012, 07:17 AM
  4. Replies: 8
    Last Post: 01-23-2012, 10:28 AM
  5. Need a Macro.Create new sheets from one, where need to select from a dropdown list
    By Javier091 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2011, 08:47 AM
  6. Any way to get the index of a selected item from a dropdown list?
    By chitian5057 in forum Excel - New Users/Basics
    Replies: 8
    Last Post: 05-13-2010, 02:41 PM
  7. [SOLVED] How can I set up to chose more than 1 item from a dropdown list (.
    By microchick in forum Excel General
    Replies: 4
    Last Post: 04-07-2005, 02:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1