Help with Formula to Find/Remove if same data in another cell
Closed
Kristen
-
Apr 11, 2015 at 11:02 AM
TrowaD
TrowaD
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Related:
- Help with Formula to Find/Remove if same data in another cell
- Excel formula to move data from one cell to another - Guide
- Remove torrent and data - Guide
- Insert/Remove photos depending up on ref. cell value changing ✓ - Forum - Excel
- Remove or Clear Data ✓ - Forum - Excel
- IF formula for a range almost works, except with blank cells ✓ - Forum - Excel
1 reply
TrowaD
Apr 20, 2015 at 11:40 AM
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Apr 20, 2015 at 11:40 AM
Hi Kristen,
Try the following macro code to see if it yields the desired result:
How to implement and run a code:
- From Excel hit Alt + F11 to open the "Microsoft Visual Basic" window.
- Go to the top menu in the newly opened window > Insert > Module.
- Paste the code in the big white field.
- You can now close this window.
- Back at Excel, hit Alt + F8 to display the available macro's.
- Double-click the macro you wish to run.
NOTE: macro's cannot be reversed using the blue arrows. Always make sure you save your file before running a code, so you can reopen your file if something unforeseen happens or you want to go back to the situation before the code was run.
Best regards,
Trowa
Try the following macro code to see if it yields the desired result:
Sub RunMe() Dim lRow As Integer lRow = Range("B" & Rows.Count).End(xlUp).Row For Each cell In Range("B2:B" & lRow) cell.Replace What:=cell.Offset(0, 1), Replacement:=vbNullString, LookAt:=xlPart cell.Value = Trim(cell) Next cell End Sub
How to implement and run a code:
- From Excel hit Alt + F11 to open the "Microsoft Visual Basic" window.
- Go to the top menu in the newly opened window > Insert > Module.
- Paste the code in the big white field.
- You can now close this window.
- Back at Excel, hit Alt + F8 to display the available macro's.
- Double-click the macro you wish to run.
NOTE: macro's cannot be reversed using the blue arrows. Always make sure you save your file before running a code, so you can reopen your file if something unforeseen happens or you want to go back to the situation before the code was run.
Best regards,
Trowa