ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¤ÀÂ÷³æ¸¹

¦^´_ 10# PJChen


Ãö©ó©â¶Hªº°ÝÃD ¸Ñ¨M¤è¦¡¦p¤U
¥ý½m²ß¦p¦ó¾Þ§@"·s¼WºÊ¬Ý¦¡"
https://www.youtube.com/watch?v=SvUFa37qOXo
7:08’
©Î
https://blog.gtwang.org/programming/excel-vba-debug-error-handling/

µM«á ¶}excel vba
¿é¤J
Sub aa()
Dim ar, ar1
ar = Array(1, 2, 3)
ar1 = Array(1, 2, 3)
ReDim Preserve ar(1 To 3)
ReDim Preserve ar1(2 To 4)

Debug.Print ar(1)
Debug.Print ar1(1) '<--¦¹¦æ·|¥X¿ù¥¿±` ½ÐÄ~Äò¬Ý¤U¥h
End Sub

1.ª`·NºÊ¬Ý¦¡ ar ,ar1ªº®t§O ½Ð±N¥ª«e¤èªº " ¥Ð " ¦r²Å¸¹ÂI¶} ¨Ã§PÂ_¨âªÌªÅ¶¡½s¸¹ªº¤£¦P
2.¬O§_ar1(1) ¥X²{°}¦C¶W¹L½d³ò   ¥Nªí¨S¦³ar1(1)ªº¦ì¸m
­×§ï¬°ar1(2) ¬O§_¥¿±`

¥t¥~¥i¥H¸ÕµÛ¥[¤J
ar2=array(1,2,3)
redim Preserve ar2( 3)
·|µo²{¸ò redim Preserve ar( 1 to 3) ¤£¤@¼Ë
¦]¬°
redim Preserve ar2( 3)
¬OÁY¼g
­ì©l¥¿½Tªº¼gªk¬O
redim Preserve ar2(0 to 3)

µ²½×:¸g¹L¤j¶qªº¨Ï¥Î¸gÅç ¤ÏõX«Øij­è±µÄ²ªÌªÌºÉ¶q¦h¹Á¸Õ 0 to nªº¼gªk,
¥Ñ©ó°}¦Cªº °Ï°ì³]¸m¤j¤p(n to n)¥Îªk «Ü®e©ö»PÀx¦s®æÄæ¦C¦ì¸¹½X·f°t °j°é·f°t
«áÄò¥i¥H´î¤Ö³\¦h·L½Õªº¨BÆJ   ¤]·|¸û¬°¤u¾ãª½Æ[

­YÁÙ¬O¦³ºÃ´b google ÃöÁä¦r"redim 1 to n ¥Îªk"

TOP

¦^´_ 7# ­ã´£³¡ªL


    ÁÂÁ½׾Â,ÁÂÁ«e½ú«ü¾É
«á¾ÇÂǦ¹©«¾Ç¨ì¶¶°j°é¸Ì°fµÛ¶]µ²ªG,³o¬O«á¾Ç³o±e¤~±q¨S·Q¹Lªº,¾Ç²ß¤ß±o¦p¤U,½Ð«e½ú¦A«ü¾É
°õ¦æ«e:


°õ¦æµ²ªG:



Option Explicit
Sub TEST_A1()
Dim Arr, i&, j%, Vr, TR
'¡ô«Å§iÅܼÆ
Arr = Range([g1], [e65536].End(3))
'¡ô¥OArrÅܼƬO¤Gºû°}¦C,¥HÀx¦s®æ­È±a¤J
Vr = Array("000-", "0000-", "000")
'¡ô¥OVrÅܼƬO¤@ºû°}¦C
For i = 3 To UBound(Arr)
'¡ô³]¶¶°j°éi
    TR = Split(Arr(i, 1) & "--", "-")
    '¡ô¥OTRÅܼƬO¤@ºû°}¦C: Arr°}¦C­È³s±µ"--"¦¨¬°·s¦r¦ê«á,¦A¥H"-"¤À³Î¸Ó¦r¦ê¦¨
    '(¯Á¤Þ¸¹¦Ü¤Ö·|¦³0~2)

    For j = 0 To 2
    '¡ô³]¶¶°j°éj
        Arr(i - 2, 3 - j) = IIf(IsNumeric(TR(j)), Format(TR(j), Vr(j)), "")
       '¡ô¥O­ì¨ÓªºArr°}¦C­È±q²Ä1¦C¶}©l¼g¤J·s°}¦C­È
        'IIf():¦pªGIsNumeric(TR(j))ÅÞ¿è­È¬OTrue,´N¦^¶Ç Format(TR(j), Vr(j))¦r¦ê,
        '§_«h¦^¶ÇªÅ¦r¤¸
        'IsNumeric(TR(j)):TR°}¦Cªºj°j°é¼Æ¯Á¤Þ¸¹°}¦C­È¬O¤£¬O¼Æ­È?? ¦^¶ÇTrue ©Î False
        'Format(TR(j), Vr(j)):¥OTR°}¦Cªºj°j°é¼Æ¯Á¤Þ¸¹°}¦C­ÈÂà¤Æ¦¨
        'Vr°}¦Cªºj°j°é¼Æ¯Á¤Þ¸¹°}¦C­È³W«hªº®æ¦¡¦r¦ê

    Next j
Next i
With [r3].Resize(UBound(Arr) - 2, 3)
'¡ô¥H¤U¬OÃö©ó[R3]Àx¦s®æÂX®i©Ò»Ý½d³òÀx¦s®æªºµ{§Ç
     .NumberFormatLocal = "@"
     '¡ô¥O¸Ó½d³òÀx¦s®æ®æ¦¡¬O ¤å¦r
     .Value = Arr
     '¡ô¥O¸Ó½d³òÀx¦s®æ­È¥HArr°}¦C­È±a¤J
End With
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

        ÀR«ä¦Û¦b : §Ñ¥\¤£§Ñ¹L¡A§Ñ«è¤£§Ñ®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD