View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Curt Curt is offline
external usenet poster
 
Posts: 469
Default VBA for All cells in workbook

Thank you for the reply. I am a beginner so I might have phrased my question
incorrectly, but is there a reason that this macro works when I use it for
"thisWorkbook" but it doesn't when I put it as a module in my personal macro
workbook?

thanks

"Gary''s Student" wrote:

Sub GlobalChange()
Dim w As Worksheet
For Each w In ActiveWorkbook.Sheets
w.Activate
For Each r In ActiveSheet.UsedRange
r.Value = Trim(Replace(r.Value, Chr(160), Chr(32)))
Next
Next
End Sub

--
Gary''s Student - gsnu201002


"Curt" wrote:

I would like a VBA that replaces every cell of every sheet in a workbook with
its output when used with the following function:

=TRIM(SUBSTITUTE(A1,CHAR(160),CHAR(32)))

thanks

Curt J