+ Reply to Thread
Results 1 to 8 of 8

Sort data inserts random blank cell at the top??

  1. #1
    Registered User
    Join Date
    05-27-2016
    Location
    Seattle, Washington
    MS-Off Ver
    2016
    Posts
    11

    Sort data inserts random blank cell at the top??

    Hey all,
    This is a pretty basic issue with I'm sure a pretty basic answer, but I'm stuck

    At the end of this big complex module which works fine, all I want to do is sort my data (numbers formatted as text) in ascending order.
    Every 4th column contains this data, so my code looks like this:

    Please Login or Register  to view this content.
    This works perfectly fine on all the columns EXCEPT the first one...which every time adds one blank cell at the top in cell(5,1) (it does not replace a number but bumps them all down).
    I've tried it from the 4th row with Header:xlYes, I've tried deleting some of that stuff in the sort function that I don't know what it does...etc.

    Thanks in advance for any help!!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: Sort data inserts random blank cell at the top??

    Hi Sean,

    Instead of using
    Please Login or Register  to view this content.
    Try using
    Please Login or Register  to view this content.
    If that doesn't work then you should attach a sample workbook so we can see the space at the top.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sort data inserts random blank cell at the top??

    I suspect the cell that comes to the top is not blank, but contains a null string. Delete the contents and try again.

    It's a cardinal sin to modify a loop control variable in the loop. What are you trying to do?
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    05-27-2016
    Location
    Seattle, Washington
    MS-Off Ver
    2016
    Posts
    11

    Re: Sort data inserts random blank cell at the top??

    Thanks for your response Marvin,
    I tried your version of the code but had the same results. Here is an attached workbook with just the first few sets of data, the first row being the problem. If it's any help, I noticed that as I stepped through the code pasted above, the screen would refresh to show the sorted data in each column immediately after performing the sort function...EXCEPT for the first column. This column would not update to reveal the blank space until the next column was selected in the loop.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-27-2016
    Location
    Seattle, Washington
    MS-Off Ver
    2016
    Posts
    11

    Re: Sort data inserts random blank cell at the top??

    shg:

    I'm not sure that it does because when I manually sort the data including the blank cell it spat out, it puts the blank at the bottom where it should be. Maybe I should have the code just sort column 1 twice.....hmmm.

    Also with the i = i + 3 I was just trying to jump from column 1 to 5 to 9...it works fine for that even if I didn't know the standard procedure

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sort data inserts random blank cell at the top??

    This worked fine for me for the workbook you posted. Note that if you have related data in the Reason column, it won't sort with the sorted column.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-27-2016
    Location
    Seattle, Washington
    MS-Off Ver
    2016
    Posts
    11

    Re: Sort data inserts random blank cell at the top??

    shg:
    I copied your code into the module, which definitely looks cleaner but still produces the same result. I have stepped through and know that the problem is occurring at this sorting moment and not before/after. I've also verified the formatting of A5 is the same as the cells below...not sure what else to do. I could write in to delete A5 after sorting but I'm afraid it won't do this once input data changes and I would be deleting a value.

    Also, do you have any idea why the screen would not update immediately after sorting on only for this column?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sort data inserts random blank cell at the top??

    I ran that exact code on the exact workbook you posted and it ran fine

    I think you have some other code in there doing that. Step through the code and watch it run.

+ 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. [SOLVED] Random Sort count how many player from Cell R1
    By micope21 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2016, 06:17 PM
  2. VBA Module inserts random text into itself
    By daveMguitar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2016, 02:12 PM
  3. [SOLVED] Insert Pivot Table only inserts a blank sheet
    By Dave H in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-21-2015, 01:58 PM
  4. Replies: 1
    Last Post: 03-04-2015, 02:57 PM
  5. Sort column, new sort after each blank cell
    By mike_m1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2014, 03:51 PM
  6. Creating macro that inserts data into a cell based on certain critera
    By anjoseph9626 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2013, 07:49 PM
  7. [SOLVED] Subtotalling-inserts a new blank row
    By MarkN in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-23-2006, 05:30 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