Current (Last Active) Cell in inactive worksheet

C

Clif McIrvin

Excel 2003

Is there a way to discover the "current" cell of an inactive worksheet?

If I tab between worksheets, they always remember the last ActiveCell
.... I'm looking for something along the lines of
Sheets(x).LastActiveCell.

Is this information accessible via VBA?
 
D

Dave Peterson

You can select the other sheet, find the activecell and then change back.

In code...

Option Explicit
Sub testme()

Dim CurLoc As Range
Dim OtherLoc As Range

Set CurLoc = ActiveCell

Application.ScreenUpdating = False
Worksheets("sheet2").Select
Set OtherLoc = ActiveCell
Application.Goto CurLoc
Application.ScreenUpdating = True

MsgBox CurLoc.Address(0, 0) & vbLf & OtherLoc.Address(0, 0)
End Sub

The .screenupdating stuff will prevent the user from even knowing that you
changed sheets.
 
C

Clif McIrvin

Ahh, yes ... ScreenUpdating ... I didn't even think of that.

Sheets("Sheet1").Activate is what I was doing while awaiting a reply.

Thanks!!
 

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