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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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
 

Forum statistics

Threads
1,136,329
Messages
5,675,142
Members
419,551
Latest member
thangxpm

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
Top