Results 1 to 4 of 4

Thread: VBA Function Lookup Bold Bring Back Under

  1. #1
    Board Regular
    Join Date
    Jun 2011
    Posts
    206
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA Function Lookup Bold Bring Back Under

    I have about 150000 rows of data like below. I would like to look up a bold value. For instance if I have New York in cell D1, I want to bring back all of the values underneath New York so it would return
    Jay
    Fred
    Mary
    Ted
    Sam
    Here is what the data looks like below:

    Connecticut
    Steve
    Ray
    Bob
    Jimmy
    New York
    Jay
    Fred
    Mary
    Ted
    Sam
    Maine
    Sonny
    Johnny
    Angelo
    Salvatore
    Gino
    California
    Gus
    Dave
    Ken
    Ralph
    George
    Manny

  2. #2
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    6,194
    Post Thanks / Like
    Mentioned
    67 Post(s)
    Tagged
    14 Thread(s)

    Default Re: VBA Function Lookup Bold Bring Back Under

    I guess the data is in column A and that you are going to put the value in D1.
    Try this:


    Code:
    Sub Lookup_Bold()
      Dim v As Range, f As Range, i As Long
      Set v = Range("D1")
      If v.Value = "" Then
        MsgBox "Put value"
        Exit Sub
      End If
      Range(v.Offset(1), Cells(Rows.Count, v.Column)).ClearContents
      Set f = Columns("A").Find(v, , xlValues, xlWhole)
      If Not f Is Nothing Then
        For i = f.Row + 1 To Cells(Rows.Count, f.Column).End(xlUp).Row
          If Cells(i, f.Column).Font.Bold Then Exit For
          Cells(Rows.Count, v.Column).End(xlUp)(2) = Cells(i, f.Column)
        Next
      Else
        MsgBox "Value not exists"
      End If
    End Sub
    Regards Dante Amor

  3. #3
    Board Regular
    Join Date
    Jun 2011
    Posts
    206
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Function Lookup Bold Bring Back Under

    Dante worked great. Thank you so much!!! Much appreciated.

  4. #4
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    6,194
    Post Thanks / Like
    Mentioned
    67 Post(s)
    Tagged
    14 Thread(s)

    Default Re: VBA Function Lookup Bold Bring Back Under

    I'm glad to help you. Thanks for the feedback.
    Regards Dante Amor

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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