Why type mismatch - R/T error 13

  • Thread starter Thread starter Jim May
  • Start date Start date
J

Jim May

I was/am trying to assist a previous OP (you'll possibly see it below) -
anyhow
my code at present is bombing at the last line presented below:
Any assistance appreciated..

Sub Tester()
Dim CurrDate As Date
Dim Nxtrow As Long
Dim TargRange As Range
CurrDate = Sheets("CallerInput").Range("B29")
Set TargRange = Worksheets("Infoloader").UsedRange.Columns(1)
For Each c In TargRange
If c.Value = CurrDate Then <<<<<<<<< Bomb !!
 
Try being more explicit:

For Each c In TargRange
becomes
For Each c In TargRange.Cells

And .usedrange.columns(1) may be column A. I think the OP wants to check column
B.

(And don't forget to "dim C as range" <vbg>.)
 
ps. before you do that change, try adding
msgbox c.address

and you'll see why it blows up. Trying not to give it away. That type of range
doesn't have a .value.
 
Thanks Dave for the help.
Before your ps note (below) I had already modified code so unable to try
"msgbox c.address" suggestion. Now realize how any "For each" needs
".cells" on end of a set rng. I'm getting there - thanks to guys like
you...
Jim May
 
It doesn't always need it. But if you want to cycle through the cells, it never
huts to add it.

Thanks Dave for the help.
Before your ps note (below) I had already modified code so unable to try
"msgbox c.address" suggestion. Now realize how any "For each" needs
".cells" on end of a set rng. I'm getting there - thanks to guys like
you...
Jim May
 
Dave thanks you for the response; I actually understood what
you were saying as I read your words << this is a rarity - for me.
appreciate you,
Jim

As i read your
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top