ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Searching for text in cells (https://www.excelbanter.com/excel-discussion-misc-queries/10719-searching-text-cells.html)

Matt

Searching for text in cells
 
I need to search a group of cells for text and return that text into one
cell. There will always be only one value in that group of cells.

Tom Ogilvy

Sub GetText
Dim rng as Range, sStr as String
On Error Resume Next
set rng = Selection.SpecialCells(xlConstants,xlTextValues)
On Error goto 0
if not rng is nothing then
for each cell in rng
sStr = sStr & cell.Value
next
Range("A1").Value = sStr
End if
End sub

--
Regards,
Tom Ogilvy




"Matt" wrote in message
...
I need to search a group of cells for text and return that text into one
cell. There will always be only one value in that group of cells.





All times are GMT +1. The time now is 06:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com