Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need a Marco to find and delete an entire column based on text sea

I have a SQL export which comes as an excel file containing a large amount of
data I don't need. I would like to write a macro to find and organize the
data based on the column headings, however, the columns are variable so I
cannot use the column reference. I.e. I need to find the column with the
title "owner" which could be column D or column F or Column HH. Any advice
would be much appricaiate. Also, if you could suggest how to move and delete
columns... many thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Need a Marco to find and delete an entire column based on text sea

Hi

This will get you started.

Sub Owner()
Dim f As Variant
Set f = Rows(1).Find(What:="owner", LookAt:=xlWhole)
If Not f Is Nothing Then
TargetColumn = f.Column
Else
Msg = MsgBox("Column not found!", vbInformation, "Warning")
End If
Columns("A").Cut Columns("D") 'Move column A to column D
Columns("D").Delete 'Delete column D
End Sub

Regards,
Per

"Rockpaw" skrev i meddelelsen
...
I have a SQL export which comes as an excel file containing a large amount
of
data I don't need. I would like to write a macro to find and organize the
data based on the column headings, however, the columns are variable so I
cannot use the column reference. I.e. I need to find the column with the
title "owner" which could be column D or column F or Column HH. Any
advice
would be much appricaiate. Also, if you could suggest how to move and
delete
columns... many thanks.


Reply
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
How to Delete entire rows by selecting different text in column A Doug[_5_] Excel Discussion (Misc queries) 2 November 20th 09 02:03 PM
find & delete rows based on text deb Excel Discussion (Misc queries) 4 September 17th 08 01:02 AM
Delete text in a string marco help Chuong Nguyen Excel Programming 4 January 11th 08 01:08 AM
delete entire row based on conditional test of column A guillermo.ht Excel Programming 2 January 22nd 07 03:49 AM
Find Column heading and then Delete entire column Kobayashi[_58_] Excel Programming 4 October 17th 05 09:09 PM


All times are GMT +1. The time now is 12:54 PM.

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"