adding a toolbar function to an excel cell

C

Colin Hayes

Hi

I'm trying to run a toolbar function (Refresh All) , from cell M20.

I'd rather do this than have it placed on the toolbar.

Is it possible to do this?

Grateful for any advice.



Best Wishes
 
F

FSt1

hi
you can't put the icon refresh all in the cell but you could use the before
double click event on the cell to run a macro.
right click the sheet that contains the cell you want to activate the refresh.
click view code and paste this macro in the code window.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Target, Range("M20")) Is Nothing Then
ActiveWorkbook.RefreshAll
Else
Exit Sub
End If
End Sub

careful. the first line wrapped.

post back if problems.

Regards
FSt1
 
C

Colin Hayes

Hi

OK thanks for you help with this.

I'm afraid I can't unscramble the code. I inserted it into the sheet ,
but it gives error after error when I try to apply it.

It seems to have lost all formatting in the email , so I don't know
where to split the lines , unfortunately.

Best wishes
 
G

Gord Dibben

Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("M20")) Is Nothing Then
ActiveWorkbook.RefreshAll
Else
Exit Sub
End If
End Sub

The <space_> after ByVal is known as a "continuation character" and allows
long lines of code to be be wrapped.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top