ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command button macro query (https://www.excelbanter.com/excel-programming/295131-command-button-macro-query.html)

BeSmart[_2_]

Command button macro query
 
Hi al
Is there a function (eg Shift Cntrl R) or maybe I need to create a command button that when clicked, will return the user to the last cell they entered

Currently the user enters data on a row, then scrolls down heaps of rows (in which other data is entered) to the totals row (or they use the name box to select a defined cell that refers to the totals they want) and they check the results. They then want to return to the cell they just entered but are finding it cumbersome to find it

Any help would be greatly appreciated.

Bob Flanagan

Command button macro query
 
It is not elegant, but the user can click on Edit, Undo, and then Edit, Redo
and that will put them back to the last modified cell and the cell will be
as modified.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"BeSmart" wrote in message
...
Hi all
Is there a function (eg Shift Cntrl R) or maybe I need to create a command

button that when clicked, will return the user to the last cell they
entered?

Currently the user enters data on a row, then scrolls down heaps of rows

(in which other data is entered) to the totals row (or they use the name box
to select a defined cell that refers to the totals they want) and they check
the results. They then want to return to the cell they just entered but are
finding it cumbersome to find it.

Any help would be greatly appreciated.




Anders S[_2_]

Command button macro query
 
BeSmart,

Here's one possible way to get started.

*** Enter the following code in the worksheet code window (right-click the worksheet tab and choose View Code)

'-----
Option Explicit

Public LastEnteredCell As Range

Private Sub Worksheet_Change(ByVal Target As Range)
Set LastEnteredCell = Target
End Sub

Sub goBack()
LastEnteredCell.Select
End Sub
'-----

*** To assign the shortcut - Ctrl+Shift+R - do ToolsMacroMacros, select goBack, click Options and enter R in the shortcut box.

HTH
Anders Silven


"BeSmart" skrev i meddelandet ...
Hi all
Is there a function (eg Shift Cntrl R) or maybe I need to create a command button that when clicked, will return the user to the last cell they entered?

Currently the user enters data on a row, then scrolls down heaps of rows (in which other data is entered) to the totals row (or they use the name box to select a defined cell that refers to the totals they want) and they check the results. They then want to return to the cell they just entered but are finding it cumbersome to find it.

Any help would be greatly appreciated.


kkknie[_43_]

Command button macro query
 
If I read the original post correctly, the user will be entering mor
than one piece of data in the lower rows. Therefore the simpl
worksheet_change suggestion probably won't do the trick. (You did sa
it was only to get them started...)

But, building on it a bit, you could use an array and save the last 1
positions (or more if you wanted). My solution doesn't have a "g
forward" option, but it could be implemented using an array inde
pointer. Give this a shot:


Code
-------------------
Dim adrLast(10) As String

Private Sub Worksheet_Change(ByVal Target As Range)

Dim i As Integer

For i = 1 To 10
adrLast(i) = adrLast(i - 1)
Next
adrLast(0) = Target.Address

End Sub

Sub GoBack()

Dim i As Integer

Range(adrLast(0)).Select
For i = 1 To 10
adrLast(i - 1) = adrLast(i)
Next

End Su
-------------------

Also in the worksheet module of the worksheet in question just lik
Anders suggested

--
Message posted from http://www.ExcelForum.com


BeSmart[_2_]

Command button macro query
 
Thanks guys - I tried Ander S's solution and it works brilliantly
Muchly appreciation

Anders S[_2_]

Command button macro query
 
Glad to hear that :)

Anders

"BeSmart" skrev i meddelandet ...
Thanks guys - I tried Ander S's solution and it works brilliantly.
Muchly appreciation



All times are GMT +1. The time now is 12:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com