i want to find and replace by column

itsmebestz

New Member
Joined
Aug 26, 2013
Messages
1
mhjgT.png



Thank you sir
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
itsmebestz,

Welcome to the MrExcel forum.

The following screenshots and macro are based on your posted picture/graphic.

Sample raw data:


Excel 2007
ABCDEFG
1
2
35061501.9
46372610
56974631.8
6691.96
7722.1
8742.5
9
Sheet1


After the macro:


Excel 2007
ABCDEFG
1
2
31.90501.9
41.82.1610
51.962.5631.8
6691.96
7722.1
8742.5
9
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Option Explicit
Sub FindAndReplace()
' hiker95, 08/26/2013
' http://www.mrexcel.com/forum/excel-questions/722587-i-want-find-replace-column.html
Dim a As Variant, f As Variant
Dim i As Long, ii As Long
a = Cells(3, 1).CurrentRegion
f = Cells(3, 6).CurrentRegion
For i = 1 To UBound(a, 1)
  For ii = 1 To UBound(f, 1)
    If a(i, 1) = f(ii, 1) Then
      a(i, 1) = f(ii, 2)
    End If
    If a(i, 2) = f(ii, 1) Then
      a(i, 2) = f(ii, 2)
    End If
  Next ii
Next i
Cells(3, 1).CurrentRegion = a
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the FindAndReplace macro.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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