hi:
what i m trying to do is as follows:
i have got a user form on an excel sheet, where i could select several lines, for each line sheet1 is being filtered, criteria1 is the line criteria2 is a textbox, copied onto another sheet and printed out, deselect the line, and move on to the next line, and do the same,
my code is:
but then i get a "RunTime Error '6': 'Overflow' and it highlights line 15
any help would be appreciated
Thank you for your valuable time
what i m trying to do is as follows:
i have got a user form on an excel sheet, where i could select several lines, for each line sheet1 is being filtered, criteria1 is the line criteria2 is a textbox, copied onto another sheet and printed out, deselect the line, and move on to the next line, and do the same,
my code is:
Code:
Private Sub CheckBox1_Click()
Dim iloop As Integer
For iloop = 1 To ListBox1.ListCount
ListBox1.Selected(iloop - 1) = CheckBox1.Value
Next
End Sub
Private Sub CommandButton2_Click()
Dim iloop As Integer
[COLOR=red]For iloop = 1 To ListBox1.ListCount[/color]
If ListBox1.Selected(iloop - 1) = True Then
Call stmt
ListBox1.Selected(iloop - 1) = False
End If
Next
End Sub
Sub stmt()
Dim rngFiltered As Range
Application.ScreenUpdating = False
'Select Sheet To filter
With Sheets("records")
With .Range("A1").End(xlUp)
.AutoFilter
'Select Criteria 1 & 2
.AutoFilter Field:=2, Criteria1:=ListBox1.List(iloop - 1, 0)
.AutoFilter Field:=1, Criteria1:=">=" & DTPicker3
End With
End With
'Copy Filterd Data on to Statement Sheet
Set rngFiltered = Sheets("records").Range("A1").End(xlDown).SpecialCells(xlCellTypeVisible)
rngFiltered.Copy Worksheets("sheet1").Range("a1")
'Clear Clumn B
Sheets("sheet1").Range("B:B").ClearContents
'Enter Customer Name
Sheets("sheet1").Range("A5").Value = ListBox1.List(iloop - 1, 0)
'Clear Filter's on Records Sheet
Sheets("records").ShowAllData
Sheets("sheet1").PrintOut
Range("G1").Select
Application.ScreenUpdating = True
End Sub
but then i get a "RunTime Error '6': 'Overflow' and it highlights line 15
any help would be appreciated
Thank you for your valuable time