Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Double click funtionality

I have an Excel form my boss(NOT excel savvy) wants to use in a presentation. The form has two main tables and he wants to be able to double click on a line item in one table and have it transfer to the other table and vice-versa. Is there some way to program this type of functionality to a double click? In the visual basic editor, maybe? How else can I accomplish the same thing and make my boss happy?
--
cyberindio
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Double click funtionality

Use the beforedoubleclick event.

right click on the worksheet tab with the tables and select view code.

In the left dropdown select Workbook and in the right dropdown select
BeforeDoubleClick

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

End Sub

will be placed in the module.

You can then write code in this routine

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel
As Boolean)
Dim rng1 as Range, rng2 as Range, rng3 as Range, rng4 as Range

If target.count 1 then exit sub
set rng1 = Range("Table1")
set rng2 = Range("Table2")
if not intersect(Target,rng1) is nothing and not intersect(Target,rng2) is
nothing then
if not intersect(Target.rng1) is nothing then
set rng3 = Intersect(rng1,Target.EntireRow)
set rng4 = rng2.Columns(1).SpecialCells(xlBlanks)(1)
rng3.copy Destination:=rng4
else
set rng3 = Intersect(rng2,Target.EntireRow)
set rng4 = rng1.columns(1).specialCells(xlblanks)(1)
rng3.copy Destination:=rng4
end if
Cancel = True
End if
End Sub

The above untested code should get you started. Probably needs a bit more
work to do exactly what you want - i.e. did you want to move one line to the
other table. Then you would need to go through source table and removed the
data, then slide the data up as an example.

--
Regards,
Tom Ogilvy


"Cyberindio" wrote in message
...
I have an Excel form my boss(NOT excel savvy) wants to use in a

presentation. The form has two main tables and he wants to be able to double
click on a line item in one table and have it transfer to the other table
and vice-versa. Is there some way to program this type of functionality to a
double click? In the visual basic editor, maybe? How else can I accomplish
the same thing and make my boss happy?
--
cyberindio



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Double click funtionality

Thanks for the code, Tom, but I'm having some trouble. The editor tells me there is an ambiguous name error in the first line of the Module "Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel
As Boolean)". I've experimented some but can't get the code to run.
What might I be doing wrong?

--
cyberindio


"Tom Ogilvy" wrote:

Use the beforedoubleclick event.

right click on the worksheet tab with the tables and select view code.

In the left dropdown select Workbook and in the right dropdown select
BeforeDoubleClick

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

End Sub

will be placed in the module.

You can then write code in this routine

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel
As Boolean)
Dim rng1 as Range, rng2 as Range, rng3 as Range, rng4 as Range

If target.count 1 then exit sub
set rng1 = Range("Table1")
set rng2 = Range("Table2")
if not intersect(Target,rng1) is nothing and not intersect(Target,rng2) is
nothing then
if not intersect(Target.rng1) is nothing then
set rng3 = Intersect(rng1,Target.EntireRow)
set rng4 = rng2.Columns(1).SpecialCells(xlBlanks)(1)
rng3.copy Destination:=rng4
else
set rng3 = Intersect(rng2,Target.EntireRow)
set rng4 = rng1.columns(1).specialCells(xlblanks)(1)
rng3.copy Destination:=rng4
end if
Cancel = True
End if
End Sub

The above untested code should get you started. Probably needs a bit more
work to do exactly what you want - i.e. did you want to move one line to the
other table. Then you would need to go through source table and removed the
data, then slide the data up as an example.

--
Regards,
Tom Ogilvy


"Cyberindio" wrote in message
...
I have an Excel form my boss(NOT excel savvy) wants to use in a

presentation. The form has two main tables and he wants to be able to double
click on a line item in one table and have it transfer to the other table
and vice-versa. Is there some way to program this type of functionality to a
double click? In the visual basic editor, maybe? How else can I accomplish
the same thing and make my boss happy?
--
cyberindio




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
How to change syperlink from single click to double click syperlinker Excel Worksheet Functions 0 June 13th 08 05:01 PM
double click lmb Excel Discussion (Misc queries) 4 September 6th 07 07:38 PM
Double click Anette Denmark Excel Discussion (Misc queries) 10 February 18th 07 04:24 PM
Click on graph bar to execute a double-click in a pivot table cell [email protected] Charts and Charting in Excel 4 August 3rd 05 01:37 AM
Before Double-Click Jim May Excel Discussion (Misc queries) 2 December 18th 04 05:52 PM


All times are GMT +1. The time now is 05:41 AM.

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"