[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『ループの書き方について』(みっく)
お世話様です
お手数ですお掛けいたしますが
宜しくお願いいたします
下記の様に 注文書と言う名前のシートを下記の様に処理していますが
処理方法をループ処理の書き方に変える場合について
教えていただけないでしょうか
注文書のシートが増えそうなので 増えた場合にも備えたいと考えています
Sub B()
n = Cells(Rows.Count, "B").End(xlUp).Row Sheets("北海道 注文書").Select Range("C6").Copy Range("A13") Range("A13").Select Selection.AutoFill Destination:=Range("A13:A" & n), Type:=xlFillDefault Rows("1:11").Delete Shift:=xlUp Sheets("秋田 注文書").Select Range("C6").Copy Range("A13") Range("A13").Select Selection.AutoFill Destination:=Range("A13:A" & n), Type:=xlFillDefault Rows("1:11").Delete Shift:=xlUp Sheets("東京 注文書").Select Range("C6").Copy Range("A13") Range("A13").Select Selection.AutoFill Destination:=Range("A13:A" & n), Type:=xlFillDefault Rows("1:11").Delete Shift:=xlUp Sheets("大阪 注文書").Select Range("C6").Copy Range("A13") Range("A13").Select Selection.AutoFill Destination:=Range("A13:A" & n), Type:=xlFillDefault Rows("1:11").Delete Shift:=xlUp Sheets("福岡 注文書").Select Range("C6").Copy Range("A13") n = Cells(Rows.Count, "B").End(xlUp).Row Range("A13").Select Selection.AutoFill Destination:=Range("A13:A" & n), Type:=xlFillDefault Rows("1:11").Delete Shift:=xlUp Sheets("伊丹 経費明細表").Select Range("C6").Copy Range("A13") Range("A13").Select Selection.AutoFill Destination:=Range("A13:A" & n), Type:=xlFillDefault Rows("1:11").Delete Shift:=xlUp End Sub
< 使用 Excel:Excel2010、使用 OS:Windows7 >
Sub B() Dim i As Long Dim n As Long
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = 1 To Sheets.Count With Sheets(i) If .Name Like "*注文書" Or .Name Like "*経費明細表" Then .Range("C6").Copy .Range("A13") .Range("A13").AutoFill Destination:=.Range("A13:A" & n), Type:=xlFillDefault .Rows("1:11").Delete Shift:=xlUp End If End With Next i End Sub (???) 2016/05/23(月) 11:47
有難う御座います
(みっく) 2016/05/23(月) 14:05
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.