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

[µo°Ý] ±N¸ê®Æ¼g¤J¨ì¨ä¥L¦h­ÓEXCELÀÉ®×

¥»©«³Ì«á¥Ñ lpk187 ©ó 2015-11-4 15:30 ½s¿è

¦^´_ 1# mark761222

­º¥ý¥²¶·»¡©ú¡A¨â­Óxlsªº¤u§@ªí¸ê®Æ¤£¥i¯à¦P¨B¡I¡I´Nºâ¦P®É§ó·s®É¡A¤]¤£¯àºÙ¬°¦P¨B¡I´Nºâµ{¦¡½X¼g¦baÀɮסA¤]¤@¼Ë¡A³£·|¦³¨Ò¥~ªº®É­Ô¡A©Ò¥H¥u¯à¥Hµ{¦¡¨ÓŪ¨úaÀɮתº³Ì·s¸ê®Æ¦Ó¤w¡A¤U­±µ{¦¡½X¤]¥u¬OŪ¨ú³Ì·s¸ê®Æ¡A¦Ó¤£¯àºÙ¤§¬°"¦P¨B"
¨ä2­Ó°ÝÃDµ{¦¡½X¦p¤U¡G
  1. Public Sub ex1()
  2.     Sheets("¤u§@ªí1").UsedRange.ClearContents
  3.     Dim xlPath As Variant, xlFile As Variant
  4.     Dim arr
  5.     xlPath = ThisWorkbook.Path & "\"
  6.     xlFile = "a.xlsx"
  7.     Workbooks.Open (xlPath & xlFile)
  8.     arr = Workbooks(xlFile).Worksheets("¤u§@ªí1").UsedRange
  9.     Workbooks(xlFile).Close True
  10.     Sheets("¤u§@ªí1").[A1].Resize(UBound(arr), UBound(arr, 2)) = arr
  11. End Sub
  12. Public Sub ex2()
  13.     Sheets("¤u§@ªí1").UsedRange.ClearContents
  14.     Dim xlPath As Variant, xlFile As Variant
  15.     Dim Barr, Darr, Earr
  16.     xlPath = ThisWorkbook.Path & "\"
  17.     xlFile = "a.xlsx"
  18.     Workbooks.Open (xlPath & xlFile)
  19.     With Workbooks(xlFile).Worksheets("¤u§@ªí1")
  20.         Barr = .Range("B1", .Cells(65535, "B").End(xlUp))
  21.         Darr = .Range("D1", .Cells(65535, "D").End(xlUp))
  22.         Earr = .Range("E1", .Cells(65535, "E").End(xlUp))
  23.     End With
  24.     Workbooks(xlFile).Close True
  25.     With Sheets("¤u§@ªí1")
  26.         .[A1].Resize(UBound(Barr)) = Barr
  27.         .[B1].Resize(UBound(Darr)) = Darr
  28.         .[C1].Resize(UBound(Earr)) = Earr
  29.     End With
  30. End Sub
½Æ»s¥N½X

TOP

¦^´_ 1# mark761222

½Ð°Ñ¦Ò
http://minyeh187.pixnet.net/blog/post/166816531

TOP

¦^´_ 6# mark761222


   ¤é´ÁÁÙ­«½Æ2¦¸¬O§A¦h¼g¤F For i = 0 To 1 ¡A§â2­ÓFor i = 0 To 1...Next§R¤F§a¡I
­P©ó¬°¤°»ò¥u¶Ç°e¤é´Á¡A¤º®e¤£·|¶Ç°e
«h¬O.Cells(Ro, 1) = arra ¿ù»~¡A§AÀ³¸Ó­n¦h¥[Resize½d³òµ¹¥¦
.Cells(Ro, 1).Resize(Ubound(arra),Ubound(arra,2)) = arra
.Cells(Ro, 1) = arrb ¥ç¦P¤W

TOP

¦^´_ 8# mark761222

¸Õ¸Õ¬Ý
  1. Private Sub Workbook_Open()
  2. Dim xlPath As Variant, Ro As Integer
  3. Dim xlFilea, xlFileb, arra, arrb
  4.     xlPath = ThisWorkbook.Path & "\"
  5. xlFilea = ("B.xlsx")
  6. xlFileb = ("C.xlsx")
  7. arra = Sheets("¤u§@ªí1").Range("A1:E1")
  8. arrb = Sheets("¤u§@ªí1").Range("A2:E2")
  9.     Workbooks.Open (xlPath & xlFilea)
  10.     With Workbooks(xlFilea).Worksheets("¤u§@ªí1")
  11.         Set da = .Columns(1).Find(arra(1, 1), , , , , 2)
  12.         If Not da Is Nothing Then GoTo 10
  13.          Ro = .Cells(65535, 1).End(xlUp).Row + 1
  14.          
  15.         .Cells(Ro, 1) = arra
  16.     End With
  17. 10:
  18.     Workbooks(xlFilea).Close True

  19.     Workbooks.Open (xlPath & xlFileb)
  20.     With Workbooks(xlFileb).Worksheets("¤u§@ªí1")
  21.         Set da = .Columns(1).Find(arra(1, 1), , , , , 2)
  22.         If Not da Is Nothing Then GoTo 10
  23.         Ro = .Cells(65535, 1).End(xlUp).Row + 1
  24.         .Cells(Ro, 1) = arrb
  25.     End With
  26. 20:
  27.     Workbooks(xlFileb).Close True

  28. End Sub
½Æ»s¥N½X

TOP

¦^´_ 11# mark761222

¥i¥Hªº¸Ü¡A½Ðªþ¤W§Aªº½d¨ÒÀɮפW¨Ó¡A¦Ó¥B¬O§A³Ì²×¥Øªºªº½d¨ÒÀÉ¡A¥Øªº¤£¦P¡A´Nºâ¥u¦³¨Ç³\ªº§ïÅÜ¡A¥i¯àµ{¦¡³£­n¤j´Tªº§ïÅÜ¡A´N¹³11¼Óªº°ÝÃD¡A©M¤§«eªº¼gªk¤j³¡¥÷·|¤£¤@¼Ë¡I
¬Æ¦Ü¥i¥Hªº¸Ü¦b½d¨ÒÀɤ¤½Ðªþ¤WCÄæ¤ÎFÄ檺¤½¦¡¡I

TOP

¦^´_ 14# mark761222


    ¦³2ºØ¤è¦¡¡A½Ð¦Û¦æ´ú¸Õ¡A¿ï¾Ü¦Û¤vªº»Ý¨D¡A¤@ºØ¬°¦³¨ç¼ÆªºÀx¦s®æ´N¼g¤J¨ç¼Æ¡A¦ýŲ©ó¦³¥i¯à°µ·L½Õ¬G¦³²Ä¤GºØ¤è¦¡¡A¸õ¹L¦³¨ç¼ÆªºÀx¦s®æ
  1. Option Explicit
  2. Sub Ex() '¤è¦¡1¬°¼g¤J¨ç¼Æ
  3.     Dim xlPath As Variant, xlFile As Variant
  4.     Dim Rng As Range, Rn As Range, Ran As Range, ch As Range
  5.     Dim myCol As Integer, myRow As Integer, k As Integer
  6.     Dim xlRo As Integer
  7.     Dim arr
  8.     xlPath = ThisWorkbook.Path & "\" 'Ū¨ú¥»µ{¦¡Àɪº¸ô®|
  9.     xlFile = "¨C¤é§ó·s±µ¦¬.xlsx" 'Ū¨ú¥»µ{¦¡ÀɦWºÙ
  10.     With ThisWorkbook.Sheets("¤u§@ªí1")
  11.         myCol = .Cells(1, Columns.Count).End(xlToLeft).Column '¬d¸ß¤u§@ªí1ªº³Ì«á¤@Äæ¦ì¸m
  12.         myRow = .Cells(Rows.Count, 1).End(xlUp).Row '¬d¸ß¤u§@ªí1ªº³Ì«á¤@¦C¦ì¸m
  13.         For Each Rng In .Range("A2", .Cells(myRow, 1)) '¦¹°j°é°µ ¦³¸ê®ÆRange¦ì¸mªºÁp¶° Union
  14.             If Rng <> "" Then
  15.                 k = k + 1
  16.                 If k = 1 Then
  17.                     Set Rn = Rng
  18.                 Else
  19.                     Set Rn = Union(Rn, Rng)
  20.                 End If
  21.             End If
  22.         Next
  23.     End With
  24.     Workbooks.Open (xlPath & xlFile) '¥´¶}"¨C¤é§ó·s±µ¦¬.xlsx"¬¡­¶Ã¯
  25.     For Each Ran In Rn
  26.         With Workbooks(xlFile).Sheets(Ran.Value)
  27.             Set ch = .Columns(1).Find(Ran.Offset(, 1), LookAt:=xlWhole, SearchDirection:=2)
  28.             'Àˬd¤é´Á¬O§_¦³­«½Æ¡A·íchÅܼƬ°Nothing®É¡A«hµLµo²{­«½Æ¤é´Á¡A§_«hÂ÷¶}³o¤@¦¸ªº¸ê®ÆÀx¦s¡A¨Ã°õ¦æ¤U¤@­Ó°j°é
  29.             If Not ch Is Nothing Then MsgBox Ran & "¤u§@ªí¤¤ªº" & ch & "¸ê®Æ¤w¦s¦b¡A¤£·|Àx¦s¸ê®Æ": Set ch = Nothing: GoTo 10
  30.             arr = Ran.Offset(, 1).Resize(, myCol - 1)
  31.             ''''§â¤½¦¡´À´«°}¦C¤¤ªº­È'''
  32.             arr(1, 5) = "=SUM(RC[5]:RC[13])"
  33.             arr(1, 6) = "=1-RC[-1]/RC[-2]"
  34.             arr(1, 8) = "=SUM(RC[12]:RC[18])"
  35.             arr(1, 9) = "=1-RC[-1]/RC[-2]"
  36.             arr(1, 29) = "=SUM(RC[5]:RC[10])"
  37.             arr(1, 30) = "=1-RC[-1]/RC[-2]"
  38.             arr(1, 48) = "=SUM(RC[2]:RC[11])"
  39.             arr(1, 49) = "=1-RC[-1]/RC[-2]"
  40.             ''''
  41.             xlRo = .Cells(Rows.Count, 1).End(xlUp).Row + 1
  42.             .Cells(xlRo, 1).Resize(, UBound(arr, 2)) = arr '¼g¤J¸ê®Æ
  43.         End With
  44. 10:
  45.     Next
  46.     Workbooks(xlFile).Close True 'Ãö³¬"¨C¤é§ó·s±µ¦¬.xlsx"¬¡­¶Ã¯
  47. End Sub

  48. Sub Ex1() '¤£¼g¤J¨ç¼Æ¸õ¹L¦³¨ç¼ÆªºÀx¦s®æ
  49.     Dim xlPath As Variant, xlFile As Variant
  50.     Dim Rng As Range, Rn As Range, Ran As Range, ch As Range
  51.     Dim myCol As Integer, myRow As Integer, k As Integer, I As Integer
  52.     Dim xlRo As Integer
  53.     Dim arr
  54.     xlPath = ThisWorkbook.Path & "\" 'Ū¨ú¥»µ{¦¡Àɪº¸ô®|
  55.     xlFile = "¨C¤é§ó·s±µ¦¬.xlsx" 'Ū¨ú¥»µ{¦¡ÀɦWºÙ
  56.     With ThisWorkbook.Sheets("¤u§@ªí1")
  57.         myCol = .Cells(1, Columns.Count).End(xlToLeft).Column '¬d¸ß¤u§@ªí1ªº³Ì«á¤@Äæ¦ì¸m
  58.         myRow = .Cells(Rows.Count, 1).End(xlUp).Row '¬d¸ß¤u§@ªí1ªº³Ì«á¤@¦C¦ì¸m
  59.         For Each Rng In .Range("A2", .Cells(myRow, 1)) '¦¹°j°é°µ ¦³¸ê®ÆRange¦ì¸mªºÁp¶° Union
  60.             If Rng <> "" Then
  61.                 k = k + 1
  62.                 If k = 1 Then
  63.                     Set Rn = Rng
  64.                 Else
  65.                     Set Rn = Union(Rn, Rng)
  66.                 End If
  67.             End If
  68.         Next
  69.     End With
  70.     Workbooks.Open (xlPath & xlFile) '¥´¶}"¨C¤é§ó·s±µ¦¬.xlsx"¬¡­¶Ã¯
  71.     For Each Ran In Rn
  72.         With Workbooks(xlFile).Sheets(Ran.Value)
  73.             Set ch = .Columns(1).Find(Ran.Offset(, 1), LookAt:=xlWhole, SearchDirection:=2)
  74.             'Àˬd¤é´Á¬O§_¦³­«½Æ¡A·íchÅܼƬ°Nothing®É¡A«hµLµo²{­«½Æ¤é´Á¡A§_«hÂ÷¶}³o¤@¦¸ªº¸ê®ÆÀx¦s¡A¨Ã°õ¦æ¤U¤@­Ó°j°é
  75.             If Not ch Is Nothing Then MsgBox Ran & "¤u§@ªí¤¤ªº" & ch & "¸ê®Æ¤w¦s¦b¡A¤£·|Àx¦s¸ê®Æ": Set ch = Nothing: GoTo 20
  76.             xlRo = .Cells(Rows.Count, 1).End(xlUp).Row + 1
  77.             For I = 1 To myCol - 1
  78.                 If I = 5 Or I = 6 Or I = 8 Or I = 9 Or I = 29 Or I = 30 Or I = 48 Or I = 49 Then GoTo 10 '¤£¼g¤J¨ç¼Æ¸õ¹L¦³¨ç¼ÆªºÀx¦s®æ
  79.                 .Cells(xlRo, I) = Ran.Offset(, I)
  80. 10:
  81.             Next
  82.         End With
  83. 20:
  84.     Next
  85.     Workbooks(xlFile).Close True 'Ãö³¬"¨C¤é§ó·s±µ¦¬.xlsx"¬¡­¶Ã¯
  86. End Sub
½Æ»s¥N½X

TOP

¦^´_ 16# mark761222

§Ú¥H¤U¹Ï¨Ó¸ÑÄÀ µ{¦¡¡A§ó¸Ô²Óªº¤èªk¡A§A¥i¥H§Q¥Î F8³v¦æ¨Ó°õ¦æµ{¦¡¡A¨Ã§Q¥Î°Ï°ìÅܼƼƵøµ¡¨ÓÆ[¬Ýµ{¦¡ «ç»ò¨«ªº

   

TOP

¦^´_ 18# mark761222


    ¦pªG T»PB¸òCªº ¤£·|½Æ»sªº¦a¤è¤£¤@¼Ë ¡AÁÙ¦³±NÀɮפÀ¦Ü2­Óexcel«ç»ò§ó§ï©O?
¤£·|½Æ»sªº¦a¤è¡A§Ú¸Ó«ç»ò¼Ë¥h§PÂ_¡H¦ì¸m¡HÃC¦â¡H§¹¥þ¨S¦³³W«h¡I
¶×¥X¸ê®Æ¤u§@ªí¤¤¡A¦³¦n´X­ÓTabl¡A¦ì¸m·|¤£·|¤£¦P¡H¸Ó«ç»ò¹q¸£¥h§P§O¥¦ªº±Ò©l¦ì¸m¡H¥¦¥¼¨Óªº¦ì¸m·|©Mªþ¥ó¤@¼Ë¡H
¦A¨Ó¬O¦X¨ÖÀx¦s®æ¡AVBA§P§O¸ê®Æ¡A­Y¹J¨ì¦X¨ÖÀx¦s®æ¡A³Ì®e©ö¥X¿ù¤F¡C

¬Ý¤F§Aªºªþ¥ó¡A¦pªG¾ã¦X¦b¤@°_¡A©Z¥Õ»¡«ÜÃø¡I
¦Ü©ó¡A­n¤À¦h­ÓÀɮסA©Î¦h­Ó¤u§@ªí¤£¬OÃø¨Æ¡AÃøªº¬O­n¶×¥Xªº¸ê®Æ¡A§¹¥þ¨S¦³¨t²Î©Êªº³W¹º¡I

TOP

¦^´_ 20# mark761222


    ¦b¶×¥X¸ê®Æ¦b¤¤ªº¤u§@ªí¦WºÙ©M¥Øªºªº¤u§@ªí¦WºÙ¦³»~¡A¥i¯à¬O¦]¬°ªÅ®æªºÃö«Y¡A½Ð¦Û¦æ­×¥¿§_«h·|¦³ aaa.png ªº¿ù»~²£¥Í
  1. Sub «ö¶s1_Click()
  2.     Application.ScreenUpdating = False
  3.     Dim d As Object
  4.     Dim xlPath As Variant, xlFile As Variant, aa As Variant
  5.     Dim Rng As Range, Rn As Range, Ran As Range, ch As Range
  6.     Dim myRow As Integer, myCol As Integer, k As Integer, I As Integer, j As Integer, xlRow As Integer
  7.     xlPath = ThisWorkbook.Path & "\"
  8.     Set d = CreateObject("scripting.dictionary") '³]©wd¬°¦r¨åª«¥ó
  9.     With Sheets("¶×¥X¸ê®Æ")
  10.         For Each Rng In .Range("A3", Cells(Rows.Count, 1).End(xlUp)) '¦¹°j°é¬OŪ¨úÀɮצWºÙ
  11.             If Rng <> "" Then
  12.                 d(Rng.Value) = ""
  13.             End If
  14.         Next
  15.         myRow = .Cells(Rows.Count, 1).End(xlUp).Row '¬d¸ß"¶×¥X¸ê®Æ"ªº³Ì«á¤@¦C¦ì¸m
  16.         For Each Rng In .Range("B2", .Cells(myRow, 2)) '¦¹°j°é°µ ¦³¸ê®ÆRange¦ì¸mªºÁp¶° Union¡AŪ¨ú¤u§@ªí¦WºÙ
  17.             If Rng <> "" Then
  18.                 k = k + 1
  19.                 If k = 1 Then
  20.                     Set Rn = Rng
  21.                 Else
  22.                     Set Rn = Union(Rn, Rng)
  23.                 End If
  24.             End If
  25.         Next
  26.     End With
  27.         xlFile = d.keys '±N¦r¨åªºkey­Èµ¹¤©xlFile(¬°°}¦C)¡A¥H¥Ø«eŪ¨úªºÀɮצWºÙ¦³"Daily Yield Rate report ¤À¼t 2015BR"
  28.                         '¥H¤Î"Daily Yield Rate report(EN)2015BR4"2­ÓÀÉ®×
  29.         
  30.     For I = 0 To UBound(xlFile) '¥HÀɮ׬°°µ¬°°j°é¡A¨Ó¶}±ÒÀÉ®×
  31.         With Workbooks.Open(xlPath & xlFile(I) & ".xlsx") '¶}±ÒÀÉ®×
  32.             For Each Ran In Rn '°õ¦æ¤u§@ªí°j°é
  33.                 If Ran.Offset(, -1) Like xlFile(I) Then '¤ñ¹ï¦¹¤u§@ªí¬O§_ÄÝ©óxlFile(I)ÀɮסA¦pªG¬O«h°õ¦æIf¤¤µ{§Ç
  34.                     With .Sheets(Ran.Value)
  35.                         Set ch = .Columns(1).Find(Ran.Offset(, 1), LookAt:=xlWhole, SearchDirection:=2)
  36.                         'Àˬd¤é´Á¬O§_¦³­«½Æ¡A·íchÅܼƬ°Nothing®É¡A«hµLµo²{­«½Æ¤é´Á¡A§_«hÂ÷¶}³o¤@¦¸ªº¸ê®ÆÀx¦s¡A¨Ã°õ¦æ¤U¤@­Ó°j°é
  37.                         If Not ch Is Nothing Then MsgBox Ran & "¤u§@ªí¤¤ªº" & ch & "¸ê®Æ¤w¦s¦b¡A¤£·|Àx¦s¸ê®Æ": Set ch = Nothing: GoTo 10
  38.                         myCol = ThisWorkbook.Sheets("¶×¥X¸ê®Æ").Cells(Ran.Row, Columns.Count).End(xlToLeft).Column
  39.                         xlRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1 'Ū¨ú¥Øªº¤u§@ªíªº³Ì«á¤@¦C¦C¸¹
  40.                         For j = 1 To myCol - 2
  41.                             If Ran.Offset(, j).Interior.Color <> 65535 Then '·íÀx¦s®æ¦â±m¤£ÄÝ©ó¶À¦â¡A«h°õ¦æ½Æ»s­È
  42.                                 .Cells(xlRow, j) = Ran.Offset(, j).Value '½Æ»s­È
  43.                             End If
  44.                         Next
  45. 10:
  46.                     End With
  47.                 End If
  48.             Next '§¹¦¨¤@­Ó¤u§@ªí«á°õ¦æ¤U¤@­Ó¤u§@ªí
  49.             .Close True 'Ãö³¬¤ÎÀx¦sÀÉ®×
  50.         End With
  51.     Next
  52.     Application.ScreenUpdating = False
  53. End Sub
½Æ»s¥N½X

TOP

¦^´_ 20# mark761222


    ·|²£¥Í¿ù»~ªº¤u§@ªí¦WºÙ¬°Daily Yield Rate report ¤À¼t 2015BÀɮתº"B DailyYeild (F1-By Date)"©M"T Daily Yeild (F2-By Date )"

TOP

        ÀR«ä¦Û¦b : ¤ß¤¤±`¦sµ½¸Ñ¡B¥]®e¡B·P«ä¡Bª¾¨¬¡B±¤ºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD