Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Find 0s on Sheet and Replace with Formula

Hi, on a sheet in the area M13:AA6000, i'd like a macro to replace all cells
that are empty or have a value of 0 with a calculated number.

For example, if in cell F500 it finds a value of 0, it calculates and pastes
as value in a new number which is the average of the two subsequent cells
(average(g500:h500)

If in cell aa5123 it finds a cell that is blank, it replaces that value with
a formula equal to average(ab5123:ac5123).

if the calculated value is an error or a zero, the value it replaces should
just be 0.

Also, this should loop starting from column aa, then column z, then column
y... to column m

IF this makes sense to anyone, could some post a code that would make this
work or at least point me in the right direction? I'm a beginnger VbA
person, but I'm pretty good at compiling snippests on the forums and making
useful macros...

thanks for thinking about this.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Find 0s on Sheet and Replace with Formula

Steve, I didn't test this because I didn't want to have to set up the sheet
to do it. So test it on a copy before you permanently install it. It should
go into the standard code module 1 for your VBA project.

Sub replczilch()
Worksheet(" ? ").Activate 'Replace ? with ws name.
For i = 27 To 15 Step -1
For Each c In Range(Cells(13, i), Cells(6000. i))
If c = 0 Or c = "" Then
If c.Offset(0, 1) < 0 And c.Offset(0, 2) < 0 Then
c.Value = Round(c.Offset(0, 1).Value + c.Offset(0, 2).Value)/2)
End If
End If
Next
Next i
End Sub

"SteveC" wrote:

Hi, on a sheet in the area M13:AA6000, i'd like a macro to replace all cells
that are empty or have a value of 0 with a calculated number.

For example, if in cell F500 it finds a value of 0, it calculates and pastes
as value in a new number which is the average of the two subsequent cells
(average(g500:h500)

If in cell aa5123 it finds a cell that is blank, it replaces that value with
a formula equal to average(ab5123:ac5123).

if the calculated value is an error or a zero, the value it replaces should
just be 0.

Also, this should loop starting from column aa, then column z, then column
y... to column m

IF this makes sense to anyone, could some post a code that would make this
work or at least point me in the right direction? I'm a beginnger VbA
person, but I'm pretty good at compiling snippests on the forums and making
useful macros...

thanks for thinking about this.

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
Find and Replace Sheet names FARAZ QURESHI Excel Discussion (Misc queries) 2 February 23rd 09 01:40 AM
Find/Replace Event or Find/Replace for Protected Sheet ... Joe HM Excel Programming 2 October 27th 07 03:55 PM
find replace within sheet or workbook mcphc Excel Programming 5 April 23rd 07 03:28 PM
trying to find #REF! in a formula to replace with a sheet name funkymonkUK[_212_] Excel Programming 5 June 28th 06 11:21 PM
Find and Replace code in Sheet modules Jon Excel Programming 10 March 29th 05 10:15 PM


All times are GMT +1. The time now is 01:24 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"