Consulting

Results 1 to 3 of 3

Thread: Not specified issue

  1. #1
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    132
    Location

    Not specified issue

    Hi Folks

    So, I've got this so-called matrix to with some products in the rows and the exactly the same products in the columns; in order to see which tasks are to perform when changing from product1 to product2.

    To give an example: matrix.jpg

    For this i'm going through some arrays...In the end, an entry in the matrix could be "", a number (eg. 5-11), or a number combined with a or b (eg. 5a, 5b, ...)
    , or multiple values separated by "," which is where the problem is.
    My aim is to show any Xa or X number as bold, whereas Xb numbers should not become bold. The code works for that, except that the commas in between become bold as well,
    but only when bold comes first, the other way is fine

    here a "short" insight:

    sdf.jpg

    For i = LBound(arrVariantenSplit) To UBound(arrVariantenSplit)

    arrVarianten(i + 1, 1) = .Text eg. "10b"
    arrVarianten(i + 1, 2) = arrVariantenSplit(i) eg. "10b"
    arrVarianten(i + 1, 3) = Len(arrVariantenSplit(i)) eg. 3

    If Not UBound(arrVariantenSplit) = 0 Then
    arrVarianten(i + 1, 4) = InStr(1, arrVarianten(i + 1, 1), arrVarianten(i + 1, 2), 0) eg. 1
    Else
    arrVarianten(i + 1, 4) = 1
    End If

    If Right(arrVariantenSplit(i), 1) = "b" Then
    arrVarianten(i + 1, 5) = Right(arrVariantenSplit(i), 1)
    ElseIf Right(arrVariantenSplit(i), 1) = "a" Then
    arrVarianten(i + 1, 5) = "a"
    Else
    arrVarianten(i + 1, 5) = 0
    End If

    If arrVarianten(i + 1, 5) = "a" Or arrVarianten(i + 1, 5) = 0 Then

    With .Characters(arrVarianten(i + 1, 4), arrVarianten(i + 1, 3)).Font eg. so here it should apply bold to characters 1-2 or 1-3 only
    .Bold = True: .Size = 11
    End With

    Else

    With .Characters(arrVarianten(i + 1, 4), arrVarianten(i + 1, 3)).Font
    .Bold = False: .Size = 10: .Color = RGB(89, 89, 89)
    End With

    End If

    Next i

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,872
    I think we might need to know what's in and how the values in arrVariantenSplit have been assigned.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Not much to go on but maybe



    arrVarianten(i + 1, 1) = .Text                                       eg. "10b"
    arrVarianten(i + 1, 2) = arrVariantenSplit(i)                   eg. "10b"
    
    
    If Right(arrVarianten(i + 1, 1),1) = "," Then
    
    arrVarianten(i + 1, 3) = Len(arrVariantenSplit(i))-1
    Else
    arrVarianten(i + 1, 3) = Len(arrVariantenSplit(i)) eg. 3 End if
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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