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
  • 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now