Hi, I am new to macros and I am trying to come up with a macro for the following:
I am trying to have the user enter what payroll period it is and then have it do an autofilter from whatever number they put in when asked. Is this possible?
Sub PayrollPeriodInput()
HERE:
PayrollPeriod = InputBox("What Payroll Period?")
If PayrollPeriod = "" Then
MsgBox "You did not type anything. You cannot continue until the question is answered."
GoTo HERE
End If
Application.Goto Reference:="DATA"
Selection.AutoFilter
Selection.Copy
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 18
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
ActiveWindow.ScrollColumn = 24
ActiveWindow.ScrollColumn = 25
ActiveWindow.ScrollColumn = 26
ActiveWindow.ScrollColumn = 27
ActiveWindow.ScrollRow = 1
Range("AH2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFilter
End Sub
I am trying to have the user enter what payroll period it is and then have it do an autofilter from whatever number they put in when asked. Is this possible?
Sub PayrollPeriodInput()
HERE:
PayrollPeriod = InputBox("What Payroll Period?")
If PayrollPeriod = "" Then
MsgBox "You did not type anything. You cannot continue until the question is answered."
GoTo HERE
End If
Application.Goto Reference:="DATA"
Selection.AutoFilter
Selection.Copy
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 18
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
ActiveWindow.ScrollColumn = 24
ActiveWindow.ScrollColumn = 25
ActiveWindow.ScrollColumn = 26
ActiveWindow.ScrollColumn = 27
ActiveWindow.ScrollRow = 1
Range("AH2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFilter
End Sub
Code:
[list][/list]