Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Printing / March 2007

Tip: Looking for answers? Try searching our database.

SpecialCells(xlVisible)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Geoff - 30 Mar 2007 17:16 GMT
I am trying to trap the first available non costed date and the last in the
simplified table below.
But instead of:
firstdate = 01 Feb 2007 and lastdate = 03 Mar 2007 the code returns
firstdate = 01 Feb 2007 and lastdate also = 01 Feb 2007

For Each cell In vistbl
 Debug.Print cell.Value & vbTab & cell.Row
Next
Returns:
01/02/2007  2
2
03/03/2007  4
4
   
Can someone please correct me?   
   
T.I.A.

Geoff   
   
Column A                  Column B   
Date                         Cost
01 Feb 2007   
03 Feb 2007    34.62
03 Mar 2007   
04 Mar 2007    50.00
   
Sub GetCostDates()   
   
 Dim tbl As Range, vistbl As Range, cell As Range   
 Dim firstdate As Date, lastdate As Date   
   
 With Sheets(1)   
   
   Set vistbl = Nothing   
   Set tbl = .Range("A2").CurrentRegion   
   .Range("A2").AutoFilter Field:=2, Criteria1:="="      '''filter out
non-blanks   
   Set tbl = tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1)   
   
   On Error Resume Next   
   Set vistbl = tbl.SpecialCells(xlVisible)   
   On Error GoTo 0   
   
   If Not vistbl Is Nothing Then   
     firstdate = .Cells(vistbl.Rows(1).Row, 1)   
     lastdate = .Cells(vistbl.Rows(vistbl.Rows.Count).Row, 1)   
   Else   
     firstdate = 0   
     lastdate = 0   
   End If   
   
   .Range("A2").AutoFilter   
   
   End With   
   
End Sub
Geoff - 30 Mar 2007 17:28 GMT
Sorry please ignore - wrong forum - should have been programming
Geoff

> I am trying to trap the first available non costed date and the last in the
> simplified table below.
[quoted text clipped - 54 lines]
>    
> End Sub   
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.