Tab Button on Excel

Posted on 2002-06-06
Last Modified: 2011-04-14
Good Day, Have another knowledge question. I have an excel worksheet. What i am trying to figure out is when the user is on a certain cell say for example on my sheet cell ag26 and hits the tab button, it will automatically initiate a macro. How do i go about setting this up. These are the cells i need this to happen on. ag26,ag28,ag30,ag32,ag34. Any help would be greatly appreciated

Question by:sandramac
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
LVL 16

Expert Comment

ID: 7060362
First, in your macro you have to check for activecell, it active cell is in range proceed, else exit the macro.
Second, Why to use Tab (key?)?
You can assign a Hotkey to a macro but it is a combination not only Tab.
LVL 16

Expert Comment

ID: 7060382
Go to Tools, Macro, Macros.
select macro name and push in Options button
Type the hotkey

Author Comment

ID: 7061522
You would not know how this code would be written would you. THe main thing is how do i have the active cell compare to the range i need.
LVL 16

Expert Comment

ID: 7063848
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Select Case Target.AddressLocal
Case "$AG$26", "$AG$28", "$AG$30", "$AG$32", "$AG$34"
    Call YourMacro
Case Else
    ' do nothing
End Select

End Sub
LVL 16

Accepted Solution

Richie_Simonetti earned 75 total points
ID: 7063851
'or in YourMacro (activated by hotkey):
sub MyMacro()
Select Case activecell.AddressLocal
Case "$AG$26", "$AG$28", "$AG$30", "$AG$32", "$AG$34"
   'do your stuff here
Case Else
   ' do nothing
End Select

end sub

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question