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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi

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


Tony
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,541
Messages
6,120,110
Members
448,945
Latest member
Vmanchoppy

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
Back
Top