replace a whole cell

ap2015

New Member
Joined
Feb 14, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Wanting to be able to run a code that is similar to
VBA Code:
Sub MultiFindNReplace()

'Update 20140722

Dim Rng As Range

Dim InputRng As Range, ReplaceRng As Range

xTitleId = "KutoolsforExcel"

Set InputRng = Application.Selection

Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)

Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)

Application.ScreenUpdating = False

For Each Rng In ReplaceRng.Columns(1).Cells

InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value

Next

Application.ScreenUpdating = True

End Sub

With something that will replace the whole cell instead of just that word in the cell. So for example, If in the cell I have "ask how" (not including the quotations) and want to replace the whole cell with "How?" (not including the quotations), or a cell that has "but how" and replace the whole cell with How?. I would like the find and replace code to search for the word how and replace it with How?, but sometimes the cell might have extra words. Does that make sense?
 
I got that when the choices I made were reversed. Hard to help you without a workbook or you posting a sheet of data (using xl2BB, not a pic) and instructions.
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
If your selection is reversed from what I showed, try replacing the IF line with this
If InStr(Rng, ReplaceRng) > 0 Then Rng = ReplaceRng
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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