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

[µo°Ý] VBA ¶}±ÒÀÉ®×À³¥Î

¦^´_ 10# Jason80Lo
¸Õ¬Ý¬Ý
  1. Option Explicit
  2. Sub Ex()
  3.     Dim xTime As Variant
  4.     Application.VBE.Windows("§Y®É¹Bºâ").Visible = True
  5.     '30¬í¡B30¤À¡B3¤p®É
  6.     xTime = Int(Application.Text(Time, "[s]") / 30) + 1
  7.     xTime = DateAdd("s", 30 * xTime, 0)
  8.     Debug.Print "¤U¤@­Ó30¬í¾ã", Time, xTime
  9.     xTime = Int(Application.Text(Time, "[m]") / 30) + 1
  10.     xTime = DateAdd("N", 30 * xTime, 0)
  11.     Debug.Print "¤U¤@­Ó30¤À¾ã", Time, xTime
  12.     xTime = Int(Application.Text(Time, "[h]") / 3) + 1
  13.     xTime = DateAdd("h", 3 * xTime, 0)
  14.     Debug.Print "¤U¤@­Ó3¤p®É¾ã", Time, xTime
  15. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ no3-taco ©ó 2015-10-1 20:03 ½s¿è

¦^´_ 11# GBKEE

½Ð°Ýª©¤j¡A¥[ Int() ªº¥Î·N¬°¦ó¡A¦]¬°²Ä¤@¦¸°õ¦æ·|¦³®É¶¡¤Wªº»~®t

xTime = Int(Application.Text(Time, "[m]") / 3) + 1  
xTime = DateAdd("N", 3 * xTime, 0)

TOP

¦^´_ 12# no3-taco

INT ªº¥Î³~¬O§ä¥X,¤ÀÄÁ¼Æ³Q3¾ã°£ªº¾ã¼Æ
  1. Option Explicit
  2. Sub Ex()
  3.     Dim xTime As Variant, nTime As Date
  4.     Application.VBE.Windows("§Y®É¹Bºâ").Visible = True
  5.         nTime = Time
  6.     xTime = Int(Application.Text(nTime, "[m]") / 3) + 1
  7.     xTime = DateAdd("N", 3 * xTime, 0)
  8.     Debug.Print nTime, "²Ä¤@­Ó3¤À¾ã", xTime; "", vbLf
  9.     nTime = xTime
  10.     xTime = Int(Application.Text(xTime, "[m]") / 3) + 1
  11.     xTime = DateAdd("N", 3 * xTime, 0)
  12.     Debug.Print nTime, "¦A¤U­Ó3¤À¾ã", xTime, vbLf
  13.     Debug.Print "§A¬O­n¶¡¹j3¤ÀÄÁ«áªº®É¶¡¦p¤U"
  14.     nTime = Time + #12:03:00 AM#
  15.     Debug.Print Time, "¶¡¹j3¤ÀÄÁ«á", nTime
  16.    
  17. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 13# GBKEE


    ½Ð°Ýª©¤j¡A¶}±ÒtxtÀɳo­Ó¥\¯à¥Ø«e¨C·j´M¤@¦¸³£¬O¦b©T©w¸ê®Æ§¨­«·s¦¬´M¥þ³¡ªºTXTÀÉ¡A¬O§_¥i¥H¦b·j´MTXTÀɮɤ£·|·j´M¨ì«e¦¸·j´M¹LªºTXTÀÉ
    »¡©ú¬°¦p¤Uªþ¥ó

·s¼W¸ê®Æ§¨ (4).rar (7.63 KB)

½Ðª©¤j¬Ý¬Ý¡A¬O¤£¬O¦³Ãþ¦ü¿ìªkÀ°¤p§Ì¸Ñ¨M¡AÁÂÁÂ

TOP

VBA ¶}±ÒÀÉ®×À³¥Î2

½Ð°Ý¦U¦ì°ª¤â ¤p§Ì­ìVBAµ{¦¡½X¥\¯à¬°±N¸ê®Æ§¨ªºTXTÀɳ£¶}±Ò
¦ýTXTÀɦpªG­n¸ê®Æ¤À³Î µ²ªG¦pªþ¥ó txtÀɨC¦æ¹J¨ì"ªÅ®æ"Åã¥Ü¦b¤U¤èÀx¦s®æ
¦ýÁÙ¬OµLªk§¹¦¨¤@ª½¥X²{¿ù»~¡A½Ð±Ð¦U¦ì°ª¤âÀ°¦£ Please~:Q
VBA»Ý¨Dµ²ªG.rar (17.07 KB)

TOP

¦^´_ 14# Jason80Lo
    5¼Óªºµ{¦¡½X¦³¨¾¤î·j´M¨ì«e¦¸·j´M¹LTXTÀɪº§PÂ_¦¡.
  1.   xFile = Dir(xPath & "\*.txt")          '·j´MªþÀɦW
  2. Do While xFile <> ""                   '§ä¨ì
  3.     Set Rng(2) = Rng(1).Find(xFile, LookAT:=xlWhole) '¤ñ¹ï²Ä¤@¦C¤¤ªº txtÀÉ
  4.      '***************************************************
  5.      If Rng(2) Is Nothing Then                        '²Ä¤@¦C¤¤¤ñ¹ï¨S¦³³otxtÀÉ
  6.      '************³o§PÂ_¦¡¤£¬O¶Ü***
  7.           i = 1
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 15# GBKEE


    ª©¤j¡A¤£¦n·N«ä ¤p§Ìªº·N«ä¬O¦]¬°¤U¤@¦¸·j´M¨ìªºTXTÀÉ ¤£­n±N¤W¦¸·j´M¨ìªºTXTÅã¥Ü¦bEXCEL¤W¡A¦]¬°¤p§Ì·|±N­ì¥»sheet1ªº¸ê®Æ¥þ³¡§R°£

TOP

¦^´_ 17# Jason80Lo

¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Private Sub EX()
  3.     Dim xPath As String, Rng(1 To 2) As Range, xFile As String, a As Variant, r As String
  4.     Dim i As Boolean, f As Integer, xString, xMatch As Variant
  5.     Dim S As Worksheet, AR(), x_Row As Integer
  6.    
  7.     If Join(AR, "") = "" Then ReDim AR(0)   '¬°ªÅ°}¦C,°}¦C«Å§i¬°¤@¤¸¯À
  8.     If IsArray([xFile_Add]) Then AR = [xFile_Add]  '·í¬¡­¶Ã¯ªº¦WºÙ¬O°}¦C
  9.     ' [xFile_Add] -> [³o¬¡­¶Ã¯ªº¦WºÙ©Î¨ç¼Æ]
  10.     Set S = ActiveWorkbook.ActiveSheet
  11.     Set Rng(1) = S.Rows(1)                          '¨Ï¥Î¤¤¬¡­¶Ã¯,³o¤u§@ªíªº²Ä¤@¦C
  12.     xPath = "C:\Users\j\Desktop\·s¼W¸ê®Æ§¨ (4)\"    'txt Àɮתº¥Ø¿ý
  13.     xFile = Dir(xPath & "*.txt")                    '·j´MªþÀɦW
  14.     Do While xFile <> ""                            '§ä¨ì
  15.         xMatch = Application.Match(xFile, AR, 0)    '°}¦C¤¤·j´M
  16.         If IsError(xMatch) Then                     '°}¦C¤¤·j´M¨S¦³³otxtÀÉ
  17.             If Join(AR, "") = "" Then
  18.                 AR(0) = xFile                       '°}¦C²Ä¤@¤¸¯À=xFile
  19.             Else
  20.                 ReDim Preserve AR(0 To UBound(AR) + 1) '°}¦C¤W­­¤¸¯À+1
  21.                 AR(UBound(AR)) = xFile
  22.             End If
  23.             Set Rng(2) = Rng(1).Cells(Application.CountA(Rng(1)) + 1) '¨Ì§Ç¦b²Ä¤@¦C¤¤
  24.             i = True
  25.             Rng(2).Cells = xFile                    'ÀɦW¼g¤JÀx¦s®æ¤¤
  26.             f = FreeFile
  27.             Open xPath & xFile For Input Access Read As #1  '¶}±Ò¤å¦rÀÉ
  28.                 Do Until EOF(1)                     '°õ¦æ°j°éª½¨ìÀɧÀ¬°¤î¡C
  29.                     Line Input #1, xString          '±N¸ê®ÆŪ¤JÅܼƤ¤¡C
  30.                     a = Split(xString, Space(1))    '¸ÓÀÉ®×¥H,¬°¤À¹j²Å¸¹
  31.                     'Split ªº«¬ºAVariant
  32.                     If i Then
  33.                         Rng(2).Cells(2, 1).Resize(UBound(a) + 1) = Application.Transpose(a)
  34.                         i = 0
  35.                     Else
  36.                         With Rng(2).End(xlDown).Offset(1)
  37.                             .Resize(UBound(a) + 1) = Application.Transpose(a)
  38.                         End With
  39.                     End If
  40.                 Loop
  41.                 Close #f    ' Ãö³¬ÀɮסC
  42.         End If
  43.         xFile = Dir         '¬d¤U¤@­Ó txtÀÉ
  44.     Loop
  45.     If Join(AR, "") <> "" Then ThisWorkbook.Names.Add "xFile_Add", AR    '³o¬¡­¶Ã¯ªº¦WºÙ ¤º®e¬°³o°}¦C,
  46. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 18# GBKEE


    ÁÂÁª©¤j ª©¤j­^©ú¡A¤p§Ì¦n¦n¥h¬ã¨s¤@µf~

TOP

¦^´_ 18# GBKEE


    ½Ð°Ýª©¤j¡A§Ú¸ô®|¸ê®Æ§¨§ó§ï«á¤@ª½¸õ¥X¿ù»~9 °}¦C¯Á¤Þ¶W¥X½d³ò ¡AAR()°}¦C¤@ª½Åã¥Ü«e.TXTÀÉ¡A¦p¤Uªþ¥ó¹ÏÀÉ

TOP

        ÀR«ä¦Û¦b : ¶¢¤HµL¼Ö½ì¡A¦£¤HµL¬O«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD