- 帖子
- 46
- 主題
- 12
- 精華
- 0
- 積分
- 72
- 點名
- 0
- 作業系統
- win7
- 軟體版本
- 2007-EXCEL
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2011-12-29
- 最後登錄
- 2020-3-20
|
請問各位大大,以下這些代碼是否能簡化呢!? 一直找不到感覺用不同的方法寫,讓我感覺有點挫折阿 ><,先謝過大大們....:)- Private Sub CommandButton2_Click()
- Range("S1").Select
- ActiveCell.FormulaR1C1 = "編號"
- Range("S2").Select
- ActiveCell.FormulaR1C1 = "=IF(R[1]C[-17]=R[0]C[-17],1,0)"
- Selection.AutoFill Destination:=Range("S2:S600"), Type:=xlFillDefault
- Range("S2:S600").Select
- Range("T1").Select
- ActiveCell.FormulaR1C1 = "製程"
- Range("T2").Select
- ActiveCell.FormulaR1C1 = "=IF(R[1]C[-16]=R[0]C[-16],1,0)"
- Selection.AutoFill Destination:=Range("T2:T600"), Type:=xlFillDefault
- Range("T2:T600").Select
- Range("U1").Select
- ActiveCell.FormulaR1C1 = "物料名稱"
- Range("U2").Select
- ActiveCell.FormulaR1C1 = "=IF(R[1]C[-9]=R[0]C[-9],1,0)"
- Selection.AutoFill Destination:=Range("U2:U600"), Type:=xlFillDefault
- Range("U2:U600").Select
- Range("V1").Select
- ActiveCell.FormulaR1C1 = "代碼"
- Range("V2").Select
- ActiveCell.FormulaR1C1 = "=IF(R[1]C[-13]=R[0]C[-13],1,0)"
- Selection.AutoFill Destination:=Range("V2:V600"), Type:=xlFillDefault
- Range("V2:V600").Select
- Range("W1").Select
- ActiveCell.FormulaR1C1 = "總加"
- Range("W2").Select
- ActiveCell.FormulaR1C1 = "=SUM(RC[-4]:RC[-1])"
- Selection.AutoFill Destination:=Range("W2:W600"), Type:=xlFillDefault
- Range("W1").Select
- Selection.AutoFilter
- ActiveSheet.Range("$S$1:$W$600").AutoFilter Field:=5, Criteria1:="4"
- Columns("E:H").Select
- Selection.EntireColumn.Hidden = True
- End Sub
複製代碼 |
|