VBA ignore error

Akbarov

Active Member
Joined
Jun 30, 2018
Messages
347
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am using VBA loop to get value from range.
Most of cells have values, but some cells has #NUM error.
VBA works fine until first #NUM error.

How can I ignore or make it copy "This cell has error" text instead of #NUM ?

VBA Code:
sld.Shapes("$element4").TextFrame.TextRange.Text = Sh.Range("F80").Offset(0, i).Value
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
put before it
VBA Code:
On Error Resume Next
 
Upvote 0
Hello,

.....
How can I ignore or make it copy "This cell has error" text instead of #NUM ?

Ignoring error (unless you are 100% sure of what you are doing) is never recommended. Handle it properly.

Is this what you are trying (UNTESTED)?

VBA Code:
If IsError(Sh.Range("F80").Offset(0, i).Value) Then
    sld.Shapes("$element4").TextFrame.TextRange.Text = "This cell has error"
Else
    sld.Shapes("$element4").TextFrame.TextRange.Text = Sh.Range("F80").Offset(0, i).Value
End If
 
Upvote 0
Solution

Forum statistics

Threads
1,215,343
Messages
6,124,398
Members
449,155
Latest member
ravioli44

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