+ Reply to Thread
Results 1 to 4 of 4

VB code for column sort on file open or close

  1. #1
    Registered User
    Join Date
    10-21-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    VB code for column sort on file open or close

    Hi,

    I need a specific column to be sorted alphabetically when the file is opened.
    Row 1 of the Column has a heading. What is the VB code for this and should I be calling the column letter or heading?

    I currently have a 'save before close' function in place but this should not affect anything.

    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VB code for column sort on file open or close

    Assuming column A. Note: This could have been solved using the record macro feature

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-21-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: VB code for column sort on file open or close

    Thanks,

    The sorting works but only after I receive the following message on opening - "Excel found unreadable content in file_name' Do you want to recover the contents of this workbook?"

    When I close the file I receive a "runtime error 1004". Appears if a function is still trying to run or the save before close function is conflicting.
    My code:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VB code for column sort on file open or close

    Works just fine for me. Don't know what to tell you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 10-02-2013, 01:47 AM
  2. Open 2nd file(CSV) from cell reference, copy columns to main file & close 2nd file
    By Langchop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2013, 05:09 AM
  3. Replies: 13
    Last Post: 11-29-2012, 08:25 PM
  4. Can I sort a column automatically everytime I close a file
    By jimmy05 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2012, 11:09 AM
  5. need VBA code to open a file type then do a "=countA(A:A)-1" and close it
    By BrandonFromSingapore in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2012, 12:19 PM

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