PDA

View Full Version : Solved: call a macro from within another macro works then doesn't



yorkie
11-01-2011, 02:41 PM
Hi there,

I'm using a button to run a macro. However what i'd like to do is have a message pop up when the mouse rolls over the button then when the button is clicked it moves to another sheet.
The following shows the popup message



Sub MyMacro1()
Dim shp As Shape
Set shp = ActiveSheet.Shapes("Rectangle 1")
ActiveSheet.Hyperlinks.Add shp, "", "", ScreenTip:="Click button to move to Bank details"
Call MyMacroA
End Sub




Is should call MyMacroA and move to another sheet/range using the following code


Sub MyMacroA()
Sheets("Sheet2").Select
Range("A4").Select

End Sub




However sometimes this works sometimes it doesn't. For the life of me i can't see wha the problems is.
Has anybody got any tips or ideas?
Using Office 2010, on vista and windows 7
Am i asking excel to do too much or does anybody have a simpler way of doing this?
Many thanks in advance

Trebor76
11-01-2011, 06:02 PM
Hi yorkie,

Try this:


Option Explicit
Sub Macro2()
'http://www.vbaexpress.com/forum/showthread.php?t=39640
Dim shp As Shape

With Sheets("Sheet1")
Set shp = .Shapes("Rectangle 1")
.Hyperlinks.Add _
Anchor:=shp, _
Address:="", _
SubAddress:="Sheet2!A4", _
ScreenTip:="Click button to move to Bank details"
End With

End Sub

HTH

Robert

yorkie
11-02-2011, 02:19 PM
Thanks Robert that worked a treat - much appreciated.

Trebor76
11-02-2011, 03:25 PM
You're welcome :)