ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   CLEAN on whole Worksheet (https://www.excelbanter.com/excel-discussion-misc-queries/164510-clean-whole-worksheet.html)

Gareth - Network analyst.

CLEAN on whole Worksheet
 
Hi guys/Girls

Is there a way to apply the CLEAN function to an entire worksheet?


Bob Phillips

CLEAN on whole Worksheet
 
Public Sub Test()
Dim cell As Range

For Each cell In ActiveSheet.UsedRange
If Not cell.HasFormula Then
cell.Value = Application.Clean(cell.Value)
End If
Next cell
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Gareth - Network analyst."
wrote in message ...
Hi guys/Girls

Is there a way to apply the CLEAN function to an entire worksheet?




Gary''s Student

CLEAN on whole Worksheet
 
Select the cells you want to clean and run:

Sub doit()
For Each r In Selection
If Application.WorksheetFunction.IsText(r) Then
r.Value = Application.WorksheetFunction.Clean(r.Value)
End If
Next
End Sub
--
Gary''s Student - gsnu200753


"Gareth - Network analyst." wrote:

Hi guys/Girls

Is there a way to apply the CLEAN function to an entire worksheet?



All times are GMT +1. The time now is 01:06 PM.

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