ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Column (https://www.excelbanter.com/excel-programming/328630-delete-column.html)

phil

Delete Column
 
Hi,

Can anyone tell me is it possible to delete a coulmn based upon what is
shown in a specific cell, I have a worksheet that in perhaps either A1 or B1
or C1 the word CLIENT might appear, in whichever column the word appears I
want to delete that column, I can find lots on deleteing rows but nothing on
deleting columns (is it similar?).

Thanks for the help, Phil

Bob Phillips[_7_]

Delete Column
 
Simple way

If Range("A1").Value = "CLIENT" Then
Columns(1).Delete
ElseIf Range("B1").Value = "CLIENT" Then
Columns(2).Delete
ElseIf Range("C1").Value = "CLIENT" Then
Columns(3).Delete
End If



--
HTH

Bob Phillips

"Phil" wrote in message
...
Hi,

Can anyone tell me is it possible to delete a coulmn based upon what is
shown in a specific cell, I have a worksheet that in perhaps either A1 or

B1
or C1 the word CLIENT might appear, in whichever column the word appears I
want to delete that column, I can find lots on deleteing rows but nothing

on
deleting columns (is it similar?).

Thanks for the help, Phil




Don Guillett[_4_]

Delete Column
 
If you only have one you could use this. For multiples, post back

Sub findanddelete()
Columns(Rows(1).Find("client").Column).Delete
End Sub


--
Don Guillett
SalesAid Software

"Phil" wrote in message
...
Hi,

Can anyone tell me is it possible to delete a coulmn based upon what is
shown in a specific cell, I have a worksheet that in perhaps either A1 or

B1
or C1 the word CLIENT might appear, in whichever column the word appears I
want to delete that column, I can find lots on deleteing rows but nothing

on
deleting columns (is it similar?).

Thanks for the help, Phil




phil

Delete Column
 
Hi,

Thanks for the help with this, if I have multiple finds in my row, to explain,
if I have a row like A1, B1, C1, and I am looking for the words CLIENT or
CONTACT in either A1, B1, C1, do I seperate the find out something like
Find("client","contact")

Thanks again, Phil

"Don Guillett" wrote:

If you only have one you could use this. For multiples, post back

Sub findanddelete()
Columns(Rows(1).Find("client").Column).Delete
End Sub


--
Don Guillett
SalesAid Software

"Phil" wrote in message
...
Hi,

Can anyone tell me is it possible to delete a coulmn based upon what is
shown in a specific cell, I have a worksheet that in perhaps either A1 or

B1
or C1 the word CLIENT might appear, in whichever column the word appears I
want to delete that column, I can find lots on deleteing rows but nothing

on
deleting columns (is it similar?).

Thanks for the help, Phil





Don Guillett[_4_]

Delete Column
 
Then you will need a loop. There is a good example in vba HELP index for
FIND that you could have found.
With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if ucase(c)="CLIENT" or ucase(c)="WHATEVER" then c.entirecolumn.delete'
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

--
Don Guillett
SalesAid Software

"Phil" wrote in message
...
Hi,

Thanks for the help with this, if I have multiple finds in my row, to

explain,
if I have a row like A1, B1, C1, and I am looking for the words CLIENT or
CONTACT in either A1, B1, C1, do I seperate the find out something like
Find("client","contact")

Thanks again, Phil

"Don Guillett" wrote:

If you only have one you could use this. For multiples, post back

Sub findanddelete()
Columns(Rows(1).Find("client").Column).Delete
End Sub


--
Don Guillett
SalesAid Software

"Phil" wrote in message
...
Hi,

Can anyone tell me is it possible to delete a coulmn based upon what

is
shown in a specific cell, I have a worksheet that in perhaps either A1

or
B1
or C1 the word CLIENT might appear, in whichever column the word

appears I
want to delete that column, I can find lots on deleteing rows but

nothing
on
deleting columns (is it similar?).

Thanks for the help, Phil








All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com