Hello everyone!
I have been using Mr.Excel for a while and have always been able to find answers to my questions until now.
Basically I have a sheet which could have upto 52 columns of data, that are not always in the same sequence. I need to be able to find specific column names and copy the data below into another sheet.
Below is the code I have so far, basically this works but I can only copy the cell directly below the header title. How would I define the range from 1 cell below my header to the value of Lastrow1?
Thank you in advance for any help as this one is kicking my butt!!!
Sub CopyPaste2()
'attempt using a fixed range for the column search
Dim LastColumn As Long 'not currently using, but would like a dynamic range
Dim lastrow1 As Long
Dim SEHeaderCell As Range
Dim SEHeader As Range
Application.ScreenUpdating = False
Sheet3.Activate
'find last row
lastrow1 = Sheet3.Range("A" & Rows.Count).End(xlUp).Row
'using fixed range
Set SEHeader = Range("A1:AB1")
For Each SEHeaderCell In SEHeader
If SEHeaderCell.Value = "Location" Then
'Need to select and copy all cells down to "lastrow1" at this point
SEHeaderCell.Offset(1, 0).Select
Selection.Copy
Sheet2.Activate
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteValues
End If
Next SEHeaderCell
End Sub
I have been using Mr.Excel for a while and have always been able to find answers to my questions until now.
Basically I have a sheet which could have upto 52 columns of data, that are not always in the same sequence. I need to be able to find specific column names and copy the data below into another sheet.

Below is the code I have so far, basically this works but I can only copy the cell directly below the header title. How would I define the range from 1 cell below my header to the value of Lastrow1?
Thank you in advance for any help as this one is kicking my butt!!!
Sub CopyPaste2()
'attempt using a fixed range for the column search
Dim LastColumn As Long 'not currently using, but would like a dynamic range
Dim lastrow1 As Long
Dim SEHeaderCell As Range
Dim SEHeader As Range
Application.ScreenUpdating = False
Sheet3.Activate
'find last row
lastrow1 = Sheet3.Range("A" & Rows.Count).End(xlUp).Row
'using fixed range
Set SEHeader = Range("A1:AB1")
For Each SEHeaderCell In SEHeader
If SEHeaderCell.Value = "Location" Then
'Need to select and copy all cells down to "lastrow1" at this point
SEHeaderCell.Offset(1, 0).Select
Selection.Copy
Sheet2.Activate
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteValues
End If
Next SEHeaderCell
End Sub