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

[µo°Ý] ­ì¦³¤u§@ªí¤¤¤£¦PÄæ¦ì¸ê®Æ¡AÂಾ¨ì·s²£¥Í¤u§@ªí¤¤¡A¨Ã­«·s¦w±Æ¦ì¸m(¤w¸Ñ¨M)

¦^´_ 1# jesscc
  1. Sub SourceData_S()
  2. Dim Ay()
  3. With Worksheets("¸ê®Æ¨Ó·½")
  4.     Set Rng = .Range("A3:B3")
  5.     fs = False
  6.     If .Range("B3").Value = "" Then
  7.     MsgBox "µLªk¨ú±oªÑ²¼¦WºÙ,½Ð½T©wªÑ²¼¦WºÙ¤w¶ñ¤JB3Àx¦s®æ", 32, "¸ê®Æ¿ù»~!"
  8.     Exit Sub
  9.     End If
  10.     For Each sh In Sheets
  11.        If sh.Name = .[B3].Text Then fs = True: Exit For
  12.     Next
  13.     If fs = False Then Sheets.Add.Name = .[B3].Text
  14.     ar = Array("A", "C", "I", "P")
  15.     ReDim Preserve Ay(s)
  16.     Ay(s) = Array(.Cells(4, ar(0)).Value, .Cells(4, ar(1)).Value, .Cells(4, ar(2)).Value, .Cells(4, ar(3)).Value)
  17.     s = s + 1
  18.     For i = 5 To .Cells(.Rows.Count, 1).End(xlUp).Row
  19.        If Weekday(.Cells(i, ar(0)), vbMonday) < 5 Then
  20.           ReDim Preserve Ay(s)
  21.           Ay(s) = Array(.Cells(i, ar(0)).Text, .Cells(i, ar(1)).Value, .Cells(i, ar(2)).Value, .Cells(i, ar(3)).Value)
  22.           s = s + 1
  23.           Else
  24.           ReDim Preserve Ay(s)
  25.           Ay(s) = Array(.Cells(i, ar(0)).Text, .Cells(i, ar(1)).Value, .Cells(i, ar(2)).Value, .Cells(i, ar(3)).Value)
  26.           s = s + 1
  27.           ReDim Preserve Ay(s)
  28.           Ay(s) = Array("", "", "", "")
  29.           s = s + 1
  30.         End If
  31.     Next
  32.     With Sheets(Sheets("¸ê®Æ¨Ó·½").[B3].Text)
  33.     Rng.Copy .[A1]
  34.     With .Range(.[A3], .Cells(.Rows.Count, 6))
  35.        .ClearContents
  36.        .Columns(1).NumberFormat = "yyyy/mm/dd"
  37.     End With
  38.     .[A2].Resize(s, 4) = Application.Transpose(Application.Transpose(Ay))
  39.     .Columns("A").AutoFit
  40.     End With
  41.     End With
  42. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 3# jesscc
  1. Sub SourceData_S()
  2. Dim Ay()
  3. With Worksheets("¸ê®Æ¨Ó·½")
  4.     Set Rng = .Range("A3:B3")
  5.     fs = False
  6.     If .Range("B3").Value = "" Then
  7.     MsgBox "µLªk¨ú±oªÑ²¼¦WºÙ,½Ð½T©wªÑ²¼¦WºÙ¤w¶ñ¤JB3Àx¦s®æ", 32, "¸ê®Æ¿ù»~!"
  8.     Exit Sub
  9.     End If
  10.     For Each sh In Sheets 'Àˬd¤u§@ªí¦WºÙ¬O§_¦s¦b
  11.        If sh.Name = .[B3].Text Then fs = True: Exit For
  12.     Next
  13.     If fs = False Then Sheets.Add.Name = .[B3].Text '¦pªG¤u§@ªí¤£¦s¦b´N·s¼W¤u§@ªí
  14.     ar = Array("A", "C", "I", "P") '»Ý­n´£¨úªºÄæ¦ì
  15.     ReDim Preserve Ay(s) '¡A±N¼ÐÃD¦C¦s¤J°}¦Cªº²Ä¤@µ§¨ÃÂX¤j°}¦C
  16.     Ay(s) = Array(.Cells(4, ar(0)).Value, .Cells(4, ar(1)).Value, .Cells(4, ar(2)).Value, .Cells(4, ar(3)).Value)
  17.     s = s + 1
  18.     For i = 5 To .Cells(.Rows.Count, 1).End(xlUp).Row '¶i¤J¸ê®Æ°j°é
  19.        If Weekday(.Cells(i, ar(0)), vbMonday) < 5 Then '§PÂ_¤é´Á¬°¬P´Á´X¡A¬P´Á5¥H«e°õ¦æ
  20.           ReDim Preserve Ay(s) '±N¸ê®Æ¦s¤J°}¦C
  21.           Ay(s) = Array(.Cells(i, ar(0)).Text, .Cells(i, ar(1)).Value, .Cells(i, ar(2)).Value, .Cells(i, ar(3)).Value)
  22.           s = s + 1
  23.           Else '¬P´Á¤­°õ¦æ
  24.           ReDim Preserve Ay(s) '±N¸ê®Æ¦s¤J°}¦C
  25.           Ay(s) = Array(.Cells(i, ar(0)).Text, .Cells(i, ar(1)).Value, .Cells(i, ar(2)).Value, .Cells(i, ar(3)).Value)
  26.           s = s + 1
  27.           ReDim Preserve Ay(s) 'Àx¦s¤@­ÓªÅ¥Õ¦C¨ì°}¦C
  28.           Ay(s) = Array("", "", "", "")
  29.           s = s + 1
  30.         End If
  31.     Next
  32.     With Sheets(Sheets("¸ê®Æ¨Ó·½").[B3].Text)
  33.     Rng.Copy .[A1] 'ªÑ²¼¦WºÙ
  34.     With .Range(.[A3], .Cells(.Rows.Count, 6))
  35.        .ClearContents '²M°£­ì¨Ó¸ê®Æ
  36.        .Columns(1).NumberFormat = "yyyy/mm/dd" '³]©wAÄ欰¤é´Á®æ¦¡
  37.     End With
  38.     .[A2].Resize(s, 4) = Application.Transpose(Application.Transpose(Ay)) '±N°}¦C­È¼g¤J¤u§@ªí
  39.     .Columns("A").AutoFit 'AÄæ¦Û°ÊÄæ¼e
  40.     End With
  41.     End With
  42. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 6# jesscc
  1. Sub SourceData_S()
  2. Dim Ay()
  3. With Worksheets("¸ê®Æ¨Ó·½")
  4.     Set Rng = .Range("A3:B3")
  5.     fs = False
  6.     If .Range("B3").Value = "" Then
  7.     MsgBox "µLªk¨ú±oªÑ²¼¦WºÙ,½Ð½T©wªÑ²¼¦WºÙ¤w¶ñ¤JB3Àx¦s®æ", 32, "¸ê®Æ¿ù»~!"
  8.     Exit Sub
  9.     End If
  10.     For Each sh In Sheets 'Àˬd¤u§@ªí¦WºÙ¬O§_¦s¦b
  11.        If sh.Name = .[B3].Text Then fs = True: Exit For
  12.     Next
  13.     If fs = False Then Sheets.Add.Name = .[B3].Text '¦pªG¤u§@ªí¤£¦s¦b´N·s¼W¤u§@ªí
  14.     ar = Array("A", "C", "I", "P") '»Ý­n´£¨úªºÄæ¦ì
  15.     If fs = False Then '¦pªG¬O·s¼W¤u§@ªí¡A´N¦s¤J¼ÐÃD
  16.     ReDim Preserve Ay(s) '±N¼ÐÃD¦C¦s¤J°}¦Cªº²Ä¤@µ§¨ÃÂX¤j°}¦C
  17.     Ay(s) = Array(.Cells(4, ar(0)).Value, .Cells(4, ar(1)).Value, .Cells(4, ar(2)).Value, .Cells(4, ar(3)).Value, "¦¨¥æ¶q¥eªÑ¥»¤ñ¨Ò")
  18.     s = s + 1
  19.     End If
  20.     For i = 5 To .Cells(.Rows.Count, 1).End(xlUp).Row '¶i¤J¸ê®Æ°j°é
  21.        If Weekday(.Cells(i, ar(0)), vbMonday) < 5 Then '§PÂ_¤é´Á¬°¬P´Á´X¡A¬P´Á5¥H«e°õ¦æ
  22.           ReDim Preserve Ay(s) '±N¸ê®Æ¦s¤J°}¦C
  23.           Ay(s) = Array(.Cells(i, ar(0)).Text, .Cells(i, ar(1)).Value, .Cells(i, ar(2)).Value, .Cells(i, ar(3)).Value, "=RC[-2]*RC[-1]/R1C4")
  24.           s = s + 1
  25.           Else '¬P´Á¤­°õ¦æ
  26.           ReDim Preserve Ay(s) '±N¸ê®Æ¦s¤J°}¦C
  27.           Ay(s) = Array(.Cells(i, ar(0)).Text, .Cells(i, ar(1)).Value, .Cells(i, ar(2)).Value, .Cells(i, ar(3)).Value, "=RC[-2]*RC[-1]/R1C4")
  28.           s = s + 1
  29.           ReDim Preserve Ay(s) 'Àx¦s¤@­ÓªÅ¥Õ¦C¨ì°}¦C
  30.           Ay(s) = Array("", "", "", "", "")
  31.           s = s + 1
  32.         End If
  33.     Next
  34.     With Sheets(Sheets("¸ê®Æ¨Ó·½").[B3].Text)
  35.     Rng.Copy .[a1] 'ªÑ²¼¦WºÙ
  36.     .[C1] = "ªÑ¥»(±i)": .[D1].FormulaLocal = "=YES|DQ!'" & .[a1] & ".Capital'*1000"
  37.     With .Range(.[A3], .Cells(.Rows.Count, 6))
  38.        '.ClearContents '²M°£­ì¨Ó¸ê®Æ
  39.        .Columns(1).NumberFormat = "yyyy/mm/dd" '³]©wAÄ欰¤é´Á®æ¦¡
  40.     End With
  41.     .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(s, 5) = Application.Transpose(Application.Transpose(Ay)) '±N°}¦C­È¼g¤J¤u§@ªí
  42.     .Columns("A:E").AutoFit 'A:EÄæ¦Û°ÊÄæ¼e
  43.     End With
  44.     End With
  45. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 9# jesscc

    Rng,sh,fs³o¨Ç¤£¥s«O¯d¦r¡A³o¨ÇºÙ¬°ÅܼÆ
¥Ñ¦Û¤vÀ°¬Y­ÓÀH®ÉÅܰʪº­È¡A©Ò¨ú¦W¦r¡A´N¹³°ê¤¤¼Æ¾Çªº¥N¼Æ¬O¦P¼Ëªº·N¸q
¦Ü©óÀx¦s®æªº¼gªk¦³«Ü¦h
¼Ð·Ç¼gªkCells(row,column)
¦b¬A¸¹¤º¿é¤J¦C¸¹»PÄ渹
³o¬O«ü©w³æ¤@Àx¦s®æªº¼Ð·Ç¼gªk
­n«ü©w½d³ò®ÉRange(address)
¦b¬A¸¹¤º¿é¤J½d³òªº¦ì§}¦r¦ê
³o¬O«ü©w½d³òªº¼Ð·Ç¼gªk
¥t¤@ºØ¥H¤¤¬A¸¹ªí¥Üªº¤èªk[name]
¦¹ªk¬O¤@ºØª«¥ó¥]¸Ë¼gªk¡A¬A¸¹¤º¿é¤Jªº¬O¥Nªí½d³òªº¦WºÙ
¦p[A1]¡AA1¦b¤u§@ªí¤¤©Ò¾Ö¦³ªº·N¸q¬O«ü¡A²Ä¤@¦C²Ä¤@ÄæÀx¦s®æªº¦W¦r
¦Ü©ó²Ä41¦æ.Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(s,5)
³o¬O¼Ð·ÇªºCELLS¼gªk¡A§A¥²¶·©î¶}¨Ó¸ÑÄÀ´N¯à¤F¸Ñ
.Cells(.Rows.Count, 1)¬A¸¹¤¤²Ä¤@­Ó¤Þ¼Æ¬O¦C¸¹¡A³oùبϥÎ.Rows.Count
¬O¦]¬°²{¦bEXCELªºª©¥»¤£¦P¡A¤u§@ªíªºÁ`¦C¼Æ·|¤£¦P
§A¬O2003ª©¥»©Ò¥H³o¸Ì§ï¦¨65536¤]¬O¤@¼Ëªº
³o¬O­n±o¨ìAÄæ³Ì©³¤U¤@¦CªºÀx¦s®æ
End(xlUp)¬O¦V¤W¨ì¸ê®Æªº³Ì©³³¡
Offset(1, 0)¬O¦V¤U¤@®æªº¦ì¸m
Resize(s,5)¬O°ò·ÇÀx¦s®æ¦ì¸m¦V¤Us¦C¦V¥k5ÄæÂX®iªº½d³ò
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 11# jesscc

¨S¿ù
Set Rng = .Range("A3:B3")
¥i¥H¼g¦¨
Set Rng = .[A3:B3]

S´N¬O°}¦C¨ì³Ì«á·|¦³ªº¤¸¯À¼Æ¶q
¦]¬°¸Ó°}¦C¬O¤Gºû°}¦C
¨C­Ó¤¸¯À¬O¥Ñ¤@ºû°}¦C©Ò²Õ¦¨
¦]¬°§Aªº¸ê®Æ¦b¬P´Á¤­«á­±­n¼W¥[¤@­ÓªÅ¥Õ¦C
©Ò¥HS·|¬O©Ò¦³¸ê®Æ¥[¤W´X­Ó¬P´Á¤­ªº¼Æ¶q
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : Ãø¦æ¯à¦æ¡AÃø±Ë¯à±Ë¡AÃø¬°¯à¬°¡A¤~¯àª@µØ¦Û§Úªº¤H®æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD