Wrox Programmer Forums
|
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
 
Old September 21st, 2004, 10:06 AM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.


 
Old September 21st, 2004, 11:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old September 22nd, 2004, 02:16 AM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old September 22nd, 2004, 09:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old September 28th, 2004, 06:50 AM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Birger, I will try to use merge so.


 
Old September 28th, 2004, 09:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old September 29th, 2004, 02:52 AM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid Cells Abbas C# 2005 1 October 12th, 2007 09:35 AM
Open Form from MSHFlexGrid DoubleClick neo_jakey Pro VB Databases 1 September 8th, 2004 05:18 AM
Open Form from MSHFlexGrid DoubleClick neo_jakey Pro VB 6 2 September 7th, 2004 10:17 AM
Cells MattLeek Excel VBA 2 December 12th, 2003 11:54 AM
SELECT Doubleclick kilika Classic ASP Basics 1 October 3rd, 2003 04:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.