LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default select and move columns by their name in header row

Hi

I get a large ws with 70 - 100 cols each month. There is a header row, but
the names of the cols are not always in the same order.

I want to select 3 or 4 entire columns, and move them to a blank sheet in
the same workbook "mdata". This code doesn't work in MS Excel 2007, but I
can't figure out how to correct it.

Sub cleanup()
Sheets("cases-dump").Select
date = WorksheetFunction.Match("Procedure Date", Rows("1:1"), 0)
icd9 = WorksheetFunction.Match("Pre-op Diagnoses 1", Rows("1:1"), 0)
cpt1 = WorksheetFunction.Match("Procedures 1", Rows("1:1"), 0)


Sheets("cases-dump").Columns(date).Copy
Destination:=Sheets("mdata").Range("A1")
Sheets("cases-dump").Columns(icd9).Copy
Destination:=Sheets("mdata").Range("B1")
Sheets("cases-dump").Columns(cpt1).Copy
Destination:=Sheets("mdata").Range("C1")

End Sub

Thanks in advance!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header horizontal margin seems fixed, won't move George[_23_] Excel Programming 1 September 23rd 08 11:53 PM
Move logo from word document to excel header Blue Bunny Excel Discussion (Misc queries) 3 August 22nd 08 04:08 PM
Create an always visable header row that does not move when scroll Angee Excel Discussion (Misc queries) 1 January 2nd 08 08:22 PM
1 file- multiple headers, move columns to match first header cdcueva Excel Programming 0 December 19th 07 10:03 PM
how to move header and footer within print margins excel Rohit Excel Discussion (Misc queries) 2 May 4th 05 04:52 PM


All times are GMT +1. The time now is 08:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"