» Search and copy date values using VBA
CATEGORY - Date & Time in VBA
VERSION - All Microsoft Excel Versions
Answer: Insert the following code in the appropriate modules.
Place the code below into the standard module
Sub Marking()
Dim aCell As Range, bCell As Range
Dim Start
Dim Off
On Error GoTo ErrorHandler
Start = CDate(InputBox("Start:"))
Set aCell = Columns(1).Find(DateValue(Start), LookIn:=xlFormulas)
If aCell Is Nothing Then GoTo ErrorHandler
Off = CDate(InputBox("End:"))
Set bCell = Columns(1).Find(DateValue(Off), LookIn:=xlFormulas)
If bCell Is Nothing Then GoTo ErrorHandler
Worksheets("Sheet2").Cells.ClearContents
Rows(aCell.Row & ":" & bCell.Row).Copy Worksheets("Sheet2").Range("A1")
End
ErrorHandler:
Beep
MsgBox "Not valid Date!"
End Sub
Book Store:
Recommended Books:
- Managerial Accounting: Tools for Business Decision Making, WebCT, 2nd Edition
- The Financial Numbers Game: Detecting Creative Accounting Practices
- Special Edition Using Microsoft Excel 2002
- The Total Money Makeover. : A Proven Plan for Financial Fitness
- The Ernst & Young Business Plan Guide
- Business Analysis with Microsoft Excel (2nd Edition)
No comments have been submitted.

