ปรุงก่อนชิม
Location :
นนทบุรี Thailand

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 4 คน [?]




New Comments
Group Blog
 
All Blogs
 
Friends' blogs
[Add ปรุงก่อนชิม's blog to your web]
Links
 

 

VBA Excel ให้ Cell ที่เลือกมีสี เพิ่มสีให้ cell ที่เลือก

  ตัวอย่างที่ทำที่ sheet1 มีขั้นตอนดังนี้

1. สร้างชื่อที่ A2 และ A3 เป็นชื่อ Pcell และ Ccell ตามลำดับ
2.ที่ A1 ให้สร้างสูตร =Pcell
3.Copy code ไปว่างที่ VBA editor ของ Sheet1
code
'-----------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ss As String
With ActiveCell
.Interior.ColorIndex = 5
End With
ActiveWorkbook.Names("Pcell").RefersTo = ActiveWorkbook.Names("Ccell").RefersTo
ActiveWorkbook.Names("Ccell").RefersTo = "=""" & Target.Address(False, False) & """"
ss = Range("A1").Value
Range(ss).ClearFormats
End Sub
'------------------------------------

การสร้างชื่อด้วย Name manager




 

Create Date : 04 มกราคม 2557    
Last Update : 4 มกราคม 2557 12:46:42 น.
Counter : 1558 Pageviews.  

VBA Excel บันทึกผลบอล

  Load ได้จาก Link นี้





copy code ที่ Module1
Option Explicit
Dim lastData As Long
Sub Button1_Click()
Dim N As Integer: N = 0
Dim sRow As Integer: sRow = 0
 Dim firstTeam As String: Dim Score As String: Dim SecondTeam As String
Range("B4").Select
Do Until ActiveCell.Value = ""
N = N + 1
firstTeam = Cells(3 + N, 2).Value
Score = Cells(3 + N, 3).Value
SecondTeam = Cells(3 + N, 4).Value
Call getCalculateResult(N, firstTeam, Score, SecondTeam)
Selection.Offset(1, 0).Select
Loop
Call consolidateData(lastData)
'---count rows
Range("G4").Select
Do While ActiveCell.Value <> ""
sRow = ActiveCell.Row
Selection.Offset(1, 0).Select
Loop
Call Module1.final_sort(sRow)

End Sub
Sub getCalculateResult(records As Integer, firstTeam As String, Score As String, SecondTeam As String)
Dim R, B As Integer: B = 2: R = 1 + (records * 2)
Dim SC As Variant
Dim X, Y As Integer
Dim result1, result2 As Integer
SC = Split(Score, "-")
X = SC(0)
Y = SC(1)
Debug.Print X & "-" & Y
'---------- Calculate result
If X > Y Then result1 = 3
If X = Y Then result1 = 1
If X < Y Then result1 = 0
If result1 = 3 Then result2 = 0
If result1 = 1 Then result2 = 1
If result1 = 0 Then result2 = 3
'---------- plot score
Cells(B + R - 1, 7).Value = firstTeam: Cells(B + R - 1, 8).Value = result1
Cells(B + R, 7).Value = SecondTeam: Cells(B + R, 8).Value = result2
lastData = B + R
End Sub

Sub consolidateData(LData As Long)
Dim lRow As Long
Dim ItemRow1, ItemRow2 As String
Dim lengthRow1, lengthRow2 As String
Range(Cells(4, 7), Cells(LData, 8)).Select
Call Module1.first_sort(LData)
    lRow = 4
    Cells(lRow, "G").Select
Do While (Cells(lRow, "G") <> "")
        ItemRow1 = Cells(lRow, "G")
        ItemRow2 = Cells(lRow + 1, "G")
                If (ItemRow1 = ItemRow2) Then   '-----same team is true
                            Cells(lRow, "H") = Cells(lRow, "H") + Cells(lRow + 1, "H") '-------sum
                                Range(Cells(lRow + 1, "G"), Cells(lRow + 1, "H")).Select
                                Selection.Delete Shift:=xlUp
                                Cells(lRow + 1, "G").Select
                Else
                            lRow = lRow + 1
                End If
Loop
End Sub
Sub first_sort(LD As Long)
    Range(Cells(4, "G"), Cells(LD, "H")).Select
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("G4:G" & LD) _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("G4:G" & LD)
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub
Sub first_sort_(LD As Long)
    Range("G4:H27").Select
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("G4:G27") _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("G4:H27")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub
Sub final_sort(LD As Integer)
    Range("G4:H" & LD).Select
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("H4:H" & LD), _
        SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("G4:H" & LD)
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub




 

Create Date : 04 มกราคม 2557    
Last Update : 4 มกราคม 2557 12:34:05 น.
Counter : 949 Pageviews.  

การสร้าง Collapse/expand บรรทัดใน Excel แทนการ Group | sub-total (ภาค2)

  จากตอนที่ผ่านมา เราต้องระบุเลขบรรทัดเอง ภาค2 นี้เราให้โปรแกรมค้นหาเลขบรรทัดที่จะ hide/unhide เอง โดยตอนสร้างหัวข้อให้ใส่ * ไว้หน้าหัวข้อ และ ** ใว้บรรทัดท้ายสุด

โค๊ดในการหาตามนี้
Sub surveyTopic(sht As String)
Dim r As Range
'Dim rTopic(25) As Integer
Dim a As Integer
Sheets(sht).Select
a = 1
For Each r In Range("a1:a100")
        If Left(r.Value, 1) = "*" Then
            rTopic(a) = r.Row()
            a = a + 1
        End If
        Next
      '  MsgBox rTopic(1) & " _" & rTopic(2) & " _" & rTopic(3) & " _" & rTopic(4)
End Sub

จะทำการหาเลขบรรทัดที่มี * แล้วเก็บไว้ที่ตัวแปร Array rTopic
เรียกใช้ Sub นี้ต้อนคลิก Sheets ต่างๆ โดยใส่ code ไว้ที่ workbook

Sub Workbook_SheetActivate(ByVal Sh As Object)
Call surveyTopic(Sh.Name)
End Sub

ส่วนการระบุบรรทัดแต่ละหัวข้อทำได้ง่ายกว่าเดิมตาม Code ข้างล่าง 
Sub ต่างๆ ตามข้างล่างจะถูกเรียกใช้จากการ คลิก object 

วิธีการคือต้อง Insert object สี่เหลียมมาคลุมหัวข้อที่มีดอกจัน แล้วปรับ Tranoarency 100% ลบขอบออก แล้วสร้าง Link macro มาที่ Sub Topic ตามลำดับ เป็นอันเสร็จวิธี
เวลาจะ Insert บรรทัด ก็ไม่ต้องแก้ code เหมือนภาค 1

Option Explicit
Public rTopic(25) As Integer

'---------------------  call center
Sub Topic1()
        Call callapsExpand(ActiveSheet.Name, rTopic(1) + 1, rTopic(2) - 1, 1500)
End Sub
Sub Topic2()
        Call callapsExpand(ActiveSheet.Name, rTopic(2) + 1, rTopic(3) - 1, 1500)
End Sub
Sub Topic3()
        Call callapsExpand(ActiveSheet.Name, rTopic(3) + 1, rTopic(4) - 1, 1500)
End Sub
Sub Topic4()
        Call callapsExpand(ActiveSheet.Name, rTopic(4) + 1, rTopic(5) - 1, 1500)
End Sub
Sub Topic5()
        Call callapsExpand(ActiveSheet.Name, rTopic(5) + 1, rTopic(6) - 1, 1500)
End Sub
Sub Topic6()
        Call callapsExpand(ActiveSheet.Name, rTopic(6) + 1, rTopic(7) - 1, 1500)
End Sub
Sub Topic7()
        Call callapsExpand(ActiveSheet.Name, rTopic(7) + 1, rTopic(8) - 1, 1500)
End Sub
Sub Topic8()
        Call callapsExpand(ActiveSheet.Name, rTopic(8) + 1, rTopic(9) - 1, 1500)
End Sub
Sub Topic9()
        Call callapsExpand(ActiveSheet.Name, rTopic(9) + 1, rTopic(10) - 1, 1500)
End Sub
Sub Topic10()
        Call callapsExpand(ActiveSheet.Name, rTopic(10) + 1, rTopic(11) - 1, 1500)
End Sub
Sub Topic11()
        Call callapsExpand(ActiveSheet.Name, rTopic(11) + 1, rTopic(12) - 1, 1500)
End Sub
Sub Topic12()
        Call callapsExpand(ActiveSheet.Name, rTopic(12) + 1, rTopic(13) - 1, 1500)
End Sub
Sub Topic13()
        Call callapsExpand(ActiveSheet.Name, rTopic(13) + 1, rTopic(14) - 1, 1500)
End Sub
Sub Topic14()
        Call callapsExpand(ActiveSheet.Name, rTopic(14) + 1, rTopic(15) - 1, 1500)
End Sub
Sub Topic15()
        Call callapsExpand(ActiveSheet.Name, rTopic(15) + 1, rTopic(16) - 1, 1500)
End Sub
Sub Topic16()
        Call callapsExpand(ActiveSheet.Name, rTopic(16) + 1, rTopic(17) - 1, 1500)
End Sub
Sub Topic17()
        Call callapsExpand(ActiveSheet.Name, rTopic(17) + 1, rTopic(18) - 1, 1500)
End Sub
Sub Topic18()
        Call callapsExpand(ActiveSheet.Name, rTopic(18) + 1, rTopic(19) - 1, 1500)
End Sub
Sub Topic19()
        Call callapsExpand(ActiveSheet.Name, rTopic(19) + 1, rTopic(20) - 1, 1500)
End Sub
Sub Topic20()
        Call callapsExpand(ActiveSheet.Name, rTopic(20) + 1, rTopic(21) - 1, 1500)
End Sub





Sub callapsExpand(sht As String, Frow As Integer, Lrow As Integer, delay As Integer)
        Dim i
        If Rows("" & Frow & ":" & Lrow & "").EntireRow.Hidden = True Then
                         For i = Frow To Lrow
                                 Call delay2(delay)
                                Sheets(sht).Range(Cells(i, 1), Cells(i, 1)).EntireRow.Hidden = False
                        Next i
        Else
                         For i = Frow To Lrow
                                 Call delay2(delay)
                                Sheets(sht).Range(Cells(i, 1), Cells(i, 1)).EntireRow.Hidden = True
                        Next i
        End If
End Sub


Sub delay2(duration_ms As Integer)
Dim i
    For i = 1 To duration_ms
        DoEvents
    Next i
End Sub




 

Create Date : 24 กรกฎาคม 2556    
Last Update : 24 กรกฎาคม 2556 8:13:27 น.
Counter : 1647 Pageviews.  

การสร้าง Collapse/expand บรรทัดใน Excel แทนการ Group | sub-total (ภาค 1)

การยุบหรือขยายบรรทัดภายใต้หัวข้อใหญ่ อย่างดูดีมีชาติตระกูล ทำได้ตามตัวอย่างนี้




เริ่มจากสร้างงานบน sheet ตามปกติ ซึ่งมีหัวข้อใหญ่ที่ต้องการคลิด และ หัวข้อย่อยที่ต้องการยุบ-ขยาย จากนั้นให้สร้าง Link จากหัวข้อใหญ่แต่ละหัวข้อให้ชี้ไปยัง Sub ต่างๆ ซึ่งเราต้องสร้าง Sub ต่างๆขึ้นมาเองเท่าตามจำนวนหัวข้อ จากตัวอย่างนี้ทำไว้ 4 หัวข้อ แต่ละหัวข้อเรียกใช้ Sub callapsExpand ซึ่งต้องการค่า parameter ตัวนี้

callapsExpand("Call Center", 8, 13, 1500)
callapsExpand("ชื่อชีต", เลขบรรทัดแรก, เลขบรรทัดสุดท้าย, ความเร็วในการยุบ-ขยาย)

ตัวอย่าง code ให้ copy วางที่ module1

  Option Explicit
Sub ce_performance()
        Call callapsExpand("Call Center", 8, 13, 1500)
End Sub

Sub cs_performance()
        Call callapsExpand("Call Center", 15, 19, 1500)
End Sub

Sub r_performance()
        Call callapsExpand("Call Center", 21, 21, 1500)
End Sub

Sub c_performance()
        Call callapsExpand("Call Center", 23, 23, 1500)
End Sub


'---------------------------------------------------

Sub callapsExpand(Sht As String, Frow As Integer, Lrow As Integer, delay As Integer)
        Dim i
        If Rows("" & Frow & ":" & Lrow & "").EntireRow.Hidden = True Then
                         For i = Frow To Lrow
                                 Call delay2(delay)
                                Sheets(Sht).Range(Cells(i, 1), Cells(i, 1)).EntireRow.Hidden = False
                        Next i
        Else
                         For i = Frow To Lrow
                                 Call delay2(delay)
                                Sheets(Sht).Range(Cells(i, 1), Cells(i, 1)).EntireRow.Hidden = True
                        Next i
        End If
End Sub


Sub delay2(duration_ms As Integer)
Dim i
    For i = 1 To duration_ms
        DoEvents
    Next i
End Sub




 

Create Date : 16 กรกฎาคม 2556    
Last Update : 24 กรกฎาคม 2556 8:14:19 น.
Counter : 2131 Pageviews.  

โปรแกรมสุ่มรายชื่อ

Load update on 02/05/2014



ขออภัยที่ไม่ได้มีคำอธิบาย งานยุ่ง ถ้ามีเวลาจะกลับมา edit

screen display



code class - clsData


Option Explicit
Private Sub Class_Initialize()

End Sub
Public Function Lastrows()
'Lastrows = ActiveSheet.UsedRange.Rows.Count
'Lastrows = ActiveSheet.UsedRange.Rows.Count
Lastrows = Cells.SpecialCells(xlCellTypeLastCell).Row
End Function
Public Function LastColumns()
LastColumns = ActiveSheet.UsedRange.Columns.Count
End Function
Public Function LastRow_condition(StrCondition As String, ColsData As Integer) As Long
Dim R As Range
Dim i As Long
i = 0
Range(Cells(2, ColsData), Cells(ActiveSheet.UsedRange.Rows.Count, ColsData)).Name = "forCount"
            For Each R In Range("forCount")
                If R.Value = StrCondition Then
                    i = i + 1
                End If
            Next
LastRow_condition = i + 1
End Function
Public Function LastRow_condition2(ColsData As Integer) As Long
Dim R As Range
Dim i As Long
i = 0
Range(Cells(2, ColsData), Cells(ActiveSheet.UsedRange.Rows.Count, ColsData)).Name = "forCount"
            For Each R In Range("forCount")
                If IsDate(R.Value) Then
                    i = i + 1
                End If
            Next
LastRow_condition2 = i + 1
End Function
Public Sub SheetCopy(sh1 As String)
 Sheets(sh1).Select
    Cells.Select
  Selection.Copy
End Sub
Public Sub SheetPaste(sh2 As String)
   Sheets(sh2).Select
    Range("A1").Select
    ActiveSheet.Paste
End Sub
Public Sub a1(s As String)
Cells(1, 1) = s
End Sub
Public Sub a2(d As String)
Cells(1, 2) = d
End Sub





code module ----random9

Option Explicit
Dim nPrize As Integer
Dim backupText As String
Dim EmpFirstRound(2000, 6) As String
Dim max As Integer
Sub openForm1()
Dim i, j As Integer
Dim Tepakorn As clsData
Set Tepakorn = New clsData
'--------------------------------------------------------------------  Get data to area variable
Sheets("data").Select
                For i = 2 To Tepakorn.Lastrows
                        For j = 1 To 6
                                Cells(i, j).Select
                                EmpFirstRound(i, 0) = i
                                EmpFirstRound(i, j) = Cells(i, j).Value
                        Next j
                Next i
'--------------------------------------------------------------------  Get data to area variable
max = i - 2
UserForm1.Show
End Sub
Sub startRandom()
Dim xLoop, Litems  As Integer
                                    nPrize = Worksheets("config").Cells(3, 2).Value
                                    UserForm1.ListBox1.Clear
                      If Worksheets("config").Range("R1").Value = 1 Then                   '-------------- Automatic
                                    For xLoop = 1 To nPrize
                                                Call WaitFor(2)
                                                UserForm1.TextBox1.Value = ""
                                                UserForm1.ListBox1.Clear
                                                ' *****************************************************************************************************
                                                Call xRandom                   ' **************************************************************************
                                                ' *****************************************************************************************************
                                    Next xLoop
                      End If
                        If Worksheets("config").Range("R1").Value = 2 Then                    '-------------- one by one
                                                ' *****************************************************************************************************
                                                Call xRandom                   ' **************************************************************************
                                                ' *****************************************************************************************************
                        End If
End Sub
Sub xRandom()
Dim EmpSecondRound(4, 20) As String
Dim nFreeRandom As Integer
Dim T1, T2 As Integer
Dim Lucky As Integer
Dim i, j, nFirstRandom As Integer

'--------------------------------------------------------------------  see config
nFreeRandom = Worksheets("config").Cells(4, 2).Value
UserForm1.Label3.Caption = "¼Ùé⪤´Õ¨Ò¡ " & nFreeRandom & " ¤¹  "
UserForm1.Label2.Caption = "ÊØèÁ" & nFreeRandom & " ¤¹  ¨Ò¡¼ÙéÁÕÊÔ·¸Ô·ÑéËÁ´ "
T1 = Worksheets("config").Cells(3, 5).Value
T2 = Worksheets("config").Cells(4, 5).Value

For i = 1 To nFreeRandom
Again:
          ' *****************************************************************************************************
                                                Lucky = Int((max - 2 + 1) * Rnd + 2)                 ' ****************************** first round
            ' ****************************************************************************************************
           ' MsgBox EmpFirstRound(Lucky, 1) & "- " & yDuplicate(EmpFirstRound(Lucky, 1))
            If xDuplicate(EmpFirstRound(Lucky, 1)) = "yes" Or yDuplicate(EmpFirstRound(Lucky, 1)) = "yes" Then    ' EmpFirstRound(Lucky, 1) is  an EmpID
                    GoTo Again    '-------- duplicated
            Else '--------do not duplicated
                            UserForm1.ListBox1.AddItem EmpFirstRound(Lucky, 1) & "- " & EmpFirstRound(Lucky, 2) & "   " & EmpFirstRound(Lucky, 3)
                            EmpSecondRound(0, i) = i     'items number
                            EmpSecondRound(1, i) = EmpFirstRound(Lucky, 1)  'empid
                            EmpSecondRound(2, i) = EmpFirstRound(Lucky, 2)  'name
                             EmpSecondRound(3, i) = EmpFirstRound(Lucky, 3)  'lastname
                             EmpSecondRound(4, i) = EmpFirstRound(Lucky, 6)  'site
                            Call WaitFor(T1)
                             nFirstRandom = i
            End If
Next i
'--------------------------------------------------------------------  Second Random from area variable -"EmpFirstRound"
Call WaitFor(T2)

          ' *****************************************************************************************************
                      Lucky = Int((nFirstRandom - 1 + 1) * Rnd + 1)                        ' ****************************** second round
            ' ****************************************************************************************************

For i = 1 To nFirstRandom
                        If Lucky = EmpSecondRound(0, i) Then
                                                If UserForm1.ListBox2.ListCount = 0 Then
                                                                Sheets("backup").Select
                                                                Columns("A:A").Select
                                                                Selection.ClearContents
                                                End If
                                    UserForm1.TextBox1.Value = EmpSecondRound(1, Lucky) & "-" & EmpSecondRound(2, Lucky) & "   " & EmpSecondRound(3, Lucky)
                                    UserForm1.ListBox2.AddItem EmpSecondRound(1, Lucky) & "-" & EmpSecondRound(2, Lucky) & "    " & EmpSecondRound(3, Lucky) & " - " & EmpSecondRound(4, Lucky)
                        End If
Next i
'------------------------------------back up start
' via text file
 backupText = EmpSecondRound(1, Lucky) & " - " & EmpSecondRound(2, Lucky) & "    " & EmpSecondRound(3, Lucky) & " - " & Now()
 Call random9.backup(backupText)
' via excel
Sheets("backup").Select
 Call random9.backup2(backupText)
'------------------------------------back up end
UserForm1.TextBox2.Value = UserForm1.ListBox2.ListCount & " of " & nPrize
            If UserForm1.ListBox2.ListCount = nPrize Then
             MsgBox "Done ! "
            End If
Call WaitFor(T2)
End Sub

Sub WaitFor(ByVal NumOfSeconds As Long)
Dim SngSec As Long
SngSec = Timer + NumOfSeconds
            Do While Timer < SngSec
                    DoEvents
            Loop
End Sub
Function xDuplicate(luckyPerson As String) As String 'for  Listbox2
Dim chk  As Integer
        For chk = 0 To UserForm1.ListBox2.ListCount - 1
                    If luckyPerson = GetEmpID(UserForm1.ListBox2.List(chk)) Then
                               xDuplicate = "yes"
                               Exit Function
                    End If
        Next chk
        xDuplicate = "no"
End Function
Function yDuplicate(luckyPerson As String) As String    'for  Listbox1
Dim chk  As Integer
        For chk = 0 To UserForm1.ListBox1.ListCount - 1
                    If luckyPerson = GetEmpID(UserForm1.ListBox1.List(chk)) Then
                               yDuplicate = "yes"
                               Exit Function
                    End If
        Next chk
        yDuplicate = "no"
End Function
'Return an EmpID only  (the EmpID form ----empid - name    lastname -  site)
Function GetEmpID(T As String) As String
Dim C As Integer
                For C = 1 To Len(T)
                        If Mid(T, C, 1) = "-" Then
                                GetEmpID = Left(T, C - 1)
                                Exit Function
                        End If
                Next C
End Function

Sub backup(text1 As String) '   ok
'------------------------for back up on note pad
'-----------must reference to " the Microsoft scripting runtime "
    Dim FSO As FileSystemObject
    Dim FSOFile As TextStream
    Dim FilePath As String
    Dim NoOfLoop As Integer
    FilePath = "D:backUpRandom.txt" ' create a test.txt file or change this
     Set FSO = New FileSystemObject
     ' opens  file in write mode
    Set FSOFile = FSOTextFile(FilePath, ForAppending, True)
         ' write your code here
    FSOFile.WriteLine (" lucky man----is  " & text1)
    FSOFile.Close
End Sub
Sub backup2(text1 As String) '   ok
        Sheets("backup").Select
        Dim i, j
        i = 1
        j = 1
                Do Until Cells(i, 2).Value = ""         'check data last rows existing
                            i = i + 1
                Loop

                'if old data more than 20,000 will clear all
                If i > 20000 Then
                            Columns("B:B").Select
                            Selection.ClearContents
                            i = 1
                 End If
        Cells(i, 2).Value = text1
        Do Until Cells(j, 1).Value = ""         'check data last rows existing
                            j = j + 1
        Loop
                Cells(j, 1).Value = text1

End Sub

Sub testx()
Dim a As String
T:
                    MsgBox "T"
                    a = InputBox("s", "s")
                                If a = "t" Then
                                        GoTo T
                                Else
                                        MsgBox "<>T"
                                End If
End Sub
Sub testgetID()
Dim textt As String
textt = "1234348 - Thailand"
MsgBox GetEmpID(textt)
End Sub


code form --userform1

Option Explicit
Private ScrWidth&, ScrHeight&
Private Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex&) As Long
Private Sub UserForm_Initialize()
    Dim Factor As Single
    Factor = 0.75 'adjust to suit
    Me.Width = GetSystemMetrics32(0) * Factor '< in pixels
    Me.Height = GetSystemMetrics32(1) * Factor
End Sub

Private Sub CommandButton1_Click()
Call random9.startRandom
End Sub







 

Create Date : 23 มีนาคม 2556    
Last Update : 7 กรกฎาคม 2557 13:34:33 น.
Counter : 2125 Pageviews.  

1  2  3  4  
 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.