Hi,
I have a Macro code as bellow, to search for few criteria's and extract data to new tab. I need help to copy the Header from Column A1 to V1 on every tab when I run the macro.
Thank you.
Sub TestTim()
test3 "OES", "Tim"
End Sub
Sub TestGeorge()
test3 "OES", "George"
End Sub
Sub test3(Category As String, FirstName As String)
Dim outarr()
Dim inarr As Variant, indi As Long, I As Long, J As Long '<<<< missing variable declarations.
inarr = Range("A1:V7500").Value
ReDim outarr(1 To 7500, 1 To 22)
indi = 1
For I = 2 To 7500
If UCase(inarr(I, 10)) = UCase(Category) And UCase(inarr(I, 20)) = UCase(FirstName) And inarr(I, 22) <= 12 Then
' copy row
For J = 1 To 22
outarr(indi, J) = inarr(I, J)
Next J
indi = indi + 1
End If
Next I
Worksheets.Add
ActiveSheet.Name = FirstName
If indi > 1 Then
Range(Cells(1, 1), Cells(indi - 1, 22)) = outarr
End If
End Sub
I have a Macro code as bellow, to search for few criteria's and extract data to new tab. I need help to copy the Header from Column A1 to V1 on every tab when I run the macro.
Thank you.
Sub TestTim()
test3 "OES", "Tim"
End Sub
Sub TestGeorge()
test3 "OES", "George"
End Sub
Sub test3(Category As String, FirstName As String)
Dim outarr()
Dim inarr As Variant, indi As Long, I As Long, J As Long '<<<< missing variable declarations.
inarr = Range("A1:V7500").Value
ReDim outarr(1 To 7500, 1 To 22)
indi = 1
For I = 2 To 7500
If UCase(inarr(I, 10)) = UCase(Category) And UCase(inarr(I, 20)) = UCase(FirstName) And inarr(I, 22) <= 12 Then
' copy row
For J = 1 To 22
outarr(indi, J) = inarr(I, J)
Next J
indi = indi + 1
End If
Next I
Worksheets.Add
ActiveSheet.Name = FirstName
If indi > 1 Then
Range(Cells(1, 1), Cells(indi - 1, 22)) = outarr
End If
End Sub