Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Combo box keyboard shortcut

hello again,

I'm still trying to tune up my combo box, and as I test it, I find
things that need some work to make it smooth. I would like to have it
setup so that the mouse is not required for data entry. It can be used
as an option, just not a required tool.

How do I add a shortcut key to the following code: (This code is in
sheet1)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

Dim ws As Worksheet
Set ws = ActiveSheet

Dim cboTemp As OLEObject
Cancel = True
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If Target.Column = 2 And ActiveSheet.Name = "Timesheet Entry"
Then
Application.EnableEvents = False
With cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 275
.Height = Target.Height + 5
.LinkedCell = Target.Address
End With
cboTemp.Activate
End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub

I've added this line:

Keyboard Shortcut: Ctrl Shift + Z

Without success. I've written a sub to call the doubleclick sub and
attached a shortcut there, to no avail.

If anyone can help, I'd really appreciate it.

Thanks,

Dave

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Combo box keyboard shortcut

in a general module

Public Sub Gravy_code()

Dim ws As Worksheet
Set ws = ActiveSheet

Dim cboTemp As OLEObject
Cancel = True
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If Target.Column = 2 And ActiveSheet.Name = "Timesheet Entry"
Then
Application.EnableEvents = False
With cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 275
.Height = Target.Height + 5
.LinkedCell = Target.Address
End With
cboTemp.Activate
End If

errHandler:
Application.EnableEvents = True
Exit Sub
End Sub

Now
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Call Gravy_code()
End Sub

in Excel, go to tools=Macro=Macros and select
Gravy_code, click options and assign a short cut.

--
Regards,
Tom Ogilvy



"davy_gravy" wrote:

hello again,

I'm still trying to tune up my combo box, and as I test it, I find
things that need some work to make it smooth. I would like to have it
setup so that the mouse is not required for data entry. It can be used
as an option, just not a required tool.

How do I add a shortcut key to the following code: (This code is in
sheet1)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

Dim ws As Worksheet
Set ws = ActiveSheet

Dim cboTemp As OLEObject
Cancel = True
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If Target.Column = 2 And ActiveSheet.Name = "Timesheet Entry"
Then
Application.EnableEvents = False
With cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 275
.Height = Target.Height + 5
.LinkedCell = Target.Address
End With
cboTemp.Activate
End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub

I've added this line:

Keyboard Shortcut: Ctrl Shift + Z

Without success. I've written a sub to call the doubleclick sub and
attached a shortcut there, to no avail.

If anyone can help, I'd really appreciate it.

Thanks,

Dave


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Combo box keyboard shortcut

Hi Tom,

Awesome! I only had to define 'cancel' & 'target' and set target =
activecell, and it worked perfectly.

I've attached the working code below for anyone else with a similar
issue:

In module 1:

Public Sub Combo_box()

'Keyboard Shortcut: Ctrl Shift + Z

Dim cancel As Boolean
Dim target As Range
Set target = ActiveCell

Dim ws As Worksheet
Set ws = ActiveSheet

Dim cboTemp As OLEObject
cancel = True
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If target.Column = 2 And ActiveSheet.Name = "Timesheet Entry"
Then
Application.EnableEvents = False
With cboTemp
.Visible = True
.Left = target.Left
.Top = target.Top
.Width = target.Width + 275
.Height = target.Height + 5
.LinkedCell = target.Address
End With
cboTemp.Activate
End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub

In sheet1's VBE:


Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, cancel
As Boolean)

Call Combo_box

End Sub


Enjoy!

thanks again Tom,

Dave
Tom Ogilvy wrote:
in a general module

Public Sub Gravy_code()

Dim ws As Worksheet
Set ws = ActiveSheet

Dim cboTemp As OLEObject
Cancel = True
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If Target.Column = 2 And ActiveSheet.Name = "Timesheet Entry"
Then
Application.EnableEvents = False
With cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 275
.Height = Target.Height + 5
.LinkedCell = Target.Address
End With
cboTemp.Activate
End If

errHandler:
Application.EnableEvents = True
Exit Sub
End Sub

Now
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Call Gravy_code()
End Sub

in Excel, go to tools=Macro=Macros and select
Gravy_code, click options and assign a short cut.

--
Regards,
Tom Ogilvy



"davy_gravy" wrote:

hello again,

I'm still trying to tune up my combo box, and as I test it, I find
things that need some work to make it smooth. I would like to have it
setup so that the mouse is not required for data entry. It can be used
as an option, just not a required tool.

How do I add a shortcut key to the following code: (This code is in
sheet1)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

Dim ws As Worksheet
Set ws = ActiveSheet

Dim cboTemp As OLEObject
Cancel = True
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If Target.Column = 2 And ActiveSheet.Name = "Timesheet Entry"
Then
Application.EnableEvents = False
With cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 275
.Height = Target.Height + 5
.LinkedCell = Target.Address
End With
cboTemp.Activate
End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub

I've added this line:

Keyboard Shortcut: Ctrl Shift + Z

Without success. I've written a sub to call the doubleclick sub and
attached a shortcut there, to no avail.

If anyone can help, I'd really appreciate it.

Thanks,

Dave



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyboard Shortcut danno-c[_2_] Excel Discussion (Misc queries) 3 November 30th 09 08:14 PM
Keyboard shortcut GKW in GA Excel Discussion (Misc queries) 2 September 14th 08 11:35 PM
Keyboard shortcut for name box hmm Excel Discussion (Misc queries) 4 August 11th 07 01:02 PM
Keyboard Shortcut tc Excel Discussion (Misc queries) 1 June 15th 07 03:09 PM
Keyboard shortcut for Best Fit Ob1Pimpobi Excel Discussion (Misc queries) 1 August 31st 06 01:06 AM


All times are GMT +1. The time now is 11:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"