¼ÐÃD:
[µo°Ý]
ª«¥ó¬Ù²¤ªº¥["."»P¤£¥[°ÝÃD
[¥´¦L¥»¶]
§@ªÌ:
thps51134
®É¶¡:
2011-12-7 09:22
¼ÐÃD:
ª«¥ó¬Ù²¤ªº¥["."»P¤£¥[°ÝÃD
¥»©«³Ì«á¥Ñ thps51134 ©ó 2011-12-7 09:26 ½s¿è
·Q½Ð±Ð§ÚªºÆ[©Àþ¸Ì·d¿ù¤F
¦bWith...End With ¤¤, ±NCells(), Range()µ¥«e±¥[¤W"
.
"®É
µo²{¥X²{"¿ù»~438...¤£¤ä´©¦¹ÄݩʩΤèªk"©Î"¿ù»~1004, class range select¥¢±Ñ"µ¥ªº¿ù»~°T®§
¬O Workbook.addªºÃö«Y¶Ü?
=====
¥Ø«e¥i¥H¥¿½T°õ¦æªºª©¥»¡G
With Workbooks.add
With Sheet1
Range("A1").select
End with
End with
½Æ»s¥N½X
¦ý¤§«e¾Ç¨ì¤F
With...End With
¨ä¤¤°µ°Ê§@®É
«e±ª«¥óÁö¥i¬Ù²¤, ¦ý»Ý¥[Ó"
.
"
©Ò¥H쥻¬O³o¼Ë¡G
With Workbooks.add
With .Sheet1
.Range("A1").select
End with
End with
½Æ»s¥N½X
¡®³o¼Ë¼gªº¡G
With Workbooks.add
With Sheet1
.Range("A1").select
End with
End with
½Æ»s¥N½X
¦ý´N·|¥X²{¿ù»~°T®§
½Ð«üÂI§Úþ¸Ì·d¿ù¤F¡AÁÂÁ¤j®a¡I
§@ªÌ:
Hsieh
®É¶¡:
2011-12-7 10:13
¦^´_
1#
thps51134
·í°õ¦æWorkbooks.add®É
§@¥Î¬¡¶Ã¯´N¬O¸Ó·s¼W¬¡¶Ã¯
©Ò¥HWith Workbooks.add°Ï¬q¤U
With .Sheets(1)·|«ü¦V¸Ó·s¼W¬¡¶Ã¯¤¤ªº²Ä¤@Ó¤u§@ªí
¦ý¬OY¤Ö¤F"."
With Sheets(1)«h¬O«ü¦Vµ{¦¡½X©Ò¦bªº¬¡¶Ã¯¤¤ªº²Ä¤@Ó¤u§@ªí
¨º»ò¦b°µselect°Ê§@®É¡A¦]¬°¨Ã«D©ó§@¥Î¤¤¬¡¶Ã¯¤¤°õ¦æ©Ò¥H·|¥X¿ù
§@ªÌ:
thps51134
®É¶¡:
2011-12-7 12:34
¥»©«³Ì«á¥Ñ thps51134 ©ó 2011-12-7 12:44 ½s¿è
¦^´_
2#
Hsieh
Dear Hsieh¤j, ¦Ñ¹ê»¡
¡@Åý§Ú¬Û·í§x´bªº¨ä¤¤¤@ÂI´N¦b©ó
¡@§ÚªºCode¬O¼g¦b¤U±©Ò¼gªº"Test.xls"ªºModule¤¤
¢åindows("Test.xls").Activate
Range(Cells(1, 1), Cells(4, 72)).Copy
With Workbooks.Add
With Sheets1
Cells(1, 1).Select '¤]§ï¬°' Cells(1,1).value= "OH" '¹L, ½T»{¹L°Ê§@¯uªº¬O·|§@¥Î¦b¦¹'
ActiveSheet.Paste
End With
End With
½Æ»s¥N½X
³o¼Ë¼g¤U¨Ó¡A³ºµM¥i¥H°õ¦æ¥X
Åý¦btest ¤¤Copyªº¸ê®Æ©ó
·s¶}ªºworkbook¤¤ªºSheet1
¤¤¶K¤W
(§Úªº¥Øªº´N¬OncopyÂÂÀɮפ¤ªº³¡¤À¸ê®Æ, paste©ó¶}ªºÀɮפ¤)
Hsieh¤jªº¦^ÂФ]Åý§ÚÅåı§Úªº¿ù»~°T®§°ÝÃD...
À³¸Ó»P»yªk¤£¼ô¤j¦³Ãö«Y= =a
¦]¬°±N
With Sheet1 §ï¬° With
.
Sheet
s(1)
«á
¥["."ªº´N¶¶§Q°õ¦æ¤F!
·PÁÂ!
§@ªÌ:
Hsieh
®É¶¡:
2011-12-7 13:42
¥»©«³Ì«á¥Ñ Hsieh ©ó 2011-12-8 08:34 ½s¿è
¦^´_
3#
thps51134
§A¸Õ¹L¥i¥Hª½±µµ¹È¬O¥i¥H°õ¦æªº
©Ò¥HÀ³¸Ó·|µo²{¬OSelect³y¦¨ªº¿ù»~
¸ÕµÛ¤£n¨Ï¥ÎSELECT¡A¤]¥iÁקKµL¿×ªº¿Ã¹õ§ó·s
With Workbooks.Add
Set A = .Sheets(1).Cells(1, 1) '«ü©w·s¬¡¶Ã¯ªº²Ä¤@Ó¤u§@ªíA1
With Workbooks("Test.xls").Sheets(1)
.Range(.Cells(1, 1), .Cells(4, 72)).Copy A '½Æ»sTEST.XLSªº²Ä¤@±i¤u§@ªí³¡¤À½d³ò¨ì·s¬¡¶Ã¯¤¤
End With
End With
§@ªÌ:
thps51134
®É¶¡:
2011-12-7 15:21
¥»©«³Ì«á¥Ñ thps51134 ©ó 2011-12-7 15:23 ½s¿è
[attach]8754[/attach]
¦^´_
4#
Hsieh
Sub NewMethod()
With Workbooks.Add
Set A = .Sheets(1).Cells(1, 1) '«ü©w·s¬¡¶Ã¯ªº²Ä¤@Ó¤u§@ªíA1
With Windows("test.xls").Sheets(1)
.Range(.Cells(1, 1), .Cells(4, 72)).Copy A '½Æ»sTEST.XLSªº²Ä¤@±i¤u§@ªí³¡¤À½d³ò¨ì·s¬¡¶Ã¯¤¤
End With
End With
End Sub
½Æ»s¥N½X
°»¿ù®Éhighlight»¡¦b²Ä4¦æµo²{°ÝÃD
ÁÙ¬O»¡, ·|¤£·|§Ú§ï¨ì¤F¤°»ò³]©w?
===
¨ä¹ê¥Î.select¬O¦]¬°
¨Ï¥Î¿ý»s¥¨¶°®É¶]¥XªºCode ¬°»Ýn¥Î¨ìActivateªº
§ï¨Ó§ï¥h´N¦¨¤F²{¦bªº¼Ë¤l
¯uªº«Ü·Q¬Ù±¼
Hsieh¤jµ¹¤F§Ú¤@ӫܴΪº¤è¦V~
§@ªÌ:
GBKEE
®É¶¡:
2011-12-7 16:23
¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-12-7 16:35 ½s¿è
¦^´_
5#
thps51134
µøµ¡
Windows¨S¦³Sheets(1)
¦³ActiveSheet
µøµ¡
With
Windows
("test.xls").Sheets(1) §ï¬° ->
¬¡¶Ã¯
With
WorkBooks
("test.xls").Sheets(1)
§@ªÌ:
thps51134
®É¶¡:
2011-12-14 15:16
¦^´_
6#
GBKEE
©êºp¥¼¤Î®É¦^ÂÐ
·PÁ¨â¦ì... (²Û·\±»±)
¡@³ºµM²´ªá·í¿ù»~
·QÄ~Äò¦V½Ñ¦ì½Ð±Ð
1. ¦b²Ä¥|¦æ¤¤ªº" .Range(.Cells(1, 1), .Cells(4, 72)).Copy A "ªº·N¸q¬°¦ó?
With Workbooks.Add
Set A = .Sheets(1).Cells(1, 1) '«ü©w·s¬¡¶Ã¯ªº²Ä¤@Ó¤u§@ªíA1
With Workbooks("Test.xls").Sheets(1)
.Range(.Cells(1, 1), .Cells(4, 72)).Copy A '½Æ»sTEST.XLSªº²Ä¤@±i¤u§@ªí³¡¤À½d³ò¨ì·s¬¡¶Ã¯¤¤
End With
End With
½Æ»s¥N½X
Y³]" .Range(.Cells(1, 1), .Cells(4, 72))" ¬°B
B.Copy A ¬O
"copy B to A"
¶Ü?
2. Y·Q¥t¥~¦b"Test.xls"§@³v¦æ§PÂ_
¥Oµ²ªG= trueªº¸Ó¦Ccopy to ·s¶}ªºWorkbook
¦Û¤v¸£³U¸Ìªº·§©À¹³³o¼Ë...
With Workbook("Test.xls").Sheets(1)
for i = 1 to RowEnd 'RowEnd¬°¾ãÓSheet(1)¤¤ªº³Ì«á¤@¦C'
If true then
Rows(i).copy
With èè·s¶}ªºworkbook
'±N©óWorkbook("Test.xls").Sheets(1)¤¤copyªºRow
'paste¦b New Workbookªº³Ì«á¤@¦C¤§«á
End With
End if
Next i
End With
½Æ»s¥N½X
ÁÙ¬O»¡«Øij±j¨î¥ý´À¨Ï¥ÎªÌ±N·sadd ªº workbook¦sÀÉ
¦A±N¥¦¥s¥X¨Ó?
·PÁÂ!
§@ªÌ:
GBKEE
®É¶¡:
2011-12-14 16:19
¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-12-14 16:48 ½s¿è
¦^´_
7#
thps51134
.Range(.Cells(1, 1), .Cells(4, 72)).Copy A
-> .Range(½d³ò)½Æ»s(¥þ³¡)¨ìÅܼƪ«¥óA
Y³]" .Range(.Cells(1, 1), .Cells(4, 72))" ¬°B
-> B.Copy A
ÁÙ¬O»¡«Øij±j¨î¥ý´À¨Ï¥ÎªÌ±N·sadd ªº workbook¦sÀÉ,¦A±N¥¦¥s¥X¨Ó?
À³¬O°µ§¹COPY ¦A¦sÀÉ
§@ªÌ:
thps51134
®É¶¡:
2011-12-14 17:16
¦^´_
8#
GBKEE
·Q¥ÎVBA°µªº¨Æ¡G
¡@¡@ 1. ±NTest.xlsªí®æÀÉÀY½Æ»s¨ì·s¶}ªºÀÉ®×
¡@¡@2. ¦^¨ìÂÂÀÉ®×(Test.xls), ¹ïRow data§@
³v¦C§PÂ_
¡@¡@¡@¡@²Å¦X=> Copy¸Órow¨ì
·s
Àɮ׳̫á¤@¦C«á
¡@¡@¡@¡@¤£²Å=> ¨ì¤U¤@¦C§PÂ_
³oÃ䤣ª¾¹D¸Ó¦p¦ó¦b¨âÓWorkbook¤¤¤Á´«¤~¦n
=====
¨ä¹ê«Ü·Qª¾¹D¦p¦ó°µ§¹©Ò¦³copy°Ê§@¦A¦sÀÉ
¡@¥i¬O¤£ª¾¹D¸Ó¦p¦ó¼gFor loop¤¤ªº
with "èè·s¼Wªºworkbook"¡@
¦pªGª½±µ with workbook.add©È¤@¦¸loop´N·s¶}¤@Óworkbook ...@@
ÁÂÁÂ!
§@ªÌ:
GBKEE
®É¶¡:
2011-12-15 17:51
¦^´_
9#
thps51134
Option Explicit
Sub Ex()
Dim NewSh As Worksheet
With Workbook("Test.xls").Sheets(1)
Set NewSh = Workbooks.Add.Sheets(1) 'Åܼƫü©w¬° ·s¼W¬¡¶Ã¯ªºSheets(1)
For i = 1 To RowEnd 'RowEnd¬°¾ãÓSheet(1)¤¤ªº³Ì«á¤@¦C'
If ±ø¥ó = True Then
If NewSh.Cells(1) = "" Then 'A1=""
Rows(i).Copy newbo.Rows(1) '·sÀɮ׳̫á¤@¦C«á
Else
Rows(i).Copy NewSh.Cells(Rows.Count, "A").End(xlUp).Offset(1) '·sÀɮ׳̫á¤@¦C
End If
End If
Next
NewSh.Parent.SaveAs "¸ê®Æ§¨\ÀɮצWºÙ" '·s¼Wªº¬¡¶Ã¯¦sÀÉ
End With
End Sub
½Æ»s¥N½X
§@ªÌ:
thps51134
®É¶¡:
2011-12-20 10:42
¥»©«³Ì«á¥Ñ thps51134 ©ó 2011-12-20 10:47 ½s¿è
¦^´_
10#
GBKEE
¡@·Q½Ð±Ð±zcode¤¤¨â¦Cªº·N¸q
1. ²Ä¤@¦C "Option Explicit"
2. ²Ä11¦C "NewSh.Cells(Rows.Count, "A").End(xlUp).Offset(1)"
¡@¡@°j°é°õ¦æ¨ì³o¸Ì®É¡A¦ü¥G³Ì«á¤@¦Cªº¸ê°TµLªk§ó·s¡H (¤]©È§Ú§ï¼g¿ù¤F)
¡@¡@¨C¦¸©ó·sÀɮ׶K¤W³£¬O¶K¦b¦P¤@¦CQ_Q
'¦Û¤v§ï¼gªº°j°é¤º; ²Ä¤E¦C°õ¦æ¦³°ÝÃD'
For i = 22 To RowEnd 'RowEnd¬°¾ãÓSheet(1)¤¤ªº³Ì«á¤@¦C'
If Cells(i, 3).Value = "BU5" Then
If NewSh.Cells(2, 1) = "" Then '¦]¬°Cells(1,1)³£¬°ªÅ, ©Ò¥H´«¤F§O®æ
Range(Cells(i, 1), Cells(i + 1, 2)).EntireRow.Copy NewSh.Rows(1)
'·sÀɮ׳̫á¤@¦C«á
'¦]¬°«e±¨S¬Ý¨ìnewbo©Ò¥H´«¦¨NewSh...¤£ª¾¹D¦³¨S¦³»~·|'
Else
Range(Cells(i, 1), Cells(i + 1, 3)).EntireRow.Copy NewSh.Cells(Rows.count, "A").End(xlUp).Offset(1) '·sÀɮ׳̫á¤@¦C
End If
End If
Next i
½Æ»s¥N½X
ÁÂÁÂ!
§@ªÌ:
GBKEE
®É¶¡:
2011-12-20 14:44
¦^´_
11#
thps51134
Option Explicit ³¯z¦¡ ¦b¼Ò²Õ¼h¦¸¤¤±j¢¨CÓ¦b¼Ò²ÕùتºÅܼƳ£¥²¶·©ú½Tªº«Å§i¡C
¦p¹Ï
[attach]8852[/attach]
°j°é°õ¦æ¨ì³o¸Ì®É¡A¦ü¥G³Ì«á¤@¦Cªº¸ê°TµLªk§ó·s¡H (¤]©È§Ú§ï¼g¿ù¤F)
µ{¦¡½X¬O¨S°ÝÃDªºn¬Ý¬ÝÀɮפº®e
Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)