Macro help: msgbox after refresh complete?

blueangel2323

New Member
Joined
Jul 12, 2011
Messages
15
Hi everyone, I have an Excel spreadsheet that is linked to an external data source (table on an intranet page), which is refreshed by clicking on the red exclamation mark. I was wondering if it is possble to have a message box pop up notifying the user when the refresh is complete? I want this to be as user-friendly as possible for non-technical users.

On a side note, how do I make the following code run on only a specific column (let's say A) instead of the entire worksheet, just to speed things up?

Code:
Dim cell As Range
    
For Each cell In Worksheets(1).UsedRange
    cell = Trim(Replace(cell, Chr(160), " "))
Next cell

Thanks!!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
When you refresh the external data source, you should have a status message in the lower left telling you that the external data source is Connecting-Retrieving-Copying-Ready.



Code:
Dim cell As Range

With Worksheets(1)
    For Each cell In [COLOR="Red"].Range("A1", .Range("A" & Rows.Count).End(xlUp))[/COLOR]
        cell = Trim(Replace(cell, Chr(160), " "))
    Next cell
End With
 
Last edited:
Upvote 0
When you refresh the external data source, you should have a status message in the lower left telling you that the external data source is Connecting-Retrieving-Copying-Ready.



Code:
Dim cell As Range
 
With Worksheets(1)
    For Each cell In [COLOR=red].Range("A1", .Range("A" & Rows.Count).End(xlUp))[/COLOR]
        cell = Trim(Replace(cell, Chr(160), " "))
    Next cell
End With

"Compile error: Invalid or unqualified reference"
 
Upvote 0
I would still be interested in having the pop-up msgbox though, to make it more conspicuous for users who aren't technically inclined
 
Upvote 0
This will display a message after the External Data Source has refreshed. It uses the Worksheet_Change event to trigger the message. Change the cell reference in red to the first cell in the range on the worksheet that has your External Data Source.

To install the macro...
  • Right-click on the sheet tab
  • Select View Code in the pop-up menu
  • Paste the code below in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("[COLOR="Red"]B2[/COLOR]"), Target) Is Nothing Then
        MsgBox "Refresh complete. ", , "External Data Source Status"
    End If
End Sub

Caveat: If the user manually edits or changes the one cell in red, they will trigger the message box again.
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,687
Members
452,938
Latest member
babeneker

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