Results 1 to 8 of 8

Create Macro based on Column Headings instead of Column Letter

Threaded View

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Create Macro based on Column Headings instead of Column Letter

    Good Morning All.

    I have a simple Macro that I use to quickly reorganize the data in a file... but the problem I am having is there are times where the original file has columns in a different order.... so the Macro does not always rearrange properly.

    How do I make it so that instead of it just moving columns around, it will looking at the heading that the column has, and rearrange the data based on those headings?

    Sub VB_SAM()
    '
    ' VB_SAM Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+S
    '
        Columns("M:N").Select
        Selection.Cut
        Columns("A:A").Select
        Selection.Insert Shift:=xlToRight
        Columns("G:G").Select
        Selection.Cut
        Columns("C:C").Select
        Selection.Insert Shift:=xlToRight
        Columns("O:O").Select
        Selection.Cut
        Columns("D:D").Select
        Selection.Insert Shift:=xlToRight
        Columns("F:F").Select
        Selection.Cut
        Columns("E:E").Select
        Selection.Insert Shift:=xlToRight
        Columns("Q:Q").Select
        Selection.Cut
        Columns("G:G").Select
        Selection.Insert Shift:=xlToRight
        Columns("H:I").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Columns("L:L").Select
        Selection.Cut
        Columns("J:J").Select
        Selection.Insert Shift:=xlToRight
        Columns("K:K").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Range("A1").Select
        Columns("D:D").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    End Sub
    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] Macro to combine duplicate Rows Based on a particular Column to separate INV Headings
    By prkhan56 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-28-2017, 06:38 AM
  2. macro to copy paste data based on column headings
    By kets0985 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-22-2014, 02:26 PM
  3. Create macro to copy data using column headings
    By zkhan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2013, 02:01 AM
  4. Trying to create a new sheet based on column headings selected
    By davidhale87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 01:47 PM
  5. How to turn off column letter headings?
    By VanS in forum Excel General
    Replies: 6
    Last Post: 03-03-2006, 12:20 PM
  6. Replies: 2
    Last Post: 11-23-2005, 02:55 PM
  7. What will cause column headings to change from letter to number?
    By Bob in Buffalo in forum Excel General
    Replies: 3
    Last Post: 08-08-2005, 03:05 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