variable not defined

C

Carlee

Hi there,

I am trying to use this code to make sure a value doesn't exist in the
Copreco Master Log. I get an error that says 'variable not defined' and it
highlights ' the "mydate" row.

I am not sure what is wrong...any ideas?


Assumes both workbooks are open:
Sub ckDte()
Dim wkb1 as Workbook
Dim wkb2 as workbook
Set wkb1 = Workbooks("Corpreco Daily Reading Submission.xls")
Set wkb2 = workbooks("Corpreco Master Log.xls")
myDte = wkb1.Sheets("Sheet1").Cells(2, 1).Value
For Each c In wkb2.Sheets("Daily Reading Master Log").Range("B2:B" & Cells
_(Rows.Count, 2).End(xlUp).Row)
If c = myDte Then
MsgBox "Date Found"
Exit Sub
End If
Exit Sub
 
S

Susan

carlee, carlee, carlee............. ha ha

"mydate" is a variable.
"mydate" is not defined.
EVERYTHING has to be defined.............. :D
you made a good start with
Dim wkb1 as Workbook
Dim wkb2 as workbook

but then you refer to the following variables without declaring them:
"mydate" & "c"

Dim myDate as _____________
Dim c as __________________
:)
susan
 

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

Top