VBA Function Lookup Bold Bring Back Under

anthonyexcel

Active Member
Joined
Jun 10, 2011
Messages
258
Office Version
  1. 365
Platform
  1. Windows
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

<tbody>
</tbody>
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

<tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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("[COLOR=#0000ff]D1[/COLOR]")
  If v.Value = "" Then
    MsgBox "Put value"
    Exit Sub
  End If
  Range(v.Offset(1), Cells(Rows.Count, v.Column)).ClearContents
  Set f = Columns("[COLOR=#0000ff]A[/COLOR]").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
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,240
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top