- ©«¤l
- 354
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 387
- ÂI¦W
- 0
- §@·~¨t²Î
- windows7
- ³nÅ骩¥»
- vba,vb,excel2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-1-8
- ³Ì«áµn¿ý
- 2024-8-2
 
|
¦^´_ 1# dou10801
Sub test()
Set s = Sheets("¤u§@ªí1"): Set s2 = Sheets("¤u§@ªí2"): s2.Cells.ClearContents
c = UBound(s.[b2].CurrentRegion.Value2, 2) / 5
ReDim ar(1 To c): s2.[H1:L1] = s.[b2:F2].Value
For i = 1 To c
s2.Cells(10 * i - 8, 8).Resize(10, 5) = s.Cells(3, 5 * i - 3).Resize(10, 5).Value
Next 'y=10x-8 <--¤G¤¸¤@¦¸Áp¥ß¤èµ{y=ax+b¥N¤J¨D-> y=5x-3
Set cn = CreateObject("adodb.connection"): V = Application.Version
If V >= 12 Then V = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0; "
If V < 12 Then V = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0; "
cn.Open V & "Data Source=" & ThisWorkbook.FullName
q = "select ¶µ¦¸,[«~ ¦W],®e¶qkg,°â»ù,¥X³f¼Æ¶q,°â»ù*¥X³f¼Æ¶q as ª÷ÃB from[¤u§@ªí2$H1:L] where ¥X³f¼Æ¶q is not null"
Set rs = cn.Execute(q): s2.[A1:E1] = s.[b2:F2].Value: s2.[F1] = "ª÷ÃB": s2.[A2].CopyFromRecordset rs
q = "select sum(¥X³f¼Æ¶q) as ¥X³f¼Æ¶q ,sum(ª÷ÃB) as ª÷ÃB from[¤u§@ªí2$E1:F]"
Set rs = cn.Execute(q): r = s2.Cells(Rows.Count, "F").End(3).Row + 1
s2.Cells(r, "D") = "¦Xp": s2.Cells(r, "E").CopyFromRecordset rs
End Sub |
|