Yet another Excel macro question!

  Chris the Ancien 20:15 08 Dec 05
Locked

This is not a 'drop dead' necessity... But...

I'm sure that once in the dim, distant past, I managed to do it; but I don't know how!

I have a macro that can be initiated from any cell on the sheet. The activecell then wanders over the screen doing one or two little tasks. Probably too many to use counters for!

But how can I make it go back to its original position?

I'm sure that I once had a method for determining the activecell position - whilst in a macro - so that I could go back to it. But can I find it? Can I 'eck as like!

  Number 7 22:00 08 Dec 05

How about:


Option Explicit

Dim RowN, ColN As Integer

Sub GetPositionOfActiveCell()

With ActiveCell

RowN = .Row

ColN = .Column

End With

End Sub


Sub ReturnActiveCellToOriginalPosition()

Cells(RowN, ColN).Select

End Sub

  VoG II 22:11 08 Dec 05

Hmm - I somehow missed this..

Agree with Number 7 but if position is important then I would write the values of RowN and ColN to a hidden sheet in case your macro crashes. And call ReturnActiveCellToOriginalPosition(), modified to read the values from the hidden sheet,
when the workbook opens.

  Chris the Ancien 23:30 08 Dec 05

Fed and watered.

VoG™... I thought you must have dozed off or found something much more interesting to do. ;o))

Number 7... Thanks a lot for that. I can't remember this concept or RowM and ColN - so goodness knows what I was thinking I could remember! So I've learnt another new command. I have a 'secret' storage place that I can use for the locations. (Now if I could get Wife.Sit.Quiet to work...)

Won't be until quite late tomorrow that I get a chance, So I'll tender my grateful thanks in advance.

CtA

This thread is now locked and can not be replied to.

What is ransomware and how do I protect my PC from WannaCry?

What I learned from my mentor, Oscar-winning VFX supervisor Phil Tippett

Siri vs Google Assistant