Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default How to automatically delete formulas in an adjacent column

I have two columns (A and B) which return results from formulas in other cells.

I would like to have a macro read down the list of column A and if the
result returned is empty/zero, the contents formula of its adjacent column B
cell be deleted.

I have complex code which doesnt work when the column B result returns a
blank (which is the case when A is also blank), so this solution, although
drastic will solve my problem adequately.

Can anyone help?

Thanks,
Roger


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,345
Default How to automatically delete formulas in an adjacent column

Assuming that you do not have any data below the data in Column B that you
want to work on try somehting like:

Sub DeleteIt()
Dim LastRow As Long
Dim Counter As Long

LastRow = Cells(Rows.Count, 2).End(xlUp).Row

Application.ScreenUpdating = False
For Counter = LastRow To 1 Step -1
If Cells(Counter, 1).Value = "" Then _
Range(Cells(Counter, 1), Cells(Counter, 2)).Delete shift:=xlUp
Next Counter
Application.ScreenUpdating = True
End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Roger on Excel" wrote in message
...
I have two columns (A and B) which return results from formulas in other
cells.

I would like to have a macro read down the list of column A and if the
result returned is empty/zero, the contents formula of its adjacent column
B
cell be deleted.

I have complex code which doesnt work when the column B result returns a
blank (which is the case when A is also blank), so this solution, although
drastic will solve my problem adequately.

Can anyone help?

Thanks,
Roger





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How to automatically delete formulas in an adjacent column

If column B contains formulas and you delete one that equals zero or is
blank, then shifting the cells up will make cells in column B at the bottom
of the list become blank and present the same problem for the corresponding
data in column A.
You might be better off by just using a conditional If statement to avoid
the error message you are receiving. i.e. If column B value < 0 Then do
something. That way if the value in column B is 0 it will bypass that cell.
It is difficult to determine the best method without seeing the problem code.

"Roger on Excel" wrote:

I have two columns (A and B) which return results from formulas in other cells.

I would like to have a macro read down the list of column A and if the
result returned is empty/zero, the contents formula of its adjacent column B
cell be deleted.

I have complex code which doesnt work when the column B result returns a
blank (which is the case when A is also blank), so this solution, although
drastic will solve my problem adequately.

Can anyone help?

Thanks,
Roger


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
How to select data in non adjacent rows of a column automatically jdpf Excel Discussion (Misc queries) 5 March 23rd 09 10:32 PM
automatically change column references in formulas Ozzmantsje Excel Programming 7 July 18th 07 07:53 PM
When data match, copy adjacent value to adjacent column slimbim Excel Worksheet Functions 2 November 8th 06 08:41 PM
summing values from adjacent column with refrence from adjacent column Pivotrend Excel Discussion (Misc queries) 6 March 4th 06 11:24 AM
How to change column letters to correct ones in many formulas automatically? Dmitry Kopnichev Excel Worksheet Functions 7 October 13th 05 09:52 PM


All times are GMT +1. The time now is 01:45 PM.

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

About Us

"It's about Microsoft Excel"