标题:excel的宏问题
只看楼主
lcx251147411
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-4-25
结帖率:100%
 问题点数:0 回复次数:0 
excel的宏问题
Inventory Template_For JW.zip (156.12 KB)

KANBAN为产品型号   QTY为个数  求汇总后  几个相同的产品型号 叠加为一个   后面的个数相加
代码如下
Private Sub mySumTotal()
Dim m, n, r As Integer
    Sheets("Total").Select
    Range("A2").Select
    Selection.CurrentRegion.Select
    Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1, Selection.Columns.Count).Select
    Selection.Clear
    Sheets("Index").Select
    Range("A2").Select
    MySheetNumber = Application.WorksheetFunction.CountA(Range("B:B")) - 1
    m = 1: r = 2
Do Until m > MySheetNumber
    MySheet = Sheets("Index").Range("B" & CStr(1 + m))
    Sheets(MySheet).Activate
    Range("A2").Select
    n = Application.WorksheetFunction.CountA(Range("B:B"))
    If n = 1 Then GoTo Halt:
    Range("A2:D" & CStr(n)).Copy 'Union(Range("A2:D" & CStr(n)), Range("I2:I" & CStr(n))).Copy
    Sheets("Total").Select
    Range("A" & CStr(r)).Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
    Application.CutCopyMode = False
Halt:    m = m + 1
    If n = 1 Then
    r = r
    Else
    r = r + n - 1
    End If
Loop
    Sheets("Total").Select
    Range("A2").Select


End Sub
搜索更多相关主题的帖子: 产品 型号 excel 
2013-04-27 11:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-405659-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015171 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved