Results 1 to 2 of 2

Find missing columns based on column header

Threaded View

  1. #1
    Registered User
    Join Date
    07-24-2020
    Location
    USA
    MS-Off Ver
    365
    Posts
    1

    Find missing columns based on column header

    Hi all,

    I am trying to create a code where it loops through all the columns within two sheets based on the column header. I need to compare the column headers and if the column header does not match, the code will clear contents of that specific column except the column header and so on... I have attached the code I have so far but it doesn't seem to work accordingly. P.S. this code is part of a larger procedure so I have not shown a lot of the variables that have been listed. I have also attached a sample excel file with the format of the columns. thank you!

    With wb.Sheets(destinationSheetName)
          lastcolumn = .Cells(columnheader, Columns.count).End(xlToLeft).Column
          lastcol = Workbooks(FileName).Sheets(importFile).Cells(columnheader, Columns.count).End(xlToLeft).Column
          For count = 1 To lastcolumn
          For col = 1 To lastcol
             If .Cells(columnheader, count).Value <> Workbooks(FileName).Sheets(importFile).Cells(columnheader, lastcol).Value Then
                .Cells(columnheader + 1, count).Resize(.Rows.count - 1).ClearContents
             End If
             Next col
          Next count
       End With
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [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
  2. How to Find rate based on column header dates
    By witchcraftz in forum Excel General
    Replies: 3
    Last Post: 05-24-2018, 06:56 PM
  3. Find multiple column header, filter out other columns, and export data using a macro
    By trevtrev in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2017, 06:24 PM
  4. Replies: 1
    Last Post: 04-30-2015, 10:01 AM
  5. [SOLVED] Find Row in Table based on Column Header
    By thisguy4000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2014, 12:55 PM
  6. Find Column Number Based on Column Header
    By chicagoland8 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-09-2014, 11:58 AM
  7. Group value in columns with header based on value in another column
    By hitarov in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-02-2013, 03:44 AM

Tags for this Thread

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