Small code problem...skipping found variable

Hlatigo

Well-known Member
Joined
Jun 3, 2002
Messages
677
I have some code that searches for a certain value and once it is found it than looks for the current date at that point there is a vlookup and pulls in a price. The code is working but when it does have the current date it just skips of the statement that it should run. Any thoughts?

I thought i needed to format the column as date but that hasnt worked. thatnks for your help.


Code:
Sub price_updte()

    Sheets("proposal").Activate
    Range("D65536").End(xlUp).Select
    Range(Selection, Selection.End(xlUp)).Select
    With Selection
        .NumberFormat = "m/d/yyyy"
    End With

   Dim cell As Range
   For Each cell In Range("B1:B500")
      Select Case cell.Value
         Case 79 To 81, 142 To 143
               If cell.Offset(0, 2).Value = Now() Then
                  cell.Offset(0, 5).Value = WorksheetFunction.VLookup(cell.Offset(0, -5), _
                  Sheets("currentprice").Range("D12:G16"), 2, False)
               End If
      End Select
   Next cell
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

First thought - change now() to date. Now() will contain a time component but your data may not???


Tony
 

Hlatigo

Well-known Member
Joined
Jun 3, 2002
Messages
677
Hi there Tony,

I thought about that too and I used so many different ways to format that as well. But still no go. I did use your method and it stills doesnt recognize that the two values are equal so it can execute the then statement.

I was thinking...the column with the current date is being populated by a input box...would that make much of a difference?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
63,302
Office Version
  1. 365
Platform
  1. Windows
the column with the current date is being populated by a input box...would that make much of a difference?
Make sure that the date is actually being entered as a date and not text. In an Excel formula, you can use DATEVALUE function to convert text to a date.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,020
Messages
5,834,989
Members
430,331
Latest member
Syed Yasir Hannan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top