Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default Adding up filtered list..........only what is shown on screen?

Thanks Tom, I will re-post my code as I have also added the print
function and im not touching it anymore now as it works!!

Many thanks

Duncan

Private Sub CommandButton1_Click()

Sheets("sheet1").Select

Dim Date1 As Date, Date2 As Date
Date1 = Format(Date1t.Text, "DD/MM/yyyy")
Date2 = Format(Date2t.Text, "DD/MM/yyyy")

Range("D1").End(xlDown).Offset(1, 0).Select
ActiveCell.Select

Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="=" & CLng(Date1),
Operator:=xlAnd _
, Criteria2:="<=" & CLng(Date2)

LOPRdaterange.Hide

Select Case MsgBox("Print?", vbYesNo)
Case vbYes
'will put something here to print out the sheet
Sheet1.Activate
Set rng = Range("A1:I" & Range("a65536").End(xlUp).Row)
rng.Select
Selection.PrintOut Copies:=1, Collate:=True


With Worksheets("Sheet1")
Set rng = Intersect(.AutoFilter.Range, .Columns(7))
s = Application.Subtotal(9, rng)
MsgBox s
LOPRtot.Value = s
End With


With Worksheets("Sheet1")
Set rng = Intersect(.AutoFilter.Range, .Columns(8))
s2 = Application.Subtotal(9, rng)
MsgBox s2
LOPRus.Value = s2
End With

Selection.AutoFilter
LOPRdaterange.Show
Exit Sub

Case vbNo
'will replicate the above here so it still populates the form with
figures
With Worksheets("Sheet1")
Lastrow = .Cells(Rows.Count, "G").End(xlUp).Row
s = 0
For i = 2 To Lastrow
If .Rows(i).Hidden = False Then s = s + .Cells(i, "G")
Next i
End With
LOPRtot.Value = s

With Worksheets("Sheet1")
Lastrow2 = .Cells(Rows.Count, "H").End(xlUp).Row
s2 = 0
For j = 2 To Lastrow2
If .Rows(j).Hidden = False Then s2 = s2 + .Cells(j, "H")
Next j
End With
LOPRus.Value = s2

Selection.AutoFilter
LOPRdaterange.Show

Exit Sub
End Select

Sheets("sheet1").Select

End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
' Prevents use of the Close button
If CloseMode = vbFormControlMenu Then
MsgBox " Clicking this button will not work. " & vbCrLf
& "" & vbCrLf & " Please use the Close button provided below "
Cancel = True
End If
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
Convert 29.08 hours (shown in decimal form) to time shown in "hh:m Nila in Florida Excel Worksheet Functions 1 September 14th 08 01:35 AM
Tracked changes not shown on screen. Susan Talcott Excel Discussion (Misc queries) 0 January 17th 07 04:53 PM
adding numbers shown in cells, not what is actually in cell - help!!! nelsonsdavis Excel Worksheet Functions 2 January 6th 07 08:22 PM
Column of Text Shown = Total Times Shown? philcassell Excel Worksheet Functions 3 July 19th 06 07:24 AM
Named Ranges shown (or not shown) as blue means what? wdeleo Excel Worksheet Functions 0 July 8th 05 01:40 PM


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

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"