Question: In Excel, how do I write a macro that would look for a string in an entire column. If the string is found, it will copy that entire row to a new sheet in that same file? For Example, Answer: Let's take a look at an example. Download Excel spreadsheet (as demonstrated below)
|
In our spreadsheet, we've created a button on Sheet1 called "Search for String". When the user clicks on this button, a macro called SearchForString will run. This macro will search through the values in Column E looking for "Mail Box". When the "Mail Box" string is found in Column E, the corresponding row will be copied to Sheet2.
|
When the macro has completed, the above message box will appear.
|
If you view Sheet2, you can see that only the rows where Column E contains the string "Mail Box" have been copied. You can press Alt-F11 to view the VBA code. Macro Code:The macro code looks like this:
|
Visit our busy book shop, were you can find latest books for beginners as well as advanced excel users.
Spreadsheet 123 Spreadsheet Software Development
See Spreadsheets for:
a.Hotel Management b.Personal Budget
c.Corporate Finance d.Rating Calculation e.Real Estate and Mortgage
f.Web Calc