Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Location
    Edmonton, Alberta, Canada
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need to list lines from ComboBox (English/Word97/SR2)

    Hi. The only way that I can figure out to do it will take lines and lines of code, and I am hoping that there is an easier way.

    I have a UserForm set up with one box a drop-down combo list for the users to select which practice code they are opening this file under. There are 85 of these lines (if I start counting at 0) and each one is added with an additem code. (i.e. .AddItem "CORP 10 Corporate - Incorporation").

    I have grouped all 85 practice codes so that if any of the lines 0-21 are chosen, then the practice group is =1, lines 22-29 = 7, etc.

    I need to have the macro fill in the Practice Group automatically into a box on the Word form based on which practice code the user chooses. However, the only way I can actually get this to work is by using If ... Then statements on each individual line. For example: If cboPracticeCode = "CORP 10 Corporate - Incorporation" then
    strPracGroup=1
    and do this for each line.

    Is there any way for me to specify to the macro that if lines 0-21 are selected by the user, then strPracGroup=1? I have tried value and list, but I haven't got either one to work. Hopefully, there is an easier way.

    I hope this makes sense. Any input would be appreciated.

  2. #2
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Need to list lines from ComboBox (English/Word97/SR2)

    Instead of using an "equal to" can you use a "less than or equal to" and qualify by the line number rather than the text of the item?

    Just a thought off the top of my head.

    Kim

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to list lines from ComboBox (English/Word97/SR2)

    <P ID="edit" class=small>(Edited by Kevin on 21-Apr-03 09:46. Bryan beat me to the Post button, making my post a bit redundant..)</P>How about

    if cboPracCode.ListIndex < 22 then

    elseif cboPracCode.ListIndex < 44 then

    elseif cboPracCode.ListIndex < 66 then
    else bla bLA

    A select statement might look nicer in a print out:

    Select Case cboPracCode.ListIndex
    Case 0 to 21
    case 22 to 44
    case 45 to 66 etc. etc...
    End Select

    fyi: The above is air code, use with intellisense...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to list lines from ComboBox (English/Word97/SR2)

    <P ID="edit" class=small>(Edited by carbonnb on 21-Apr-03 12:48. to fix a small mistake in the code)</P>It sounds like you will be better off with a Select Case structure

    <pre>Select Case cboPracticeCodeComboBox.ListIndex
    Case 0 to 21
    PracticeGroup = 1
    Case 22 to 29
    PracticeGroup = 7
    '....
    'These are just made up numbers, yours will be different
    Case 75 to 83
    PracticeGroup = 12
    Else
    'This will catch anything not caught by the above conditions.
    PracticeGroup = 18
    End Select
    </pre>

    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  5. #5
    New Lounger
    Join Date
    Oct 2002
    Location
    Edmonton, Alberta, Canada
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to list lines from ComboBox (English/Word97/SR2)

    Works like a charm!!! Thank you very much.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to list lines from ComboBox (English/Word97/SR2)

    Sweet!
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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