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 [TABLE="width: 87"]
<tbody>[TR]
[TD]Jay[/TD]
[/TR]
[TR]
[TD]Fred[/TD]
[/TR]
[TR]
[TD]Mary[/TD]
[/TR]
[TR]
[TD]Ted[/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[/TR]
[TR]
[/TR]
</tbody>[/TABLE]
Here is what the data looks like below:

[TABLE="width: 87"]
<tbody>[TR]
[TD]Connecticut[/TD]
[/TR]
[TR]
[TD]Steve[/TD]
[/TR]
[TR]
[TD]Ray[/TD]
[/TR]
[TR]
[TD]Bob[/TD]
[/TR]
[TR]
[TD]Jimmy[/TD]
[/TR]
[TR]
[TD]New York[/TD]
[/TR]
[TR]
[TD]Jay[/TD]
[/TR]
[TR]
[TD]Fred[/TD]
[/TR]
[TR]
[TD]Mary[/TD]
[/TR]
[TR]
[TD]Ted[/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[/TR]
[TR]
[TD]Maine[/TD]
[/TR]
[TR]
[TD]Sonny[/TD]
[/TR]
[TR]
[TD]Johnny[/TD]
[/TR]
[TR]
[TD]Angelo[/TD]
[/TR]
[TR]
[TD]Salvatore[/TD]
[/TR]
[TR]
[TD]Gino[/TD]
[/TR]
[TR]
[TD]California[/TD]
[/TR]
[TR]
[TD]Gus[/TD]
[/TR]
[TR]
[TD]Dave[/TD]
[/TR]
[TR]
[TD]Ken[/TD]
[/TR]
[TR]
[TD]Ralph[/TD]
[/TR]
[TR]
[TD]George[/TD]
[/TR]
[TR]
[TD]Manny[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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

Similar threads

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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