+ Reply to Thread
Results 1 to 16 of 16

UserForm ComboBox data source from another workbook

  1. #1
    Registered User
    Join Date
    04-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    54

    UserForm ComboBox data source from another workbook

    Hi guys,

    I am seek help in vba codes , which populate the combobox list which data are from another work book

    1) my another workbook "sourcedata.xlsx "

    it has also the range of data named "Names"

    2)my work book with userform called "attentance.xlsx"

    my first combox1 is the box where data from this range of data named "Names" in another work book ( "sourcedata.xlsx "
    ) will be populated from.

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: UserForm ComboBox data source from another workbook

    Hello..
    Upload the sample files...
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Registered User
    Join Date
    04-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: UserForm ComboBox data source from another workbook

    attentance.xlsm
    Attentance.docm
    sourcedata1.xlsx

    there is two types of documents , words and excel , which combobox required the data from sourcedata1.xlsx

    is like sourcedata1.xlsx acts as a database for populating combobox

  4. #4
    Registered User
    Join Date
    04-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: UserForm ComboBox data source from another workbook

    Take your time to reply, i will be back in 15 hours time =S

  5. #5
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: UserForm ComboBox data source from another workbook

    Hi
    Check out this for excel...

    attentance.xlsm

    Pls check the code and change the path for the sourcedata1 file.
    Attentance.docm
    Last edited by jraj1106; 04-23-2012 at 06:37 AM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: UserForm ComboBox data source from another workbook

    The suggested code requires that both workbooks are open. I would normally open the source workbook and write the code using RowSource to the target workbook, hiding the operation by switching off screen updating. I haven't time now but I'll post an example later
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: UserForm ComboBox data source from another workbook

    Some sample code, ListBox can be substituted for CombBox in the coe


    From a different Workbook that is open

    Option Explicit

    Please Login or Register  to view this content.
    From a different Workbook that is closed

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: UserForm ComboBox data source from another workbook

    Thanks guys for the response ! btw RoyUK ( thank you for taking your time off to hlpe me ) , btw which meants yours able to retrieve the data without opening the sourcedata workbook ? ( yeah i also notice alot codes in the net that requires to open both books which i am not looking for ) Also do i need to add any code for the source data file when working From a different Workbook that is closed


    and many thanks to jraj
    Last edited by andywsw; 04-23-2012 at 09:15 PM.

  9. #9
    Registered User
    Join Date
    04-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: UserForm ComboBox data source from another workbook

    i tried your code RoyUK, at the third code u gave me , .RowSource = rdata.Address(external:=True) is producing an error of Method or data member not found (Error 461). do i need to change sth on the address? was my referencing is wrong ?
    are the codes for both words and excel ?


    Btw how do i transfer list box selected value to a cell ? ( first time using Listbox )




    Hi jraj , i tried your codes and able to run however, ever since i could not open the file as per normal ( read-only ) any solution to this ?
    Last edited by andywsw; 04-24-2012 at 01:37 AM.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: UserForm ComboBox data source from another workbook

    You need to change address, sheet names & workbook names & paths.


    What are you doing with the word doc?

  11. #11
    Registered User
    Join Date
    04-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: UserForm ComboBox data source from another workbook

    i also have a report on words as well , do they share the same code?
    Last edited by andywsw; 04-24-2012 at 03:01 AM.

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: UserForm ComboBox data source from another workbook

    Code would be different, but why use Word?

  13. #13
    Registered User
    Join Date
    04-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: UserForm ComboBox data source from another workbook

    because both uses this source data ( acts like a common databsae for name ) on the combo box

  14. #14
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: UserForm ComboBox data source from another workbook

    The word doc seems to be blank to me. I would set up a separate sheet in Excel instead of word then coding would be simpler

  15. #15
    Registered User
    Join Date
    04-09-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: UserForm ComboBox data source from another workbook

    I am doing an word template , when user opens , a userform pop out . follow by user will input the data of their choice base on my userform. The data will be then transfer into the word document.

  16. #16
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: UserForm ComboBox data source from another workbook

    As I said, why complicate it by using two applications, set up the emplate in Excel. If you want to use Word then the code would be differnt & you would probably write to Bookmarks
    Last edited by royUK; 04-25-2012 at 05:18 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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