Wawan

Find Row Position of Certain Text

| Wawan | visual basic

Terkadang di Excel, kita perlu mencari posisi baris dari suatu text tertentu, ini tentunya kalau worksheet yg kita gunakan menggunakan sebuah template yg tidak berubah bentuknya. Disinilah fungsi dibawah ini mengambil perannya.

'------
'Input:
'   sText: text yg ingin dicari
'   SearchDirection: arah pencarian, maju atau mundur
'   SearchOrder: urutan pencarian, baris atau kolom duluan
'   kedua input yg terakhir bersifat optional
'   defaultnya adalah maju dan baris dahulu br kolom
'Output: posisi baris dari text input
'------
Private Function pFindRowPos(sText As Variant, _
  Optional SearchDirection As XlSearchDirection = xlNext, _
  Optional SearchOrder As XlSearchOrder = xlByRows) As Long
 
    Dim lResult As Long, oRg As Range
 
    Set oRg = Cells.Find(What:=sText, LookIn:=xlValues, _
    LookAt:=xlPart, SearchOrder:=SearchOrder, _
                 SearchDirection:=SearchDirection, _
    MatchCase:=False, SearchFormat:=False)
 
    If Not oRg Is Nothing Then lResult = oRg.Row
 
    pFindRowPos = lResult
 
    Set oRg = Nothing
End Function

Ehm… fyi, semua post di kategori vba-excel ini aku ubah timestampnya ke 2004.01.01 :mrgreen:

Bagikan artikel ini ke: InfoGue · Lintas Berita · Facebook · Twitter

Related Entries:

Random Entries:

No comments yet.

feel free to leave a comment

Comment Guidelines: Basic XHTML is allowed (a href, strong, em, code). All line breaks and paragraphs are automatically generated. Off-topic or inappropriate comments will be edited or deleted. Email addresses will never be published. Keep it PG-13 people!

All fields marked with " * " are required.