PC Review


Reply
Thread Tools Rate Thread

delete columns based on information in another column

 
 
NewBee
Guest
Posts: n/a
 
      9th Apr 2008
I am trying to delete columns 'A' and 'B' based on if there is some data in
column 'C'. I am trying to write a macro to accomplish this. Any help is
appreciated.
 
Reply With Quote
 
 
 
 
affordsol
Guest
Posts: n/a
 
      9th Apr 2008
Hello,

Think logically:

if there is something in column C, must delete column A
.... so, delete column A
Now, the old column B has become column A
.... so, again, delete column A


Hope this helps !

--
Herve Hanuise
http://www.affordsol.be


"NewBee" wrote:

> I am trying to delete columns 'A' and 'B' based on if there is some data in
> column 'C'. I am trying to write a macro to accomplish this. Any help is
> appreciated.

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2008
Hi,

You don't give too much information so use this cautiously becuase it will
cler row A & B if it finds anything in row C. Right click the sheet tab, view
code and paste it in

Sub stance()
Dim myrange, copyrange As Range
Lastrow = Cells(Cells.Rows.Count, "C").End(xlUp).Row
Set myrange = Range("C1:C" & Lastrow)
For Each c In myrange
If c.Value <> "" Then 'Change to a particular value
If copyrange Is Nothing Then
Set copyrange = c.Offset(0, -2).Resize(, 2)
Else
Set copyrange = Union(copyrange, c.Offset(0, -2).Resize(, 2))
End If
End If
Next
If Not copyrange Is Nothing Then
copyrange.ClearContents
End If
End Sub


Mike

"NewBee" wrote:

> I am trying to delete columns 'A' and 'B' based on if there is some data in
> column 'C'. I am trying to write a macro to accomplish this. Any help is
> appreciated.

 
Reply With Quote
 
NewBee
Guest
Posts: n/a
 
      11th Apr 2008
Mike I want to take the time to thank you for the solution you have provided
to me. I will execute it today and will provide you with feedback. I
appreciate the fact that you have taken the time to respond to my query

"Mike H" wrote:

> Hi,
>
> You don't give too much information so use this cautiously becuase it will
> cler row A & B if it finds anything in row C. Right click the sheet tab, view
> code and paste it in
>
> Sub stance()
> Dim myrange, copyrange As Range
> Lastrow = Cells(Cells.Rows.Count, "C").End(xlUp).Row
> Set myrange = Range("C1:C" & Lastrow)
> For Each c In myrange
> If c.Value <> "" Then 'Change to a particular value
> If copyrange Is Nothing Then
> Set copyrange = c.Offset(0, -2).Resize(, 2)
> Else
> Set copyrange = Union(copyrange, c.Offset(0, -2).Resize(, 2))
> End If
> End If
> Next
> If Not copyrange Is Nothing Then
> copyrange.ClearContents
> End If
> End Sub
>
>
> Mike
>
> "NewBee" wrote:
>
> > I am trying to delete columns 'A' and 'B' based on if there is some data in
> > column 'C'. I am trying to write a macro to accomplish this. Any help is
> > appreciated.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return a value based on 2 or more columns of information Becca.T. Microsoft Excel Worksheet Functions 2 22nd Sep 2009 08:36 PM
Consolidate information from Column B Based on Info In Column A =?Utf-8?B?Q29uc29sLiBJbmZvIGZyb20gT25lIENvbHVtbiB0 Microsoft Excel Worksheet Functions 1 27th Oct 2007 04:02 PM
how to delete rows based on duplicate information in a column albertpinto Microsoft Excel Discussion 5 29th May 2006 02:20 PM
Looking up information based on Columns and Rows =?Utf-8?B?U2FsbHkgSg==?= Microsoft Excel Worksheet Functions 6 16th Dec 2005 09:18 PM
RE: increment a column based on information in another column =?Utf-8?B?Sk1C?= Microsoft Excel New Users 1 25th May 2005 09:47 PM


Features
 

Advertising
 

Newsgroups
 


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