+ Reply to Thread
Results 1 to 3 of 3

Changing code from Manual input to Calculated input

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2007
    Posts
    10

    Changing code from Manual input to Calculated input

    I have the below code, which updates the last entered value of column B into column D, when the value in column B is MANUALLY entered. I need it to update when a FORMULA changes the value, rather than a MANUAL input. I am a complete novice, so may you re-post the whole code with the changes, so that I can just copy and paste, please.

    Thanks you so much.


    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False

    If ColTo <> 0 Then
    Cells(Target.Row, ColTo).Value = OldValue
    Cells(Target.Row, ColTo + 1).Value = Date
    End If

    ColTo = 0
    Application.EnableEvents = True

    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    Application.EnableEvents = False
    OldValue = Target.Value
    Select Case Target.Column
    Case 2: ColTo = 4
    Case 6: ColTo = 11
    Case Else
    End Select

    Application.EnableEvents = True
    End Sub

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,966

    Re: Changing code from Manual input to Calculated input

    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing.
    Select/hi-lite your code and click the [#] button at the top of the editor window (if you are editing an existing post, press Go Advanced to see the [#] button). The result will appear like this in the edit window:

    [code]
    your code here ...
    and here ...
    and here
    [/code]

    ... and appear like this when posted:

    Please Login or Register  to view this content.
    You can also type the code tags in manually if you prefer.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    05-15-2012
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Changing code from Manual input to Calculated input

    Cheers Ben,

    The code below works, but not when column B is changed by a formula. Only when it is manually entered. What needs to be changed to make it so the result of a formula changes it?

    Please Login or Register  to view this content.
    Last edited by Gertheking; 05-16-2012 at 11:49 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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