VBA - Find text and replace with value of cell above it

jmcginley3

New Member
Joined
Mar 28, 2018
Messages
14
I'm trying to figure out how I can use Cells.Replace along with Offset to locate and replace the cells that contain the text "Auto Adjustments" and replace it with the value of the cell directly above it.


450
Auto Adjustments<--- this Cell is changed to the value of the cell right above it (450)
564
45433
56788
9084
Auto Adjustments<---- this Cell is changed to the value of the cell right above it (9084)
56165
8765
Auto Adjustments<---- this Cell is changed to the value of the cell right above it (8765)

<tbody>
</tbody>

Can I use this and insert some kind of offset coding into the Replacement?

Code:
    Cells.Replace What:="Auto Adjustments", Replacement:="?????", LookAt:= xlPart, SearchOrder:=xlByRows
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How about
Code:
Sub replaceSpec()
With Range("a2", Range("A" & Rows.Count).End(xlUp))
   .Value = Evaluate(Replace(Replace("if(@=""Auto Adjustments"",#,@)", "@", .Address), "#", .Offset(-1).Address))
End With
End Sub
 
Upvote 0
Hey that worked! Thanks for your help! Now I'm off to dissect and understand what it's doing. I've just recently jumped into using macros since it helps a great deal with my new job.
 
Upvote 0
Glad to help& thanks for the feedback
 
Upvote 0
Sorry to jump in on your thread. I'm still new to this but can some on help me how to set goal seek must be in ascending


For example cell B83 "set cell" is the sum of B71:B82

and cell B85 is the "to value"

and cell b70 is "by changing cell"


also, cell b71 is a hard code cell
cell b72 =B71*(1+$B$70)
cell b73 =B72*(1+$B$71)

and so far


thank you
 
Upvote 0
@ttran123
As this is a completely different question, please start your own thread.
 
Upvote 0

Forum statistics

Threads
1,215,733
Messages
6,126,541
Members
449,316
Latest member
sravya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top