Application-defined or object defined error

dan_pafc

Board Regular
Joined
Aug 16, 2007
Messages
162
Hi

Im trying to run the following code but get getting an error - it only started happening today so im guessing its as a result of an update to MS Office.

Code:
Sub ConvertTextNumberToNumber()
For Each WS In Sheets
On Error Resume Next
For Each r In WS.UsedRange.SpecialCells(xlCellTypeConstants)
If IsNumeric(r) Then r.Value = Val(r.Value)
Next
Next
End Sub

Any ideas?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
In the VB Editor, click Tools - Options, then the General tab, and make sure the Error Trapping is not set to 'Break on all errors'.
 
Upvote 0
Either of the other options is fine - I use Break in class modules myself.
 
Upvote 0
Thats worked so thanks very much Rory - I read a few other forum pages before hand and all other solutions were a lot more complicated and still didnt work.

Appreciate the help!
 
Upvote 0

Forum statistics

Threads
1,203,066
Messages
6,053,330
Members
444,654
Latest member
Rich Cohen

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