Pulling values from columns based on column headings

kimcindyj

New Member
Joined
Dec 6, 2013
Messages
1
Hello,

In A1, I have Nov2013. Columns A2:Z2 have various headings with data underneath each column. I would like to find the column with the heading "Nov2013" and pull the all the data underneath that column into a new column, column AA2.

How can I do this?

Thank you!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Since you specified that cell A1 contains the same string as the target header, I assume you are using cell A1 as an entry box. If not, then this code fails. This code is written as Worksheet_Change event code, which means that the entry into cell A1 will trigger the macro to run.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim fLoc As Range
If Target.Address = "$A$1" Then
    Set fLoc = Range("A2:Z2").Find(Target.Value, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
        If Not fLoc Is Nothing Then
            Range(fLoc.Offset(1, 0), Cells(Rows.Count, fLoc.Column).End(xlUp)).Copy Range("AA2")
        End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,981
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top