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.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

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 :)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,164
Messages
5,835,745
Members
430,384
Latest member
kiuwai

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