Results 1 to 2 of 2
  1. #1
    snax500
    Guest

    Vlookup to a bold formatted cell

    Is there a way to do a Vlookup based on if a cell is formatted bold. For example, I want to look up "Tom" in a list of names. There are 5 "Toms" listed but only one is bold. How can I use just the bold formatted name?

    Thanks

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Vlookup to a bold formatted cell

    The following function will work as you require provided that the bold formatting was not applied through conditional formatting. The return value is based on the first first cell where the criteria are met. If no criteria are met it returns #N/A. Also note that changing a cell's formatting to or from bold will have no effect until the sheet is re-calculated.<pre>Function VLookUpBold(fLookUp As Variant, fRng As Range, fSet As Integer) As Variant
    Application.Volatile True
    Dim cell As Range
    VLookUpBold = CVErr(xlErrNA)
    For Each cell In fRng
    If cell.Font.Bold = True And cell.Value = fLookUp Then
    VLookUpBold = cell.Offset(0, fSet - 1)
    Exit For
    End If
    Next
    End Function</pre>

    To use it place it a VBA module of the workbook that requires it's use. Call it in the same way you use VLOOKUP.

    Hope it helps,

    Andrew C

Posting Permissions

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