Thread: Delete Columns
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Delete Columns

Dim varr as Variant, i as long, res as Variant
varr = Array("MGMTCODE", "CHANNEL", "NAME1", "CLASS", "FUND NAME")

for i = lbound(varr) to ubound(varr)
res = Application.Match(varr(i),Rows(1),0)
if not iserror(res) then
columns(res).EntireColumn.Delete
end if
Next

--
Regards,
Tom Ogilvy

"Jean" wrote in message
...
I have spreadsheet and 5 columns get deleted before I
import into a database. At first I just did a record
macro and deleted assuming the formatted would not
change. What I want to do is look for a specific name and
then delete the entire column. So if the columns are
named MGMTCODE, CHANNEL, NAME1, CLASS, FUND NAME Delete.
The column names always start in the first row A1. There
are about 20 columns in all ans some months they change
the order on me.

Any suggestions on how I can do this?