Results 1 to 3 of 3

vba excel match replace column header using criteria

Threaded View

terriertrip vba excel match replace... 04-25-2019, 05:41 PM
JLGWhiz Re: vba excel match replace... 04-25-2019, 07:02 PM
terriertrip Re: vba excel match replace... 04-26-2019, 12:27 PM
  1. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: vba excel match replace column header using criteria

    If you have a list of the incorrect headers in column A and the corresponding correct ones in column B, same row of sheet 1 then the headers in sheet 2 can be corrected like this:
    Sub t()
    Dim c As Range
    Set ws1 = Sheets(1)
    Set ws2 = Sheets(2)
        For Each c In ws1.Range("A2", ws1.Cells(Rows.Count, 1).End(xlUp))
            ws2.Rows(1).Replace c.Value, c.Offset(, 1).Value
        Next
    End Sub
    If there are no incorrect headers on the sheet it simply ignores everything and ends the procedure. In other words it will only correct somethig if it finds a match.
    Last edited by JLGWhiz; 04-25-2019 at 07:04 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 03-19-2019, 11:41 AM
  2. Match Criteria in Range & Extract Column Header
    By sp0ck1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-26-2018, 06:27 AM
  3. [SOLVED] looping through columns to find a value then replace said value with column header
    By Sybille in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2018, 10:38 AM
  4. Helped needed to index match row header, column header, and sheet
    By vw103604 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-15-2016, 12:37 PM
  5. Replies: 3
    Last Post: 01-18-2016, 10:18 AM
  6. Replies: 1
    Last Post: 10-05-2013, 03:35 PM
  7. [SOLVED] Replace all non blanks in a column with column header
    By hnyb1 in forum Excel General
    Replies: 3
    Last Post: 04-18-2006, 12:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1