+ Reply to Thread
Results 1 to 4 of 4

VBA Double Click issue

Hybrid View

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

    VBA Double Click issue

    Hi to all and thanks in advance for your help.

    It appears that I am doing something incorrectly with Double Click.

    There is a column of random numbers (I use RANDBETWEEN) and two other columns where calculations are performed.

    To add the results of the calculation, I use Doubleclick.

    I am experiencing a problem in which the random number column is refreshing twice instead of once every time I double click on the sheet. If I delete one of the two options, for example { Cells(5, "A") = Cells(5, "A") + Cells(13, "A") Cancel = True } it works perfectly (the column with the random numbers is refreshing one time and not two).

    What am I doing wrong?

    The code I am using is as follows.

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

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

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

    End Sub

  2. #2
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,176

    Re: VBA Double Click issue

    Try disabling the calculation while you make the changes

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    calc = Application.Calculation
    Application.Calculation = xlCalculationManual
    
    Cells(5, "B") = Cells(5, "B") + Cells(16, "B")
    Cancel = True
    
    Cells(5, "A") = Cells(5, "A") + Cells(13, "A")
    Cancel = True
    
    Application.Calculation = calc
    End Sub

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

    Re: VBA Double Click issue

    Quote Originally Posted by ByteMarks View Post
    Try disabling the calculation while you make the changes

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    calc = Application.Calculation
    Application.Calculation = xlCalculationManual
    
    Cells(5, "B") = Cells(5, "B") + Cells(16, "B")
    Cancel = True
    
    Cells(5, "A") = Cells(5, "A") + Cells(13, "A")
    Cancel = True
    
    Application.Calculation = calc
    End Sub
    It seems to work perfectly. Thank you so much!

  4. #4
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,176

    Re: VBA Double Click issue

    Happy to help. Appreciate the feedback.

+ 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. [SOLVED] Double click hide and unhide rows issue
    By MonkeyHorse in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-21-2019, 12:37 PM
  2. [SOLVED] Double Click one sheet and replicate Double Click "mark" on other sheets
    By jeffreybrown in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-14-2018, 08:43 AM
  3. [SOLVED] Double click into cell issue
    By terratushi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2018, 04:34 AM
  4. [SOLVED] Add 1 to target on double click, add 0.5 on shift + double click
    By MarmaladeLover in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2015, 06:59 AM
  5. Changing cell properties with double click, then revert with another double click
    By mweber2525 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-01-2014, 01:40 PM
  6. Copy double-clicked cell to next empty row in different sheet with each double-click
    By erhathaway in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-25-2013, 12:06 AM
  7. [SOLVED] Issue with cell selection on double click and returned value
    By Slyman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2012, 07:16 PM

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