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

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

¦^´_ 9# lpk187
§Ú¸Õ¹L¤F!¥i¥H¦ý¦³¤@­Ó¦a¤è·|¿ù»~¡A²Ä¤@¦¸¸ê®ÆÂà¥X¥i¥H¡A¦A«ö²Ä¤G¦¸¥L·|¥X²{¤U¹Ï
AAA.jpg
  1. Sub Workbook_Open2()
  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:F1")
  8. arrb = Sheets("¤u§@ªí1").Range("A2:F2")
  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).Resize(UBound(arra), UBound(arra, 2)) = 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(arrb(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).Resize(UBound(arrb), UBound(arrb, 2)) = arrb
  25.     End With
  26. 20:
  27.     Workbooks(xlFileb).Close True

  28. End Sub
½Æ»s¥N½X
¥t¤@¤è­±¦pªG¶Ç°e¤è¦¡Åܦ¨¦p¤U¹Ï
c.xlsx·|¦³¨ç¼Æ¥h­pºâ¼Æ­È¡A¥i¥H¸õ®æ¶Ç°e¶Ü

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

¦^´_ 12# lpk187


    ¦n!§Ú¥þ³¡¾ã²z¤@¤U¦A¸ò§A»¡¡AÁÂÁÂ

TOP

¦^´_ 12# lpk187
§Ú±N¸ê®Æ¾ã²z¦n¤F

¨C¤é§ó·s±µ¦¬¡A¶À¦â°Ï¶ô¦³sub ­pºâ¼Æ¶q¡A©Ò¥H§Æ±ævba¶K¹L¥h¤£·|Âл\¡A©ÎªÌ¦³¤°»ò¤èªk¥i¥H¸Ñ¨M¤]¥i¥H¡A
¦]¬°¶Ç°e¹L¥hªº¸ê®Æ¡A¦³¥i¯à·|°µ·L½Õ¡A©Ò¥H¤~§Æ±æ¨ç¼Æ¤£­n³QÂл\±¼¡C
¦@·|¶Ç°e3µ§¸ê®Æ¨ì¦U­Ó¤£¦Pªº¤u§@ªí¡C
VBA¸ê®Æ¦Û°Ê¶Ç°e°ÝÃD.rar (302.42 KB)

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

¦^´_ 15# lpk187


ÁÂÁÂ! ¶¶§Q¹B§@¡A¦ý¬O´X¥G¬Ý¤£À´¡A¤£ª¾¹D¥LªºÅÞ¿è«ç»ò¥h§PÂ_¨ú±o¾ã­Ó¸ê®Æ¥á¨ì¤u§@ªí1 ¡B2 ¡B3   µ{«×®t¤Ó¦h¤F@_@

¥»¨Ó·Q¦Û¤v§ï§¹®M¥Î¨ì¥t¤@­Ó¤u§@ªí¡A¬Ý¨Ó¦³¨ÇÃø«×¡A§Æ±æµ¥§Ú¾ã²z§¹¸ê®Æ§¹¡A¯à¦bÀ°§Ú¸Ñµª¡AÁÂÁÂ

TOP

¦^´_ 16# mark761222

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

   

TOP

¦^´_ 17# lpk187

Àɮ׶ץX.rar (701.29 KB)

¦pªG T»PB¸òCªº ¤£·|½Æ»sªº¦a¤è¤£¤@¼Ë ¡AÁÙ¦³±NÀɮפÀ¦Ü2­Óexcel«ç»ò§ó§ï©O?¡A¦pªþ¥ó
¦³¤T­ÓÀɮ׸ò¤W¤@¦¸¤£¤@¼Ë¡A¦pªG¦h¤@­Óexcel¡AÁÙ¦³TB¦ì¤l¤£¦P¡C
¬Ý¤F§Aªº±Ð¾Ç¡A§Ú³»¦h¥u¯à§â¥¦¤À¦¨2­Ó¤u§@ªí¥h¶]¡A¦pªG¾ã¦X¦b¤@°_¡A«ç»òÅý¥L¥h§P§O©O

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

¦^´_ 19# lpk187

©êºp§Ú¥i¯à»¡©úªº¤£°÷¸Ô²Ó¡A§Ú±NÀÉ®×­«·s¾ã²z¥ÎÃC¦â¤À¶}¤F
ªþ¥ó¤¤¦³EXCELÀÉ®×»P¹Ï¤ù»¡©ú

¶À¦â°Ï¶ô¸õ¶}¤£½Æ»s¹L¥h¡A¦]¬°¦³¨ç¼Æ¤£§Æ±æÂл\
¸ê®Æ·J¾ã¨º³¡¤À¡AÀx¦s®æ¬O¤£·|Åܰʪº¡A©Ò¥H±q¨ºÃäµo¥X¼Æ¾Úµ¹¦U­Óexcleªº¤u§@ªí¡A¦pªG«e­±¤é´Á¬Û¦P¤£¼g¤J

¤£ª¾¹D³o¼Ë°÷¤£°÷²M°£¡A¦pªG­þ¸Ì¤£À´¦A¸ò§ÚÁ¿
ÁÂÁÂ

¹Ï¤ù»¡©ú.rar (847.13 KB)
Àɮ׶ץX.rar (749.76 KB)

TOP

        ÀR«ä¦Û¦b : ¥Ç¿ù¥XÄb®¬¤ß¡A¤~¯à²M²bµL·Ð´o¡C
ªð¦^¦Cªí ¤W¤@¥DÃD