Thread: Chart pop-up
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Henk Frigge
 
Posts: n/a
Default Chart pop-up

John,

Thanks for your prompt answer. It works perfectly when I use Alt-F8, but I
want to assign it to a command-button. So, click a command button to go from
sheet to graph and click a command button to return. When I create this
situation in a little workbook for testing, everything works except returning
ot the last cell address. I get teh message - Runtime error '1004' : Activate
method of Range class failed.

Hope you can help me.

tHENKs



"John Michl" wrote:

You could try this code. Put it in a VBA module. You'll need to
change the sheet references to match your sheet names. This requires a
sheet (I called it Sheet1) to capture and save the current active cell
and sheet addresses. You can fire this macro by pressing Alt-F8 then
running "FlipFlop" or assign it to a short cut key combination. Hope
that helps.

- John

Sub FlipFlop()

Dim rngSht As Range
Dim rngCell As Range
Dim sht As Sheets

Set rngSht = Sheets("Sheet1").Range("A1")
Set rngCell = Sheets("Sheet1").Range("A2")

If ActiveSheet.Name < "Chart1" Then
rngSht.Value = ActiveSheet.Name
rngCell.Value = ActiveCell.Address
Sheets("Chart1").Activate
Else
Sheets(rngSht.Value).Activate
Range(rngCell.Value).Activate
End If

End Sub