Window Message to Verify Data Already typed

M

maperalia

I have a macro which calls “lst†files under specific directory (see macro
below).
Most of the time, the data is not typed accordingly to call the “lst†files.

I wonder if I can get a window message to tell me that "MAKE SURE DATA
TYPED ON CELLS C3, C5 AND C6 MATCH WITH LAB DATA".

Thanks in advance.
Maperalia


Sub List_lst_Files1()
Const basicPath = "S:\GEOTEST\shears\"
Const listSheetName = "List of lst Files"
Dim anyFileName As String
Dim searchFor As String
Dim rOffset As Long
Dim listBaseCell As Range

Application.ScreenUpdating = False

searchFor = basicPath & _
Worksheets("DEFAULTS").Range("C3").Value & "\" & _
Worksheets("DEFAULTS").Range("C5").Value & "*" & _
Worksheets("DEFAULTS").Range("C6").Value & "*.lst"
anyFileName = Dir$(searchFor)
Do While anyFileName <> ""
listBaseCell.Offset(rOffset, 0) = anyFileName
rOffset = rOffset + 1
anyFileName = Dir$ ' gets next match for original 'mask'
Loop
Set listBaseCell = Nothing ' release resource


Application.ScreenUpdating = False

End Sub
 
J

JNW

See changes below (marked with *>*)
--
JNW


maperalia said:
I have a macro which calls “lst†files under specific directory (see macro
below).
Most of the time, the data is not typed accordingly to call the “lst†files.

I wonder if I can get a window message to tell me that "MAKE SURE DATA
TYPED ON CELLS C3, C5 AND C6 MATCH WITH LAB DATA".

Thanks in advance.
Maperalia


Sub List_lst_Files1()
Const basicPath = "S:\GEOTEST\shears\"
Const listSheetName = "List of lst Files"
Dim anyFileName As String
Dim searchFor As String
Dim rOffset As Long
Dim listBaseCell As Range

Application.ScreenUpdating = False
*>* onerror goto ErrRoutine
searchFor = basicPath & _
Worksheets("DEFAULTS").Range("C3").Value & "\" & _
Worksheets("DEFAULTS").Range("C5").Value & "*" & _
Worksheets("DEFAULTS").Range("C6").Value & "*.lst"
anyFileName = Dir$(searchFor)
Do While anyFileName <> ""
listBaseCell.Offset(rOffset, 0) = anyFileName
rOffset = rOffset + 1
anyFileName = Dir$ ' gets next match for original 'mask'
Loop
Set listBaseCell = Nothing ' release resource
*>* Application.screenupdating = false
*>* Exit sub
*>* ErrRoutine:
*>* msgbox "MAKE SURE DATA TYPED ON CELLS C3, C5 AND C6 MATCH WITH LAB DATA"
 

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