LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Select entire rows if between date/time range

Hey,

I have a code that selects between two dates and then goes to another
sheet and looks for all cells (in colum A) that are between thoes
dates and copies the entire row into another spread sheet and emails
it.

Problem is that is not selecting the any of the lines.

Can you please take a look at my code and tell me what I am doing
wrong.

Thanks




----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Workbooks.Open Filename:= _
"\\mascarolinabdc\puball\Data log trending Version 2.0\email sheets
\Cycle email P102.xls"
Sheets("sheet1").Select
Rows("3:200").ClearContents

Workbooks("Data log Trending V2.0.xls").Activate
Sheets("sheet2").Visible = True
Sheets("sheet2").Select
Range("B10").Select
ActiveCell.FormulaR1C1 = "=NOW()-1"

Workbooks.Open Filename:= _
"\\mascarolinabdc\puball\Data log trending Version 2.0\Data log
trending\P102 Datalog trending.xls"
Sheets("Cycles with problems ").Visible = True


Workbooks("P102 Datalog trending.xls").Activate
Sheets("Cycles with problems ").Select

Dim sDate As Date, fDate As Date
Dim ws1 As Worksheet
Set ws1 = Workbooks("P102 Datalog trending.xls").Worksheets("Cycles
with problems ") '<== Change as required

ws1.Activate
With ws1
'assumes dates are in colum A
lastrow = .Cells(Rows.Count, 1).End(xlUp).row
sDate = Workbooks("Data log Trending
V2.0.xls").Worksheets("sheet2").Range("C30").Value
fDate = Workbooks("Data log Trending
V2.0.xls").Worksheets("sheet2").Range("B30").Value
Set dateRng = Range("a1:a" & lastrow)
r = Application.Match(CLng(sDate), dateRng, 1)
If IsError(r) Then
frow = 2 ' first row i.e. start date is before first date in
column A
Else
frow = r
End If
lrow = Application.Match(CLng(fDate), dateRng, 1)

End With

Selection.Copy
Workbooks("Cycle email P102.xls").Activate
Sheets("sheet1").Select
Range("A3").PasteSpecial
Rows("3:3").Select
Selection.Delete Shift:=xlUp
Workbooks("Data log Trending V2.0.xls").Activate
Sheets("sheet2").Select
Range("B30").Select
Selection.Copy
Range("C30").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Sheets("sheet2").Visible = False


Workbooks("Cycle email P102.xls").Activate
Workbooks("P102 Datalog trending.xls").Activate
Sheets("Cycles with problems ").Visible = False
Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "Blank.com"
.CC = ""
.BCC = ""
.Subject = "P102 cycles with issue"
.Body = "Please see attached spread sheet for the latest
datalogs with issues"
.Attachments.Add ("\\mascarolinabdc\puball\Data log trending
Version 2.0\email sheets\Cycle email P102.xls")
.Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

Workbooks("Data log Trending V2.0.xls").Activate
Sheets("sheet2").Visible = False


Workbooks("Cycle email P102.xls").Save
Workbooks("Cycle email P102.xls").Close
Workbooks("P102 Datalog trending.xls").Save
Workbooks("P102 Datalog trending.xls").Close
Workbooks("Data log Trending V2.0.xls").Activate
Sheets("sheet2").Visible = False
Sheets("sheet1").Select
MsgBox ("Email sent")

End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
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
how to select entire rows desired by user Anupam Soral Excel Programming 3 July 15th 08 12:29 PM
Select rows in a date range ryguy7272 Excel Programming 1 March 6th 08 02:43 PM
Select all rows in a date range thomasDrew Excel Programming 1 February 4th 08 08:27 AM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
select entire rows using a contains comparison - an example [email protected] Excel Programming 0 April 5th 06 11:43 PM


All times are GMT +1. The time now is 08:18 AM.

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

About Us

"It's about Microsoft Excel"