Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Replace number in formula with ROW number



My routine "lands" on cell m1000, and there is a row formula in it that
contains cell m$6.

Using find-and-replace, would like to change the 6 to row 998.
To be specific, it should be absolute two rows above wherever the routine
"lands" my active cell.

Examples:

Lands on cell 200, $6 should change to $198.
Lands on cell 10020, $6 should change to $10018.
Lands on cell 1744, $6 should change to $1742.
**** Lands on cell 1746, $6 should change to $1744.
**** Lands on cell 808, $6 should change to $806.
.... And so on.

Any assistance will be greatly appreciated.
Regards,
- Mike

ps: Bernie MVP, if you're reading this, it could be the solution. Thanx!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Replace number in formula with ROW number

Please paste the formula

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:



My routine "lands" on cell m1000, and there is a row formula in it that
contains cell m$6.

Using find-and-replace, would like to change the 6 to row 998.
To be specific, it should be absolute two rows above wherever the routine
"lands" my active cell.

Examples:

Lands on cell 200, $6 should change to $198.
Lands on cell 10020, $6 should change to $10018.
Lands on cell 1744, $6 should change to $1742.
**** Lands on cell 1746, $6 should change to $1744.
**** Lands on cell 808, $6 should change to $806.
... And so on.

Any assistance will be greatly appreciated.
Regards,
- Mike

ps: Bernie MVP, if you're reading this, it could be the solution. Thanx!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Replace number in formula with ROW number

Ok, here it is....

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M$6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M$6)-ROW(M8),0))),"k")

There are 2 instances of ROW(m$6).
The "$6" needs to change to 2 rows above whatever cell ROW(m8) becomes, as
per the examples below.

Thanx,
- Mike



"Jacob Skaria" wrote:

Please paste the formula

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:



My routine "lands" on cell m1000, and there is a row formula in it that
contains cell m$6.

Using find-and-replace, would like to change the 6 to row 998.
To be specific, it should be absolute two rows above wherever the routine
"lands" my active cell.

Examples:

Lands on cell 200, $6 should change to $198.
Lands on cell 10020, $6 should change to $10018.
Lands on cell 1744, $6 should change to $1742.
**** Lands on cell 1746, $6 should change to $1744.
**** Lands on cell 808, $6 should change to $806.
... And so on.

Any assistance will be greatly appreciated.
Regards,
- Mike

ps: Bernie MVP, if you're reading this, it could be the solution. Thanx!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Replace number in formula with ROW number

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M6)-ROW(M8),0))),"k")

Copy the formula to the same cell from where you copied the below..

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:

Ok, here it is....

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M$6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M$6)-ROW(M8),0))),"k")

There are 2 instances of ROW(m$6).
The "$6" needs to change to 2 rows above whatever cell ROW(m8) becomes, as
per the examples below.

Thanx,
- Mike



"Jacob Skaria" wrote:

Please paste the formula

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:



My routine "lands" on cell m1000, and there is a row formula in it that
contains cell m$6.

Using find-and-replace, would like to change the 6 to row 998.
To be specific, it should be absolute two rows above wherever the routine
"lands" my active cell.

Examples:

Lands on cell 200, $6 should change to $198.
Lands on cell 10020, $6 should change to $10018.
Lands on cell 1744, $6 should change to $1742.
**** Lands on cell 1746, $6 should change to $1744.
**** Lands on cell 808, $6 should change to $806.
... And so on.

Any assistance will be greatly appreciated.
Regards,
- Mike

ps: Bernie MVP, if you're reading this, it could be the solution. Thanx!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Replace number in formula with ROW number

Jacob, thank you, but this will not work.

There is *much* more going on.

the $6 needs to be *absolutely* 2 rows above the *first* cell in multiple
groups of 202 rows.
So the formula in row 9 *still* needs to refer to row(m$6), as do the
formulas in rows 10 thru 210.
Then the formula in row 213 needs to refer to row(m$211), as do the formulas
in rows 214 thru 415.
And so on ....

That's why it seems that a replace $6 with *whatever* row is 2 rows above
the first row in the group seems to be the answer.

It's a TRICKY one!!

Thanx again for any assistance you can provide.
- Mike


"Jacob Skaria" wrote:

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M6)-ROW(M8),0))),"k")

Copy the formula to the same cell from where you copied the below..

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:

Ok, here it is....

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M$6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M$6)-ROW(M8),0))),"k")

There are 2 instances of ROW(m$6).
The "$6" needs to change to 2 rows above whatever cell ROW(m8) becomes, as
per the examples below.

Thanx,
- Mike



"Jacob Skaria" wrote:

Please paste the formula

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:



My routine "lands" on cell m1000, and there is a row formula in it that
contains cell m$6.

Using find-and-replace, would like to change the 6 to row 998.
To be specific, it should be absolute two rows above wherever the routine
"lands" my active cell.

Examples:

Lands on cell 200, $6 should change to $198.
Lands on cell 10020, $6 should change to $10018.
Lands on cell 1744, $6 should change to $1742.
**** Lands on cell 1746, $6 should change to $1744.
**** Lands on cell 808, $6 should change to $806.
... And so on.

Any assistance will be greatly appreciated.
Regards,
- Mike

ps: Bernie MVP, if you're reading this, it could be the solution. Thanx!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Replace number in formula with ROW number

Hello Mike,

Try the macro below.. You can adapt it to your need...

Sub rowMinusTwo()
Dim currentRow As Variant
With ActiveCell
currentRow = Split(.Address, "$")
currentRow(2) = currentRow(2) - 2
.Formula = WorksheetFunction.Substitute(.Formula, "$6", "$" & currentRow(2))
MsgBox ActiveCell.Formula
End With
End Sub

"MikeF" wrote:

Jacob, thank you, but this will not work.

There is *much* more going on.

the $6 needs to be *absolutely* 2 rows above the *first* cell in multiple
groups of 202 rows.
So the formula in row 9 *still* needs to refer to row(m$6), as do the
formulas in rows 10 thru 210.
Then the formula in row 213 needs to refer to row(m$211), as do the formulas
in rows 214 thru 415.
And so on ....

That's why it seems that a replace $6 with *whatever* row is 2 rows above
the first row in the group seems to be the answer.

It's a TRICKY one!!

Thanx again for any assistance you can provide.
- Mike


"Jacob Skaria" wrote:

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M6)-ROW(M8),0))),"k")

Copy the formula to the same cell from where you copied the below..

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:

Ok, here it is....

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M$6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M$6)-ROW(M8),0))),"k")

There are 2 instances of ROW(m$6).
The "$6" needs to change to 2 rows above whatever cell ROW(m8) becomes, as
per the examples below.

Thanx,
- Mike



"Jacob Skaria" wrote:

Please paste the formula

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:



My routine "lands" on cell m1000, and there is a row formula in it that
contains cell m$6.

Using find-and-replace, would like to change the 6 to row 998.
To be specific, it should be absolute two rows above wherever the routine
"lands" my active cell.

Examples:

Lands on cell 200, $6 should change to $198.
Lands on cell 10020, $6 should change to $10018.
Lands on cell 1744, $6 should change to $1742.
**** Lands on cell 1746, $6 should change to $1744.
**** Lands on cell 808, $6 should change to $806.
... And so on.

Any assistance will be greatly appreciated.
Regards,
- Mike

ps: Bernie MVP, if you're reading this, it could be the solution. Thanx!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Replace number in formula with ROW number

Sheeloo ... woo-HOO!
I *think* you've nailed it.
Works in a few test examples, let me incorporate it into the real deal and
will let you know.
THANK you!!
- Mike

"Sheeloo" wrote:

Hello Mike,

Try the macro below.. You can adapt it to your need...

Sub rowMinusTwo()
Dim currentRow As Variant
With ActiveCell
currentRow = Split(.Address, "$")
currentRow(2) = currentRow(2) - 2
.Formula = WorksheetFunction.Substitute(.Formula, "$6", "$" & currentRow(2))
MsgBox ActiveCell.Formula
End With
End Sub

"MikeF" wrote:

Jacob, thank you, but this will not work.

There is *much* more going on.

the $6 needs to be *absolutely* 2 rows above the *first* cell in multiple
groups of 202 rows.
So the formula in row 9 *still* needs to refer to row(m$6), as do the
formulas in rows 10 thru 210.
Then the formula in row 213 needs to refer to row(m$211), as do the formulas
in rows 214 thru 415.
And so on ....

That's why it seems that a replace $6 with *whatever* row is 2 rows above
the first row in the group seems to be the answer.

It's a TRICKY one!!

Thanx again for any assistance you can provide.
- Mike


"Jacob Skaria" wrote:

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M6)-ROW(M8),0))),"k")

Copy the formula to the same cell from where you copied the below..

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:

Ok, here it is....

=SUMIFS($Z8:$AS8,INDIRECT("$Z"&ROW(OFFSET(M8,ROW($ M$6)-ROW(M8),0))&":"&"$AS"&ROW(OFFSET(M8,ROW(M$6)-ROW(M8),0))),"k")

There are 2 instances of ROW(m$6).
The "$6" needs to change to 2 rows above whatever cell ROW(m8) becomes, as
per the examples below.

Thanx,
- Mike



"Jacob Skaria" wrote:

Please paste the formula

If this post helps click Yes
--------------
Jacob Skaria


"MikeF" wrote:



My routine "lands" on cell m1000, and there is a row formula in it that
contains cell m$6.

Using find-and-replace, would like to change the 6 to row 998.
To be specific, it should be absolute two rows above wherever the routine
"lands" my active cell.

Examples:

Lands on cell 200, $6 should change to $198.
Lands on cell 10020, $6 should change to $10018.
Lands on cell 1744, $6 should change to $1742.
**** Lands on cell 1746, $6 should change to $1744.
**** Lands on cell 808, $6 should change to $806.
... And so on.

Any assistance will be greatly appreciated.
Regards,
- Mike

ps: Bernie MVP, if you're reading this, it could be the solution. Thanx!

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
Formula to convert a number with spaces to just a number? WolfgangPD Excel Discussion (Misc queries) 10 December 16th 08 03:21 AM
Creating number formula to count number occurences in a data set Brreese24 Excel Programming 1 August 23rd 07 11:18 PM
Formula to change scientific number to regular number or text Compare Values Excel Discussion (Misc queries) 2 August 23rd 07 06:10 PM
countif formula to find the occurances of a number that is greater than one number but less than another steveo Excel Discussion (Misc queries) 3 July 8th 06 02:04 AM
How do I replace a negative number at the end of a formula with a. dealn2 Excel Discussion (Misc queries) 5 December 23rd 04 07:47 PM


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