![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 16
|
I want to write a Macro to slect and copy data from a column of data. The data files have variable number of columns, but all have one column with the text heading "36". Is there a way to select theis column based on its heading?
Thanks. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
Try the following. I don't know where you want to copy to, so this just leaves the "marching ants" around the column that has been copied. ------------- Sub test() Dim x As Integer With ActiveSheet .UsedRange For x = 1 To .Cells.SpecialCells(xlCellTypeLastCell).Column If Left(Cells(1, x), 2) = "36" Then Columns(x).Copy Next x End With End Sub ------------------ Bye, Jay |
|
|
|
|
|
#3 |
|
Join Date: Mar 2002
Posts: 22
|
Or more simply :-
Sub test() ActiveSheet.Rows(1).Find("36").EntireColumn.Copy End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|