auto fill previous value from onther fileld

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tilala
    New Member
    • Dec 2019
    • 1

    auto fill previous value from onther fileld

    I Have Few product name with code every day i want add new new value but i need auto fill previous value
    like Column A1, A2, A3 and A4
    A4 = A1-A2+A3
    when i add new date than i need Previous Value from A4 in A1
  • SioSio
    Contributor
    • Dec 2019
    • 272

    #2
    Code:
    'Process when the cell value changes
    Private Sub Worksheet_Change(ByVal Target As Range)
     If InStr(Target.Address, ":") <> 0 Then Exit Sub
    'Execute processing if "A" is included in the address of the argument Target
    'StrConv and Lcase are case insensitive
     If InStr(Target.Address, "A") <> 0 Then
         MsgBox "Entered in column A", vbInformation
      End If
    End Sub
    Last edited by gits; Dec 16 '19, 08:53 AM. Reason: added code tags - use them when posting code

    Comment

    • Buk1tH3d
      New Member
      • Dec 2019
      • 4

      #3
      This is a very basic design code for what your asking for... you would just use "MovePrevio us" to get to the previous record and get your previous value in the recordset. Hope this gets you close enough to work the rest out on your own.

      Code:
          Dim rst As Recordset
          Dim strSQL As String
          
          strSQL = "Select * From [Tbl] Where (criteria)"
          Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
          rst.MoveFirst
      
          Do While (criteria)
          	A1 = rst!SQL_Field
      
          	rst.MoveNext
          Loop
      
          rst.Close
          Set rst = Nothing

      Comment

      Working...