+ Reply to Thread
Results 1 to 11 of 11

Double click activation from another sheet

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    Athens
    MS-Off Ver
    Excel 2016
    Posts
    65

    Double click activation from another sheet

    Hi to everyone and thanks in advance for your help!

    I am using the "Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean" option in Sheet1 on excel and I want to activate it from another Sheet.

    So, when I am in the Sheet2, I want to double click somewhere and give an order to Sheet1 to run the "Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean".

    Is there any code or command that I can use?
    Last edited by komhs; 12-29-2022 at 10:46 AM.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Double click activation from another sheet

    In Sheet1

    Please Login or Register  to view this content.

    In Sheet2
    Please Login or Register  to view this content.

    Double-clicking in D1 on Sheet2 should give the same as double-clicking A1 in Sheet1

  3. #3
    Registered User
    Join Date
    12-17-2012
    Location
    Athens
    MS-Off Ver
    Excel 2016
    Posts
    65

    Re: Double click activation from another sheet

    Quote Originally Posted by ByteMarks View Post
    In Sheet1

    Please Login or Register  to view this content.

    In Sheet2
    Please Login or Register  to view this content.

    Double-clicking in D1 on Sheet2 should give the same as double-clicking A1 in Sheet1
    I am doing something wrong and it doesn't work?

    In Sheet1 (the real name is: Experiment 1500)
    I have this code:


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

    calc = Application.Calculation
    Application.Calculation = xlCalculationManual

    If Target.Address = "$A$1" Then
    MsgBox "You double-clicked A1 on Sheet1"
    End If

    Cells(5, "B") = Cells(5, "B") + Cells(16, "B")
    Cancel = True

    Cells(5, "A") = Cells(5, "A") + Cells(13, "A")
    Cancel = True

    Cells(8, "A") = Cells(8, "A") + Cells(21, "AD")
    Cancel = True

    Cells(10, "B") = Cells(10, "B") + Cells(13, "B")
    Cancel = True

    Cells(5, "C") = Cells(5, "C") + Cells(15, "C")
    Cancel = True

    Cells(10, "C") = Cells(10, "C") + Cells(16, "D")
    Cancel = True

    Cells(5, "D") = Cells(5, "D") + Cells(13, "C")
    Cancel = True

    Cells(8, "C") = Cells(8, "C") + Cells(15, "D")
    Cancel = True

    Application.Calculation = calc
    End Sub


    In Sheet2 (the real name is Dashboard) I pasted what you have sent. I just changed the D1 to W1

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Address = "$W$1" Then
    Application.Run "Sheet1.Worksheet_BeforeDoubleClick", Sheet1.Range("A1"), False
    End If
    End Sub

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Double click activation from another sheet

    It might be easier you separate out the double-click code and then call the routine from both events.

    So in Sheet1
    Please Login or Register  to view this content.
    Then in Sheet2
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-17-2012
    Location
    Athens
    MS-Off Ver
    Excel 2016
    Posts
    65

    Re: Double click activation from another sheet

    Quote Originally Posted by ByteMarks View Post
    It might be easier you separate out the double-click code and then call the routine from both events.

    So in Sheet1
    Please Login or Register  to view this content.
    Then in Sheet2
    Please Login or Register  to view this content.
    It shows an error

    Run-time error '424'
    Object required

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Double click activation from another sheet

    I'm not getting an error. Which line is it on?

  7. #7
    Registered User
    Join Date
    12-17-2012
    Location
    Athens
    MS-Off Ver
    Excel 2016
    Posts
    65

    Re: Double click activation from another sheet

    At

    Set Target = .Range(Target.Address)

    Capture.JPG
    Last edited by komhs; 12-29-2022 at 02:46 PM.

  8. #8
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Double click activation from another sheet

    It's because it's Sheet15 not Sheet1.

    Here's the same thing using the tab description which should fix it.


    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-17-2012
    Location
    Athens
    MS-Off Ver
    Excel 2016
    Posts
    65

    Re: Double click activation from another sheet

    Quote Originally Posted by ByteMarks View Post
    It's because it's Sheet15 not Sheet1.

    Here's the same thing using the tab description which should fix it.


    Please Login or Register  to view this content.
    And I must change and this?
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Call Sheet1DoubleClick(Target, Cancel)
    End Sub

    Or I leave it as it is?


    And if I must change it, how am I going to do it?

    Sorry. I feel silly for asking so dummy questions.

  10. #10
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Double click activation from another sheet

    Not at all, it's a good question.
    Although I called it Sheet1DoubleClick, that was just a name of the routine I created. You could really call it anything.
    For example, if you wanted to call it ABC you'd change the name of the procedure

    Please Login or Register  to view this content.
    and then change it accordingly where you 'call' it.
    e.g.

    So in the Experiment sheet.
    Please Login or Register  to view this content.
    and then in the Dashboard sheet
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-17-2012
    Location
    Athens
    MS-Off Ver
    Excel 2016
    Posts
    65

    Re: Double click activation from another sheet

    Quote Originally Posted by ByteMarks View Post
    Not at all, it's a good question.
    Although I called it Sheet1DoubleClick, that was just a name of the routine I created. You could really call it anything.
    For example, if you wanted to call it ABC you'd change the name of the procedure

    Please Login or Register  to view this content.
    and then change it accordingly where you 'call' it.
    e.g.

    So in the Experiment sheet.
    Please Login or Register  to view this content.
    and then in the Dashboard sheet
    Please Login or Register  to view this content.
    Thank you so much for your help and your patience!!!
    Last edited by komhs; 12-29-2022 at 09:19 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Before DoubleClick
    By jevicha2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2022, 07:41 PM
  2. Dashboard help! Data from columns showing in the correct boxes on dashboard
    By MattExcelLearner in forum Excel Formulas & Functions
    Replies: 35
    Last Post: 06-27-2019, 11:10 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1