CalibreUnion
Junior Member
- Joined
- Dec 28, 2012
- Messages
- 62
- Reaction score
- 0
hey guys, this is my code I am doing for a simple excel program for school. There seems to be an issue with the filter part as I am unable to use the filter. Anyone could help me out?
Private Sub CommandButton1_Click()
EraseWorkSheetKeepRow1 ("FilteredItems")
Sheets("CustomerInfo").Select
Dim i As Integer
Dim k As Integer
k = Application.WorksheetFunction.CountA(Range("A:A"))
For i = 2 To k
Sheets("CustomerInfo").Select
If Val(Cells(i, 3)) > Val(TextBox1.Text) Then
Call Copy1row("CustomerInfo", i, "FilteredItems")
End If
Next
End Sub
Sub EraseWorkSheetKeepRow1(sheetname As String)
'
' EraseWorkSheetKeepRow1 Macro
' Erase all rows except row 1 for worksheet
ActiveWorkbook.Sheets(sheetname).Select
Dim k As Integer
k = Application.WorksheetFunction.CountA(Range("A:A")) + 1
Range("A2:C" & k).Select
Selection.ClearContents
End Sub
Sub Copy1row(FromSheet As String, rowno As Integer, ToSheet As String)
'
' Copy1row Macro
Sheets(FromSheet).Select
Rows(rowno & ":" & rowno).Select
Selection.Copy
Sheets(ToSheet).Select
Dim k As Integer
k = Application.WorksheetFunction.CountA(Range("A:A")) + 1
Rows(k & ":" & k).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub
Thanks in advance
Private Sub CommandButton1_Click()
EraseWorkSheetKeepRow1 ("FilteredItems")
Sheets("CustomerInfo").Select
Dim i As Integer
Dim k As Integer
k = Application.WorksheetFunction.CountA(Range("A:A"))
For i = 2 To k
Sheets("CustomerInfo").Select
If Val(Cells(i, 3)) > Val(TextBox1.Text) Then
Call Copy1row("CustomerInfo", i, "FilteredItems")
End If
Next
End Sub
Sub EraseWorkSheetKeepRow1(sheetname As String)
'
' EraseWorkSheetKeepRow1 Macro
' Erase all rows except row 1 for worksheet
ActiveWorkbook.Sheets(sheetname).Select
Dim k As Integer
k = Application.WorksheetFunction.CountA(Range("A:A")) + 1
Range("A2:C" & k).Select
Selection.ClearContents
End Sub
Sub Copy1row(FromSheet As String, rowno As Integer, ToSheet As String)
'
' Copy1row Macro
Sheets(FromSheet).Select
Rows(rowno & ":" & rowno).Select
Selection.Copy
Sheets(ToSheet).Select
Dim k As Integer
k = Application.WorksheetFunction.CountA(Range("A:A")) + 1
Rows(k & ":" & k).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub
Thanks in advance