Announcement

Collapse
No announcement yet.

Order columns by Headers

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Order columns by Headers



    This is my first post on Ozgrid, and I'm still pretty new at creating macros using VBA. Any help would be appreciated.

    I have contact info (First Name, Last Name, Address 1, City, etc) that gets exported out as a CSV file regularly. I am trying to make a macro to clean it up so that it is easily viewable.

    The column headings are consistent, but their order can change based on who has given me the file (ie today the order Columns A,B,C,D is: 'First Name', 'Last Name', 'Company Name', 'Address 1', etc, but tomorrow it might be 'Last Name', 'First Name', 'Address 1', 'Company Name'). Each of these columns need to have something different done to them (Ex: Make 'Company Name' Bold), but what is the best way to do this?

    Is there any way to "attach" the Header Name to the column? I would like to refer to the Column with the first cell = 'Company Name' as "Company Name Column", and use this to manipulate those cells regardless of if it is Column B today and Column F tomorrow.

  • #2
    Re: Order columns by Header

    Sabres427,

    Welcome to the Ozgrid forum.

    If the titles are the same, then we could re-order the columns.

    Can we see a workbook with several worksheets with different imports.

    Click on Reply, Go Advanced, and see Manage Attachments.

    Comment


    • #3


      Stanley,

      Thank you for your response.

      I found a similar issue elsewhere on Ozgrid, and I was able to shoehorn it into fit my problem. Basically I find the cell based on its name, select and cut that column to the end of my spreadsheet, repeat for all columns, then delete everything I don't need.

      Ozgrid is a great resource, and I will definitely be posting more issues as I get more adventurous using VBA.

      Comment

      Working...
      X