LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Naming list of non blank cells

I am writing a For loop inside which I am filtering, sorting and then naming
a range. I am currently naming the entire column because I get compiling
errors everytime I try to select the last non empty cell in the column. Does
anyone know a more elegant way to do this?


For MyFromColumn = 1 To 11
MyToColumn = MyFromColumn + 26
MyFromStartCell = Cells(1, MyFromColumn).Address
MyFromEndCell = Cells(65536, MyFromColumn).Address
MyToStartCell = Cells(1, MyFromColumn + 26).Address
MyToEndCell = Cells(65536, MyFromColumn + 26).Address

'AutoFilter
Range(MyFromStartCell & ":" & MyFromEndCell).AdvancedFilter
Action:=xlFilterCopy, CopyToRange:=Range(MyToStartCell), Unique:=True
'Sort
Range(MyToStartCell & ":" & MyToEndCell).Select
Selection.Sort Key1:=Cells(2, MyToColumn), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'Define Name

'Set MyLastPopulatedCell = Cells(1, xlDown)

Set MyNamedRange = Range(MyToStartCell & ":" & MyToEndCell)

''Range(MyToStartCell & ":" & Selection.End(xlDown)).Select

ActiveWorkbook.Names.Add Name:=MyRangeName(MyFromColumn),
RefersToR1C1:=MyNamedRange

Next
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range naming cells with blank cells through coding Naveen J V Excel Discussion (Misc queries) 1 March 27th 08 01:46 PM
No colour in cells when blank in list harwookf Excel Worksheet Functions 1 November 15th 07 08:58 PM
Naming a non-blank range from a col containing non-consec. blank c fruitticher Excel Worksheet Functions 3 September 14th 07 11:49 PM
Eliminating blank cells in a list on a ROW grime Excel Worksheet Functions 5 November 3rd 05 05:41 PM
List not omitting blank cells....?? malik641 Excel Worksheet Functions 2 July 1st 05 04:33 PM


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"