+ Reply to Thread
Results 1 to 17 of 17

Run Macro and fill out cells , when country is selected.

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,121

    Run Macro and fill out cells , when country is selected.

    Hi I have a dropdownmanu in sheet1 with different countries taken from Column A in Sheet3. I need a macro to run when i select a country example Denmark. It will fill out transmittal code and also country code in named cells for it in sheet1. Info taken from Sheet3
    Transmittal code is in below testsheet in Sheet1 cell E12.
    Country code is in Sheet1 cell.
    But this have to be possible to change. Also the range for the country have to be possible to change. Can be many countries.

    This vba code i need to run as soon as i select a country in the dropdown manu.

    This is my primary question.
    But one thing i would like to solve also is. When i select a country it will create a dropdownlist in I13 taken from the info in column, i have in Sheet3 column F. So if i select example Denmark, it will show a dropdown menu in sheet1 I13, with the ledger codes 10 and 6x.
    I have tried to make this work but cant make it work good.

    I use excel 2003. Please have a look and upload the testsheet back.

    Thanks in advance.

    Sincerely.
    Abjac
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Run Macro and fill out cells , when country is selected.

    e12
    Please Login or Register  to view this content.
    g14=
    Please Login or Register  to view this content.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,121

    Re: Run Macro and fill out cells , when country is selected.

    Thanks Oeldere. Tried the formula but it gives and error. Maybe because i use excel 2003. If it can be done with a vba code it would be great.
    Please have a look if time.

    Thanks

    Abjac

  4. #4
    Registered User
    Join Date
    02-09-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    11

    Re: Run Macro and fill out cells , when country is selected.

    Hi, I hope this help you.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,121

    Re: Run Macro and fill out cells , when country is selected.

    HI Pushcar. Thanks allot for your codes. I tried it but it come up with an error in this line.

    HTML Code: 
    Say compile error.
    Cant find project or library.

    If time please have a look .

    Thanks in advance.
    SIncerely

    Abjac

  6. #6
    Registered User
    Join Date
    02-09-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    11

    Re: Run Macro and fill out cells , when country is selected.

    Hi abjac.
    automateaccessado_1.gif
    To use ADO in your VBA project, you must add a reference to the ADO Object Library in Excel (your host application) by clicking Tools-References in VBE, and then choose an appropriate version (mostly, you should choose the highest version number) of Microsoft ActiveX Data Objects x.x Library from the list. The ADO version depends on your Windows operating system, viz. Microsoft ActiveX Data Objects 6.1 Library for Windows 7 or later, Microsoft ActiveX Data Objects 6.0 Library for Windows Vista, and Microsoft ActiveX Data Objects 2.8 Library for Windows XP. In Windows Vista or in later versions of Windows only one of the ADO version 6.0 or version 6.1 will be available in the Reference list at one time. Refer Image 1 for available libraries, wherein 'Microsoft ActiveX Data Objects 6.1 Library' has been selected.

    You must have these references (the number on the end can be lower or higher):
    references.JPG
    Last edited by PushCar; 06-09-2014 at 01:36 AM.

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Run Macro and fill out cells , when country is selected.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,121

    Re: Run Macro and fill out cells , when country is selected.

    HI Pushcar. I figured that out also. I have windows xp and selected the version 2.8. Now it gives another error. ScreenHunter_01 Jun. 09 07.42.gif

    Maybe i dont understand but i guess i shall just press the button Show form. Have a look if time.

    Oeldere. I think you only pasted my answer to you in here. Could not make your formula work in excel 2003

    Sincerely

    Abjac

  9. #9
    Registered User
    Join Date
    02-09-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    11

    Re: Run Macro and fill out cells , when country is selected.

    yes just press the button.
    But you must have activated the first cell for example "A2" or A3.... Try in the code change like this and then show me the error when are you pressing the button.
    Please Login or Register  to view this content.
    ok i think it is because of the excel version so in the code:
    Please Login or Register  to view this content.
    on the page

    http://www.connectionstrings.com/excel/

    is the correct examples if you use the excel 2003
    Last edited by PushCar; 06-09-2014 at 02:17 AM.

  10. #10
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Run Macro and fill out cells , when country is selected.

    Please Login or Register  to view this content.
    VLookup will work in excel 2003.

    That is why i'm asking you wich error you get with the formula.

  11. #11
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,121

    Re: Run Macro and fill out cells , when country is selected.

    Hi i am on d way work now but will try as soon as i can. Oeldera is it possible for u to send it back in d test sheet i uploaded. Got a code error when i tried put d code in as a formula. Thanks Abjac

  12. #12
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Run Macro and fill out cells , when country is selected.

    You can use the formula in the excel sheet. (No VBA necessary).

  13. #13
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Run Macro and fill out cells , when country is selected.

    Hi Abjac,
    maybe so (see attached file)
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    02-09-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    11

    Re: Run Macro and fill out cells , when country is selected.

    Hi, now (I think) it works fine in Excel 2003.
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,121

    Re: Run Macro and fill out cells , when country is selected.

    Hi Nilem. Yours seems to work just perfect. So thanks allot for that.

    Pushcar yours are nearly working now the only error is that in Country code it put this in 678_1. It should just be 678. And I guess you did not make anything for the ledger codes. Need to be able to choose there, but the error with the number 678_1 I need to solve if possible. Thanks both for your effort. Will leave it open to see if Pushcar can make his work also.

    Thanks its a big help for both of you.

    Sincerely

    Abjac

  16. #16
    Registered User
    Join Date
    02-09-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    11

    Re: Run Macro and fill out cells , when country is selected.

    Hi abjac,
    If you fill each cell so the values will be in the correct form. Just tri push Next when the Ledger codes is checked. This UserForm works even if some data are longer than 255 characters.

  17. #17
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,121

    Re: Run Macro and fill out cells , when country is selected.

    Ok Now I got it for sure. Its quite perfect, thanks allot to you PushCar for you effort and also you Nilem and Oeldere.

    Both solutions works brilliant.

    Have a nice day. And thanks
    Sincerely Abjac

+ 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] Run code when country is selected in dropdown menu
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-30-2013, 03:52 AM
  2. Fill selected cells by selecting a value from a list
    By davejcohen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-17-2010, 04:33 PM
  3. Macro to fill cells when a value is selected from Drop Down List
    By TRJJK73 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2009, 05:13 AM
  4. [SOLVED] Auto-fill the selected cells without using macro
    By sachi.b@gmail.com in forum Excel General
    Replies: 3
    Last Post: 02-22-2006, 11:35 PM
  5. Replies: 1
    Last Post: 06-30-2005, 02:05 AM

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