VBA Syntax for Excel's CLEAN Function

peterv6

Board Regular
Joined
May 16, 2005
Messages
129
Office Version
  1. 365
Does anyone know how to code Excel's CLEAN function within VBA? I've tried numerous different ways, and none have worked.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try something like this.
Code:
   Range("A1").Value = Application.WorksheetFunction.Clean(Range("A1"))
 
Upvote 0
Try something like this.
Code:
   Range("A1").Value = Application.WorksheetFunction.Clean(Range("A1"))

Hi everyone - I have 'USB in range("A1"), that is atrophy(')&USB and I run the code above it doesn't work. However, if I put '7 in range("A1"), it works. I have been searching overall the web including Searching for Leading Apostrophes (Microsoft Excel) with this code:


For Each c In Selection If c.PrefixCharacter = "'" Then c.Value = c.Value End If Next c

Nothing seems to work for me
</pre>
 
Upvote 0
The apostrophe just marks the cell as text. There's no need to remove it, but you can do

Code:
With Range("A1")
        .Value = .Formula
End with
 
Upvote 0
Thanks shg. I counted len('USB), it returns 3. I think I will just leave it alone, but it just bugs me visually when I see the (') after I cleaned it.
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,003
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top