Advancing from Cell to Cell on Key Press

G

Guest

Hi all, I am in the process of migrating from Lotus 123 to Excel. My macro
for advancing through the various fields in my spreadsheet will neither run
nor translate. Sooooo! I need help. I can select a field for input [
example - Range ("F5").Select] at this point I want the program to suppend
execution while I input information then resume and proceed to the next field
when I press the return key (or another appropriate key). Any Help would be
greatly appreciated.

Thanks,
 
G

Guest

Lotus and Excel function quite differently in terms of macros. Paste this
code into a sheet (right click the tab -> View Code -> Paste) and change the
values of A1, B2, or C3 and trace the code through to see what is happening
(F9 to place a break point ->F8 to advance one line of code at a time).

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
Application.EnableEvents = False 'Place a break point here
Select Case Target.Address
Case "$A$1"
ActiveSheet.Range("B2").Select
Call Message1(Target)

Case "$B$2"
ActiveSheet.Range("C3").Select
Call Message2(Target)

Case "$C$3"
ActiveSheet.Range("A1").Select
Call Change(Target)

End Select
ErrorHandler:
Application.EnableEvents = True
End Sub

Private Sub Message1(ByVal Target As Range)
MsgBox Target.Value & " Changed This"
End Sub

Private Sub Message2(ByVal Target As Range)
MsgBox Target.Value & vbTab & Environ("UserName")
End Sub

Private Sub Change(ByVal Target As Range)
Target.Value = Target.Value & " Changed The Other"
End Sub
 

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