• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

A little help on the code logic

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.

Capture.JPG
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
 
Back
Top