Artificial Intelligence Forum

Ask Question   UnAnswered
Home » Forum » Artificial Intelligence       RSS Feeds

GOBACK subroutine

  Asked By: Morton    Date: Oct 06    Category: Artificial Intelligence    Views: 1408

I'm very, very new to VBA - can someone help explain the following code - first part goes in "insert module" from within the VBE, and the second part is done via view code from the worksheet itself. This code very simply allows your cursor to return to where it was previously, regardless of where you are in a worksheet, multiple times - meaning it will just go back once - not multiple time, but you can use it over and over. I assigned an icon in the ribbon to activate the code I call GOBACK. I want to do what the code says - thanks.

Insert in module:

Option Explicit
Public r As Range
Public oldr As Range
If oldr Is Nothing Then
End If
End Sub

Insert via the workseet:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set oldr = r
Set r = Target
End Sub