By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,730 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,730 IT Pros & Developers. It's quick & easy.

auto fill previous value from onther fileld

P: 1
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
Dec 14 '19 #1
Share this Question
Share on Google+
2 Replies


P: 51
Expand|Select|Wrap|Line Numbers
  1. 'Process when the cell value changes
  2. Private Sub Worksheet_Change(ByVal Target As Range)
  3.  If InStr(Target.Address, ":") <> 0 Then Exit Sub
  4. 'Execute processing if "A" is included in the address of the argument Target
  5. 'StrConv and Lcase are case insensitive
  6.  If InStr(Target.Address, "A") <> 0 Then
  7.      MsgBox "Entered in column A", vbInformation
  8.   End If
  9. End Sub
Dec 16 '19 #2

P: 4
This is a very basic design code for what your asking for... you would just use "MovePrevious" 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.

Expand|Select|Wrap|Line Numbers
  1.     Dim rst As Recordset
  2.     Dim strSQL As String
  3.  
  4.     strSQL = "Select * From [Tbl] Where (criteria)"
  5.     Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
  6.     rst.MoveFirst
  7.  
  8.     Do While (criteria)
  9.         A1 = rst!SQL_Field
  10.  
  11.         rst.MoveNext
  12.     Loop
  13.  
  14.     rst.Close
  15.     Set rst = Nothing
  16.  
4 Weeks Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.