Here is some Air Code (untested as you did not supply a worksheet to test).
Option Explicit
Sub Brad()
Dim i As Long, lr As Long, lrg As Long, mth As String
Dim col As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
mth = Range("G1").Text
Application.ScreenUpdating = False
If mth = "Jan" Then col = 2
If mth = "Feb" Then col = 3
If mth = "March" Then col = 4
If mth = "April" Then col = 5
For i = 6 To lr
lrg = Range("G" & Rows.Count).End(xlUp).Row
If Cells(i, col) = "Y" Then
Range("A" & i).Copy Range("G" & lrg + 1)
End If
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
MsgBox "Completed"
End Sub
How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
Bookmarks