Error Handling

SBF12345

Well-known Member
Joined
Jul 26, 2014
Messages
614
I would like to use an error handling statement to define string variable if an error occurs. The error has the potential to occur if the value of RngEnd is near enough to the top of the sheet to return a value that would be outside of the sheet. How can I do this so that the error handling method is only used during this line of code?

Code:
RngFutureR = RngEnd.Offset(-25, 0).Address

I would like to write something like

Code:
On Error RngFutureR = string value
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
What about

Code:
On Error GoTo errHandler
[COLOR=#333333]RngFutureR = RngEnd.Offset(-25, 0).Address

[/COLOR]errHandler:
[COLOR=#333333]RngFutureR = string value[/COLOR]
 
Upvote 0
Rather than an error handler, how about
Code:
If rngEnd.Row < 26 Then
   RngFutureR=???
Else
   RngFutureR = rngEnd.Offset(-25, 0).Address
End If
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,402
Messages
6,124,708
Members
449,182
Latest member
mrlanc20

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