I have code to copy rows of data to another sheet if the cell in column L equals "High" or "Extreme". I'm unsure how to copy only certain columns of that row to the new spreadsheet, which has matching headers in place. I'd like to either copy columns 2, 3, 6, 12, 14, 18, and 21, or have the code copy the columns which match the column headers in the new sheet. Any guidance would be much appreciated!
Sub Copy() 'assuming the data is in Current Risks Set i = Sheets("Current Risks") Set e = Sheets("Extreme&High Risk Report") Dim d Dim j d = 1 j = 2 Do Until IsEmpty(i.Range("L" & j)) 'copy row with high or extreme risk rating If i.Range("L" & j) = "Extreme" Or i.Range("L" & j) = "High" Then d = d + 1 e.Rows(d).Value = i.Rows(j).Value End If j = j + 1 Loop End Sub