Excel 多重排序
Function sort_test()
'xlAscending
Set SheetPer = Sheets("今彩機率")
'Set SheetImg = Sheets("今彩圖表")
Set SheetImg = Sheets("今彩機率")
Set ShtPer_Rng = Sheets("今彩機率").Range("d3:f41")
img_Y = SheetImg.Range("d65535").End(xlUp).Row + 2
img_X = SheetImg.Range("iv" & img_Y).End(xlToLeft).Column + 2
Set ShtImg_Rng = SheetImg.Cells(img_Y, img_X)
'依照落號,次數排序
ShtPer_Rng.Cells(1, 1).Sort _
key1:=ShtPer_Rng.Columns(3).Cells, Order1:=xlDescending 'xlAscending
ShtPer_Rng.Cells(1, 1).Sort _
key1:=ShtPer_Rng.Columns(1).Cells, Order1:=xlDescending
'篩選不重復資料
ShtPer_Rng.Columns(1).AdvancedFilter _
Action:=xlFilterCopy, criteriarange:=ShtPer_Rng.Columns(1), _
copytorange:=ShtImg_Rng, unique:=True
'落號合併
End Function
'xlAscending
Set SheetPer = Sheets("今彩機率")
'Set SheetImg = Sheets("今彩圖表")
Set SheetImg = Sheets("今彩機率")
Set ShtPer_Rng = Sheets("今彩機率").Range("d3:f41")
img_Y = SheetImg.Range("d65535").End(xlUp).Row + 2
img_X = SheetImg.Range("iv" & img_Y).End(xlToLeft).Column + 2
Set ShtImg_Rng = SheetImg.Cells(img_Y, img_X)
'依照落號,次數排序
ShtPer_Rng.Cells(1, 1).Sort _
key1:=ShtPer_Rng.Columns(3).Cells, Order1:=xlDescending 'xlAscending
ShtPer_Rng.Cells(1, 1).Sort _
key1:=ShtPer_Rng.Columns(1).Cells, Order1:=xlDescending
'篩選不重復資料
ShtPer_Rng.Columns(1).AdvancedFilter _
Action:=xlFilterCopy, criteriarange:=ShtPer_Rng.Columns(1), _
copytorange:=ShtImg_Rng, unique:=True
'落號合併
End Function
留言
張貼留言