View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Selecting ranges by dates


Dim rng as Range, rng1 as Range
Dim ans as String, Target as Long
Dim res as Variant
with worksheets("Sheet1")
set rng = .range(.Cells(2,1),.Cells(2,1).End(xldown))
End with
ans = Inputbox("Enter your date:")
if cdate(ans) then
target = clng(cdate(ans))
res = Application.match(target,rng,0)
if not iserror(res) then
set rng1 = rng(res)
rng1.copy Destination:=worksheets("Sheet2").cells( _
rows.count,1).End(xlup)(2)
else
msgbox ans & " was not found"
end if
else
msgbox ans & " is not a valid date"
end if

--
Regards,
Tom Ogilvy

" wrote:

I am trying to write the code that will allow me to input date ranges
and copy the information by the date that it was entered.