+ Reply to Thread
Results 1 to 7 of 7

I need the first word, in a concatenated string, displayed with Bold font in my listbox...

  1. #1
    Registered User
    Join Date
    03-10-2013
    Location
    Ugerløse, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    I need the first word, in a concatenated string, displayed with Bold font in my listbox...

    Hello everyone,

    I'm filling up a listbox by concatenating several strings from my Excel database, this concatenated string is being filled into the listbox by .additem and everything is working fine.

    My issue is, that I would like the first Word in every concatenated string to be Bold and maby even with a larger font size, but I can't figure out how to do this.

    I was hoping there would be an easy way to do this, maby by telling that str_C should be Bold (something like "font.bolt(str_C)=True"), anyone have any suggestion?



    This is the code I wrote...

    Private Sub cbo_SelectGroup_Change()
    xRow = 2
    xColumn = 3

    zRow = 1
    zColumn = 3

    str_A = cbo_SelectGroup.Value

    Select Case str_A

    Case Is = "Melee - Blades"
    '(i.e. "Combat axe | Accuracy: 4 | Reach: 2 | Damage: (Str + 5) P | AP: -4 | Avail: 12R | Cost: 4000")

    'Clear List
    lst_EquipmentList.Clear

    'Item name (i.e. "Combat axe")
    xRow = 2
    xColumn = 3

    'Sub-header (i.e. "Accuracy")
    zRow = 1
    zColumn = 4

    'Sub-header value (i.e. "4")
    yRow = 2
    yColumn = 4

    'Divider ( | )
    str_B = " | "

    For int_A = 1 To 999

    Do

    'Load condition for stopping loop
    var_Stop = Worksheets("db_Blade").Cells(zRow, zColumn + 1)

    'Load Item name into string
    str_C = Worksheets("db_Blade").Cells(xRow, xColumn)

    'Load Sub-header into string
    str_D = Worksheets("db_Blade").Cells(zRow, zColumn) & ": "

    'Load Sub-header value into variable
    var_A = Worksheets("db_Blade").Cells(yRow, yColumn)

    'Concatenate string
    str_E = str_E & str_B & str_D & var_A

    xRow = xRow + 0
    xColumn = xColumn + 0

    zRow = zRow + 0
    zColumn = zColumn + 1

    yRow = yRow + 0
    yColumn = yColumn + 1

    Loop Until var_Stop = ""

    'Add Item name infront of concatenated string
    str_F = str_C & str_E

    'Load Completed string into listbox
    If str_C <> "" Then
    With lst_EquipmentList
    .AddItem str_F
    End With
    Else
    End If

    'Reset Dim
    str_C = ""
    str_D = ""
    str_E = ""
    str_F = ""
    var_A = ""

    'Next set of coordinates
    xRow = xRow + 1
    xColumn = 3

    'Next set of coordinates
    zRow = 1
    zColumn = 4

    'Next set of coordinates
    yRow = yRow + 1
    yColumn = 4

    Next int_A

    End Select

    End Sub



    Kind Regard
    Martin Kristensen

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: I need the first word, in a concatenated string, displayed with Bold font in my listbo

    You can't change the formatting of an individual item in a listbox.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-10-2013
    Location
    Ugerløse, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I need the first word, in a concatenated string, displayed with Bold font in my listbo

    Thats annoying, but I guess I have to live with that

    Then I don't want to Waste any more energy on that issue.

    Thank you very much for a quick reply.



    Maby you could help me with another question I have regarding the code I wrote, everytime I refer to my worksheet, I write worksheets("db_Blade").cells(xRow, xColumn).

    Is there a way I could replace "db_Blade" with a variable, I tried...


    var_B = "db_blade"
    worksheets(var_B).cells(xRow, xColumn)


    But it doesn't seem to Work, would be easier later on, when I repeat this code and use it for the rest of my 25 db_sheets?



    Kind Regard
    Martin Kristensen

  4. #4
    Registered User
    Join Date
    03-10-2013
    Location
    Ugerløse, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I need the first word, in a concatenated string, displayed with Bold font in my listbo

    Hmm... Odd...

    var_B = "db_blade"
    worksheets(var_B).cells(xRow, xColumn)

    Did Work for me when I tried it out Again - Wonder why I couldn't get it to Work the first time.



    Kind Regard
    Martin Kristensen

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: I need the first word, in a concatenated string, displayed with Bold font in my listbo

    Martin

    You could use a worksheet variable.

    Right at the start of the code add this.
    Please Login or Register  to view this content.
    You can now use wsBlade in place of Worksheets("db_Blade") in the rest of the code.

    For example.
    Please Login or Register  to view this content.
    PS Can you add code tags?

  6. #6
    Registered User
    Join Date
    03-10-2013
    Location
    Ugerløse, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I need the first word, in a concatenated string, displayed with Bold font in my listbo

    I can't seem to get the code tags to Work, but the other stuff seems to Work fine - thanks!



    Kind Regard
    Martin Kristensen

  7. #7
    Registered User
    Join Date
    03-10-2013
    Location
    Ugerløse, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I need the first word, in a concatenated string, displayed with Bold font in my listbo

    I can't seem to get the code tags to Work, but the other stuff seems to Work fine - thanks!



    Kind Regard
    Martin Kristensen


    --Sorry, double post--

+ 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. VBA to format bold a concatenated string
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-16-2016, 04:18 AM
  2. Make a word bold if it starts with a particular character/string
    By lightsandsirens in forum Word Programming / VBA / Macros
    Replies: 9
    Last Post: 03-08-2010, 09:28 AM
  3. [SOLVED] Set string variable to word displayed in a combobox
    By Graham Whitehead in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2006, 09:30 AM
  4. [SOLVED] Bold a portion of concatenated string
    By joeeng in forum Excel General
    Replies: 1
    Last Post: 12-08-2005, 04:30 PM
  5. [SOLVED] determining bold font in a string
    By william kossack in forum Excel General
    Replies: 2
    Last Post: 11-02-2005, 06:17 PM

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