Error Msg Coding Issue

Craw

New Member
Joined
Jul 27, 2011
Messages
32
Greetings,
I have a spreadsheet linked to a SharePointe list. I created a marco that is attached to a command button so that when it is activated it will refresh the data between the Excel spreadsheet and the SharePoint list. However if the user is not connected to the internet or the SharePoint site is down I would like an error msg box to pop-up with the following text in the following format;

Connectivity Issue due to:
- The SharePointe is Currently Down or;
- You are not connected to the Internet or;
- You are using an outside interner connection without VPN

Potential Solutions;
- Please try again in 5 minutes
- If you are using an outside internet connection ensure you are logged into to VPN
- Contact Help Desk at Ext 2555

Please note that I have tried the code shown below but it would not show the error msg. It would just ask me to debug the code or end the function.

Here is the code I have so far;

Code:
Sub Refresh()
'
' Refresh Macro
ActiveWorkbook.RefreshAll
On Error GoTo ErrMsg:
ActiveSheet.ListObjects("Table_owssvr_1").TableStyle = "Table Style 1"
Range("B:B,I:I").Select
Range("I1").Activate
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
Range("A3").Select
End With
 
Exit Sub
ErrMsg:
MsgBox ("Error Message will go here"), , "PLEASE READ"
End Sub
 
Last edited:

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"
I am using 2010 but for some reason if the connection is broken between my comp and the internet it doesn't prompt the error code.? Instead I get run-time error 1004...Any ideas?
 
Upvote 0
Maybe you need to swap these lines:
Code:
ActiveWorkbook.RefreshAll
On Error GoTo ErrMsg:
Also, the colon is not needed there, better leave it out:
Code:
On Error GoTo ErrMsg
ActiveWorkbook.RefreshAll

In your code, if the RefreshAll caused an error, it would not be trapped.
 
Upvote 0
Brilliant swaping the code lines did the trick thank you very much for your help.

Cheers to beers,

Craw
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,818
Members
452,946
Latest member
JoseDavid

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