#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default copy dates

Can I have the module hereunder modified in three ways (1) Have it copy
the new dated under the last copy date in sheet two (2) The copy
information must sent to sheet2 stating form a3 downward and (3) I need
to copy information from about ten worksheet sheet in order of date
to worksheet 2

Sub FindDates()
On Error GoTo errorHandler
Dim startDate As String
Dim endDate As String
Dim startRow As Integer
Dim endRow As Integer
startDate = InputBox("Enter the Start Date: (mm/dd/yyyy)")
If startDate = "" Then End
endDate = InputBox("Enter the End Date: (mm/dd/yyyy)")
If endDate = "" Then End
startDate = Format(startDate, "mm/dd/yyyy")
endDate = Format(endDate, "mm/dd/yyyy")
startRow = Worksheets("sheet1").Columns("a").Find(startDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
endRow = Worksheets("sheet1").Columns("a").Find(endDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
Worksheets("sheet1").Range("A" & startRow & ":A" & endRow) _
.Resize(, 4).Copy Destination:= _
Worksheets("sheet2").Range("a1")
End
errorHandler:
MsgBox "There has been an error: " & Error() & Chr(13) _
& "Ending Sub.......Please try again", 48
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default copy dates

Sub FindDates()
On Error GoTo errorHandler
Dim startDate As String
Dim endDate As String
Dim startRow As Integer
Dim endRow As Integer
Dim rng as Range
Dim v as Variant
v = Array("Sheet1", "Sheet3", "Sheet4", _
"Sheet5", "Data", "Day6", . . . )
startDate = InputBox("Enter the Start Date: (mm/dd/yyyy)")
If startDate = "" Then exit sub
endDate = InputBox("Enter the End Date: (mm/dd/yyyy)")
If endDate = "" Then exit sub
startDate = Format(startDate, "mm/dd/yyyy")
endDate = Format(endDate, "mm/dd/yyyy")
for i = lbound(v) to ubound(v)
sName = v(i)
startRow = 0
endRow = 0
On Error Resume Next
startRow = Worksheets(sName).Columns("a").Find(startDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
endRow = Worksheets(sName).Columns("a").Find(endDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
On Error goto ErrHandler
if startRow < 0 and endRow < 0 then
set rng = Worksheets("Sheet2").Cells(rows.count,1).End(xlup)
if rng.row < 3 then
set rng = Worksheets("Sheet2").Range("A3")
else
set rng = rng.offset(1,0)
end if
Worksheets(sName).Range("A" & startRow & ":A" & endRow) _
.Resize(, 4).Copy Destination:= rng
End if
Next i
exit sub
ErrorHandler:
MsgBox "There has been an error: " & Error() & Chr(13) _
& "Ending Sub.......Please try again", 48
End Sub

--
Regards,
Tom Ogilvy

"solid" wrote in message
ups.com...
Can I have the module hereunder modified in three ways (1) Have it copy
the new dated under the last copy date in sheet two (2) The copy
information must sent to sheet2 stating form a3 downward and (3) I need
to copy information from about ten worksheet sheet in order of date
to worksheet 2

Sub FindDates()
On Error GoTo errorHandler
Dim startDate As String
Dim endDate As String
Dim startRow As Integer
Dim endRow As Integer
startDate = InputBox("Enter the Start Date: (mm/dd/yyyy)")
If startDate = "" Then End
endDate = InputBox("Enter the End Date: (mm/dd/yyyy)")
If endDate = "" Then End
startDate = Format(startDate, "mm/dd/yyyy")
endDate = Format(endDate, "mm/dd/yyyy")
startRow = Worksheets("sheet1").Columns("a").Find(startDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
endRow = Worksheets("sheet1").Columns("a").Find(endDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
Worksheets("sheet1").Range("A" & startRow & ":A" & endRow) _
.Resize(, 4).Copy Destination:= _
Worksheets("sheet2").Range("a1")
End
errorHandler:
MsgBox "There has been an error: " & Error() & Chr(13) _
& "Ending Sub.......Please try again", 48
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum value between two dates and copy to new cell dave Excel Worksheet Functions 6 March 7th 10 07:47 PM
Compare dates to copy data Very Basic User Excel Discussion (Misc queries) 4 February 24th 10 04:36 PM
Copy and Pasting Dates Erika Excel Discussion (Misc queries) 2 May 1st 09 01:41 PM
Auto copy dates from one cell to another [email protected] Excel Discussion (Misc queries) 8 January 7th 06 12:26 AM
Copy and paste text and dates Kitty Excel Discussion (Misc queries) 5 March 15th 05 11:03 PM


All times are GMT +1. The time now is 07:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"