Tecnologia, programação e muito Visual FoxPro.

sexta-feira, 11 de setembro de 2009

Re: ]] XL-mania [[ sort by

 

Mungkin begini..

Pada masing header sepertinya harus dibuat ractangle (manual aja), Caranya:
klik kanan pada cell dimana header itu berada lalu pada pojok kanan
atas ada name box
kemudian ganti "name box B2" dengan "Contoh" lalu enter. ulangi lagi
untuk masing2 header

Setelah itu assign macro pada rectangle tadi dengan klik kanan pada
cell B1 misalnya

di vbe-nya : Makroh dipanggil dengan application.caller (terlampir)

Option Explicit
Sub ClickToSort()
Dim MyDat As Range, ColStart As Long, SortOrder As Long
Dim FRow As Long, TRow As Long, LRow As Long, iCol As Integer,
strCol As String
Dim Rng1 As Range, Rng2 As Range

TRow = 2
iCol = 3
strCol = "B"

With ActiveSheet
LRow = .Cells(.Rows.Count, strCol).End(xlUp).Row

Set Rng1 = .Range(.Cells(TRow, strCol), .Cells(LRow, strCol))
Set Rng2 = Nothing
On Error Resume Next
With Rng1
Set Rng2 = .Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
End With
On Error GoTo 0
FRow = Rng2(1).Row
ColStart = .Shapes(Application.Caller).TopLeftCell.Column

Set MyDat = .Range("B" & TRow & ":B" & LRow).Resize(, iCol)
If .Cells(FRow, ColStart).Value < .Cells(LRow, ColStart).Value Then
SortOrder = xlDescending
Else
SortOrder = xlAscending
End If
MyDat.Sort key1:=.Cells(FRow, ColStart), order1:=SortOrder, header:=xlYes
End With

End Sub

hope this help..

__._,_.___
+-:: XL-mania ::::::::::::::::::::----------------------------------+
| Ada lowongan jadi direktur ga? Hubungi momods please... :D        |
| http://www.facebook.com/group.php?gid=37671048001&ref=mf          |
+-------------------------------------------------------------------+
| DILARANG : MLM, money game, OOT, iklan tanpa izin, SARA, testing, |
| pembicaraan pribadi, one line message,  melecehkan,  tidak sopan. |
+-------------------------------------------------------------------+
| Buat subjek yang kreatif, jangan : "tanya", "help", "mohon bantu" |
| Usahakan besar attachment < 200 kb. Gunakan  winzip  jika  perlu. |
+-------------------------------------------------------------------+
| Ajak teman-teman Anda bergabung dengan mengirim e-mail kosong ke  |
| XL-mania-subscribe@yahoogroups.com atau kirimkan mereka file dari |
| http://groups.yahoo.com/group/XL-mania/files/Promotion/           |
+-------------------------------------------------------------------+
| Berikan testimoni di : http://www.friendster.com/xlmania atau...  |
| http://www.xl-mania.com/2008/06/testimoni-xl-mania.html           |
+-------------------------------------------------------------------+
| Message lama ada di :                                             |
| http://groups.yahoo.com/group/XL-mania/messages [perlu yahoo id]  |
| http://www.mail-archive.com/xl-mania@yahoogroups.com              |
+-------------------------------------------------------------------+
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Group Charity

Be the Change

A citizen movement

to change the world

Yahoo! Groups

Weight Management Challenge

Join others who

are losing pounds.

.

__,_._,___

Nenhum comentário:

Arquivo do blog