![]() |
Check part of cell for data
I need to check the cells in a column to see if any of the cells contain
certain data. For example: Apple Pie Apple and Berry Cobbler Berry Jam Apple Jam I would need to be able to run the macro to check if the cell contained Berry to then list each cell that fit the criteria. I've got my Loop to run through the column and transfer the data to another column but need to code for checking within each cell. Any help would be great. Thanks! -- Mike M2K Computer Consulting www.m2kcomputers.com |
Check part of cell for data
Try something along the line of: Sub berry() Dim strToFind strToFind = "berry" For r = 1 To 4 If InStr(1, Cells(r, 1), strToFind, vbTextCompare) 0 Then Cells(r, 3) = Cells(r, 1) Next r End Sub This assumes the list is in column 1 and the cell contents needs copying to column 3. Mike K. Wrote: I need to check the cells in a column to see if any of the cells contain certain data. For example: Apple Pie Apple and Berry Cobbler Berry Jam Apple Jam I would need to be able to run the macro to check if the cell contained Berry to then list each cell that fit the criteria. I've got my Loop to run through the column and transfer the data to another column but need to code for checking within each cell. Any help would be great. Thanks! -- Mike M2K Computer Consulting www.m2kcomputers.com -- ben77 ------------------------------------------------------------------------ ben77's Profile: http://www.excelforum.com/member.php...o&userid=35602 View this thread: http://www.excelforum.com/showthread...hreadid=554318 |
All times are GMT +1. The time now is 01:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com