Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Need a Marco to find and delete an entire column based on text sea

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rockpaw - 28 May 2008 21:38 GMT
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.
Per Jessen - 29 May 2008 08:12 GMT
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

>I have a SQL export which comes as an excel file containing a large amount
>of
[quoted text clipped - 6 lines]
> delete
> columns... many thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.