How do I replace multiple cells of text with the first Number value above them? (w/o macros)

patrickmg17

New Member
Joined
Sep 26, 2023
Messages
14
Office Version
  1. 2019
Platform
  1. Windows
Excel 2016 and I cant allow macros due to annoying business restrictions

thatthisanothersome moreagainlastly
86468465454654651651Note 165168
Note 26546+484615Note 2321316545
Note 2321651984616516516565651
Note 265165165165165165116516651
61651321651Note 1498443631816354684
161961496498466546432133Note 26546514
6194961646.52E+083131Note 2351651

I have the above cells as an example. I want to replace every instance of "Note 2" with the number value above it. So for the first column all 3 "Note 2"s should say 86468. And the ones in column 5 should be 31816. This is the most important part i need, so if you can answer that I'm happy :) but there is another part i need to figure out as well; for every instance of a row having a "Note 1" in it, i need that whole row of data deleted. Most of these rows are were the Note 2 spots pull their replacements so this part has to come after they are replaced.

I know some people have said its not possible to delete rows without macros but i figure i can accomplish the same goal by having a new sheet created and everything ported there EXCEPT the Note 1 lines that should be deleted. Essentially just making a new sheet without the stuff that will be removed
 
Power Query is not an add in for 2016 and later versions. It is located on the Data Tab and is called Get and Transform Data.

Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.

If I follow the query correctly, it only searches 2 columns for "Note 1". Is there a way to rewrite the query so it looks through the whole table without having to list all the columns? I have some cases where I could use this functionality.
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I've revised the code to search all columns and replace in all columns. This is more efficient and cleaner.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    RV=Table.ReplaceValue(Source,"Note 2",null,Replacer.ReplaceValue,Table.ColumnNames(Source)),
    FD = Table.FillDown(RV,Table.ColumnNames(Source))   
in
    FD
Book2
ABCDEF
1thatthisanothersome moreagainlastly
286468465454654651651Note 165168
3Note 26546+484615Note 2321316545
4Note 2321651984616516516565651
5Note 265165165165165165116516651
661651321651Note 1498443631816354684
7161961496498466546432133Note 26546514
86194961646.52E+083131Note 2351651
9
10thatthisanothersome moreagainlastly
1186468465454654651651Note 165168
12864686546+484615651651321316545
1386468321651984616516516565651
148646865165165165165165116516651
1561651321651Note 1498443631816354684
16161961496498466546432133318166546514
17619496164652000000313131816351651
Sheet1
 
Upvote 0
I've revised the code to search all columns and replace in all columns. This is more efficient and cleaner.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    RV=Table.ReplaceValue(Source,"Note 2",null,Replacer.ReplaceValue,Table.ColumnNames(Source)),
    FD = Table.FillDown(RV,Table.ColumnNames(Source))  
in
    FD


How do you re-write the Row Filter code to generically find "Note 1" throughout the Table?
VBA Code:
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([another] <> "Note 1") and ([again] <> "Note 1"))
 
Upvote 0
In this line of code
Power Query:
RV=Table.ReplaceValue(Source,"Note 2",null,Replacer.ReplaceValue,Table.ColumnNames(Source)),
change "Note 2" to "Note 1"
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

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