MsOf07 Specify a range for worksheet_calculate method for saving records of change-VBForums
Results 1 to 3 of 3

Thread: Specify a range for worksheet_calculate method for saving records of change

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2012
    Posts
    3

    Resolved Specify a range for worksheet_calculate method for saving records of change

    Re: [RESOLVED] Specify a range for worksheet_calculate method
    Wow, excelent work there, Im wondering if you guys could help me in something similar, Im getting live data from a link on my excel spreadsheet, and i got a code that saves the data everytime it changes, the problem is that it only works with worksheet_change, which means it dosent work because it wait for user action to save, now the problem of using worksheet_calculate is that it fires everytime a calculation is donde, and I need it to target it to a change to a specific cell, heres the code i have for saving with the change function, i wanna do exactly the same, but this being triggered by a calculate event on a especific cell:

    Private Sub Worksheet_Change(ByVal target As Range)
    ''Do something only if the value changes in cell A1
    If target.Address = "$CH$4" Then
    ''Look at the full list below the Target title
    With ThisWorkbook.Names("STA10A").RefersToRange.CurrentRegion
    ''Look at the cell at the bottom of the list
    With .Offset(.Rows.Count, 0).Resize(1, 1)
    ''Enter the current time in the cell
    .Value = Now
    ''Enter the new value to the right of the time
    .Offset(0, 1).Value = target.Value
    End With
    End With
    End If
    End Sub

    thanks in advance!

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    22,891

    Re: Specify a range for worksheet_calculate method for saving records of change

    i am not sure what your problem is as the above code will fire every time a calculation is performed, but should only actually do something if the target cell is CH4
    is this not the case?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2012
    Posts
    3

    Re: Specify a range for worksheet_calculate method for saving records of change

    yeah, that's the thing it wont fire when it is a calculation because the Worksheet_Change doesn´t fire with formula calculations. I have the target "CH4", but i want the trigger to be value change by formula in that cell.

    Thanks for your time!

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.