Macro help

excellrookie

New Member
Joined
Mar 23, 2011
Messages
17
How would I code a macro that scans a specific column for a key phrase, once the macro finds the phrase it will display the entire row of information.

For example:
the macro would search the entire column B and find any cells that have the value "EXCEL FORUM," lets say it found that phrase in row 34, then it copies the entire row 34 and paste the row in the cell that the macro was run in.
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

John Davis

Well-known Member
Joined
Sep 11, 2007
Messages
3,457
How would I code a macro that scans a specific column for a key phrase, once the macro finds the phrase it will display the entire row of information.

For example:
the macro would search the entire column B and find any cells that have the value "EXCEL FORUM," lets say it found that phrase in row 34, then it copies the entire row 34 and paste the row in the cell that the macro was run in.

Maybe this could give you some ideas?

Code:
Sub excellrookie()
Dim lr As Long

lr = Cells(Rows.Count, 1).End(xlUp).Row

x = InputBox("Please Enter the Destination Range")

Columns("B:B").AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="EXCEL FORUM"
Range("B2:B" & lr).EntireRow.SpecialCells(xlCellTypeVisible).Copy Range(x)
Columns("B:B").AutoFilter

End With
End Sub
 

excellrookie

New Member
Joined
Mar 23, 2011
Messages
17
Maybe this could give you some ideas?

Code:
Sub excellrookie()
Dim lr As Long

lr = Cells(Rows.Count, 1).End(xlUp).Row

x = InputBox("Please Enter the Destination Range")

Columns("B:B").AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="EXCEL FORUM"
Range("B2:B" & lr).EntireRow.SpecialCells(xlCellTypeVisible).Copy Range(x)
Columns("B:B").AutoFilter

End With
End Sub

Thank you John. I will check it out in a few :)
 

Watch MrExcel Video

Forum statistics

Threads
1,122,224
Messages
5,594,916
Members
413,952
Latest member
JGer

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
Top