• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

Tab Button on Excel

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

0
sandramac
Asked:
sandramac
  • 4
1 Solution
 
Richie_SimonettiIT OperationsCommented:
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.
0
 
Richie_SimonettiIT OperationsCommented:
Go to Tools, Macro, Macros.
select macro name and push in Options button
Type the hotkey
0
 
sandramacAuthor Commented:
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.
0
 
Richie_SimonettiIT OperationsCommented:
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
0
 
Richie_SimonettiIT OperationsCommented:
'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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now