Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default delete columns based on information in another column

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default delete columns based on information in another column

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default delete columns based on information in another column

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default delete columns based on information in another column

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
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
Return a value based on 2 or more columns of information Becca.T. Excel Worksheet Functions 2 September 22nd 09 08:36 PM
Multiple if statements based on two columns of information Elizabeth Excel Worksheet Functions 2 July 25th 08 07:51 PM
Consolidate information from Column B Based on Info In Column A Consol. Info from One Column to another Excel Worksheet Functions 1 October 27th 07 04:02 PM
Looking up information based on Columns and Rows Sally J Excel Worksheet Functions 6 December 16th 05 09:18 PM
increment a column based on information in another column dhemlinger New Users to Excel 2 May 25th 05 09:47 PM


All times are GMT +1. The time now is 02:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"