Thread: Is there a way?
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Sean Timmons Sean Timmons is offline
external usenet poster
 
Posts: 1,696
Default Is there a way?

I'll leave to you to create an input box loop around this, but here's the
initial search...


Dim i, j As Integer
Dim pkfrom, pkto, Result As String
i = 3
j = 4
pkfrom = "$J$" & i
pkto = "$J$" & j
While Range("H1").Value = 0
Cells.Replace What:=pkfrom, Replacement:=pkto, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
i = i + 1
j = j + 1
pkfrom = "$J$" & i
pkto = "$J$" & j
Wend

"Kevin W" wrote:

I'm a beginner with macros but am quickly realizing how they can make
everything easier.

I'd like to create a macro that Replaces all cells that have $J$2 in the
formula with $J$3. I have a cell (we'll call it H1) that sums up hundreds of
other cells (sum normally will equal 0). After Find/Replacing $J$2 with
$J$3, I want the macro to look at H1. If H1 still equals 0, then I want to
replace $J$3 with $J$4. If H1 still equals 0, I want to replace $J$4 with
$J$5. I want everything to stop when H1 equals anything other than 0.

Then, I would like to run it again - but starting from the next one where I
left off (so I don't want to start at $J$2 again). I'm not sure if this is
possible --maybe a prompt asking what row to start with?