Type mismatch

SamS

Well-known Member
Joined
Feb 17, 2002
Messages
542
I have a header row that contains text and dates, the dates are formatted as Sep-02 etc. and am using an input box to loop through each cell till I find the correct date eg
Item Descr Qty Jul-02 Aug-02 Sep-02

The code I was using is something like this:

Dim Month as Date
Month = InputBox("Please enter the month eg Sep-02")

Range("A2").Select

Do While ActiveCell.Value <> Month
ActiveCell.Offset(0, 1).Select
Loop

This gives an error message on the first cell as it is Text and not a Date. In the past I've usually had the header formatted as text and been able to work around the problem but in this case it is not an option to change the format.

I hate working with dates.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I've got you all fixed up. Take a look at the email I sent you. I fixed the problem using a UserForm. The same could be done with just plain code too. The UserForm option offers less of a chance for user error. Let me know if you have any questions.
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,822
Members
449,470
Latest member
Subhash Chand

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