View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Modify Claus code "Sub Array_Var_Column_Sort()"

On Thursday, August 21, 2014 8:25:15 PM UTC-7, GS wrote:
Garry,




Try this one, I think I sent wrong link in last post




https://www.dropbox.com/s/ep41xcpsw5...20Box%20X.xlsm




Howard




Using .Find includes your notes in colG (returns 7).



Using .Cells(1, Columns.Count).End(xlToLeft).Column does not include

your notes (returns 5).



So 'as is' your notes are included in the sort so I commented out the

.Find code.



Your loops sort each column by each row count. What is the intent here?



--

Garry


Okay, I did notice 7 in the msgbox pop up, but did not make the connection.

So now I believe the problem with the gap in Col A I mentioned earlier was due to the same problem, where I most likely had some data out side column 5 and below the end rows of C & D. Col A was 30 rows deep and that was the issue for sure.

Mostly what I was trying to do here was practice on arrays. After seeing the columns to sort in an array and I noticed that if the columns were different lengths, all columns would only be sorted down to the last columns length, as it was the value for Lrow for each column.

So the mission was to put each columns Lrow in an array and apply it to the proper column from the column array.

Looks like I got it mostly accomplished but was sidetracked by side show antics of my own doing.

So it still leaves me with the question, suppose there are three columns to sort A C & D. And each a different number of rows. And to the right are many other columns.

Now, it just dawns on me that you don't need the last column line of code, you can use i as the column in:

..Range(.Cells(1, 1), .Cells(varRow(ii), i)).Sort _
Key1:=.Range(varKey(i)), order1:=xlAscending, Header:=xlNo

Hmmm, haven't tried it but will do so now.

Back in a bit.

Howard