Winston618
Member
Hi,
I am trying to reference a cell's value based on the date I enter. However, I couldn't get it work.
BankInRef.text = the date I enter
For example, 8/5/2017 is the date I enter and it is greater than D2 (8/1/2017) but small than E2 (8/7/2017) then the active cell value should be referencing H2 (8/9/2017). However, the active cell value is always H2 (8/9/2017) even the date I enter is greater than E3 or E4, such as 8/21/2017 or 8/25/2017. The code runs without any error shown.
Please help, thank you very much!
I am trying to reference a cell's value based on the date I enter. However, I couldn't get it work.
BankInRef.text = the date I enter
For example, 8/5/2017 is the date I enter and it is greater than D2 (8/1/2017) but small than E2 (8/7/2017) then the active cell value should be referencing H2 (8/9/2017). However, the active cell value is always H2 (8/9/2017) even the date I enter is greater than E3 or E4, such as 8/21/2017 or 8/25/2017. The code runs without any error shown.
Please help, thank you very much!
Code:
If BankInRef.Text <= Worksheets("money counting schedule").Range("E2").Value Then
ActiveCell.Value = Worksheets("money counting schedule").Range("H2").Value
ElseIf BankInRef.Text >= Worksheets("money counting schedule").Range("D3").Value Or BankInRef.Text <= Worksheets("money counting schedule").Range("E3").Value Then
ActiveCell.Value = Worksheets("money counting schedule").Range("H3").Value
ElseIf BankInRef.Text >= Worksheets("money counting schedule").Range("D4").Value Or BankInRef.Text <= Worksheets("money counting schedule").Range("E4").Value Then
ActiveCell.Value = Worksheets("money counting schedule").Range("H4").Value
ElseIf BankInRef.Text >= Worksheets("money counting schedule").Range("D5").Value Or BankInRef.Text <= Worksheets("money counting schedule").Range("E5").Value Then
ActiveCell.Value = Worksheets("money counting schedule").Range("H5").Value