 |
| Excel VBA Discuss using VBA for Excel programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 21st, 2004, 10:06 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Cells doubleclick
Hi, do you now:
how to know which cells had a double_click? I am using the name of a range. If I merged the cells there is no problem, but, in some case, I would prefer don't merge them.
Thanks.
|
|

September 21st, 2004, 11:11 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
MsgBox ActiveCell.Address
End Sub
..tells you which cell have been doubleclicked.
Don't know what your intentions are re. range.
|
|

September 22nd, 2004, 02:16 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Birger, this is the code that I have wrote:
Private Sub worksheet_beforedoubleclick(ByVal Target As Excel.Range, _
Cancel As Boolean)
'Block 1
Set Vrange = Range("Diffusion_Feed_Water")
'If cells = Diffusion_Feed_Water were pressed:
If Union(Target, Vrange).Address = Target.Address Then
â¦..
endif
I have the name ("Diffusion_Feed_Water") defined for the group o f cells that I need.
if the range ("Diffusion_Feed_Water") are not merged, it doesnât work.
Thanks
|
|

September 22nd, 2004, 09:49 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It's because you're trying to compare a single cell address with a range address.
To my knowledge it's not possible to get the range-name the cell belongs to by activating/clicking the cell. If possible i'd like to know myself.
Consider this. You have 2 named ranges:
Large=Sheet1!$A$1:$A$3
Small=Sheet1!$A$2
Which rangename would you expect to receive when you doubleclick cell A2 ?
Merged cells are regarded as one single cell with one address only. The address it receives is the top left cell of all the merged cells. In that case you may compare.
|
|

September 28th, 2004, 06:50 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Birger, I will try to use merge so.
|
|

September 28th, 2004, 09:00 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You're welcome - and a 'not so Pro' workaround could be to change the backcolor of the group. Then read the color when you doubleclick a cell to determing which group it belongs to. There are drawbacks, however (maintenance, overlapping ao), but in some situations it could be used.
|
|

September 29th, 2004, 02:52 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I can't use this sugestion in this project (they wouldn't be very impressed with a so colorful screen), but it is another way to do it, and I am sure in the future I will use it.
Thanks birger.
|
|
 |