Dim Ws As Worksheet
Dim Ds As Worksheet
Dim Gyo2 As Long
Dim Mydata As Variant
Dim Mydata1 As Variant
Dim Mydata2 As Variant
Dim Mydata3 As Variant
Dim MyArray() As Variant
Dim MyRow() As Long
Dim Item As Long
Dim Idx As Long
Set Ws = Wb.Sheets("A")
'集計表は1単位4行構成で作成した表でデータファイルも特殊な構成だが
'ファイルを立ち上げることなく高速で処理をしたいが目的
'この作業では約700ファイルのデータを処理している
Dim AA As Long
Gyo2 = Ws.Cells(Rows.Count, 3).End(xlUp).Row
Item = (Gyo2 - 4) / 4
ReDim MyArray(Item)
ReDim MyRow(Item)
Idx = 0
For AA = 5 To Gyo2 Step 4
Idx = Idx + 1
Mydata1 = Ws.Cells(AA, 3).Value
Mydata2 = Ws.Cells(AA, 5).Value
Mydata3 = Ws.Cells(AA, 6).Value
Mydata = Mydata1 & "-" & Val(Mydata2) & "-" & Val(Mydata3) 'セルを配列に格納
MyRow(Idx) = AA
MyArray(Idx) = Mydata
Next AA
Set Ds = Wb.Sheets("Data")
FNAME = DRC & GNAME
DNAME = Dir(FNAME & "\*.xlsx")
Shname = "収容表"
Do While DNAME <> ""
'集計表に格納用シート(Data)を設けブック間の計算式を作成
Ds.Range("A1:BN90").FormulaR1C1 = "='" & FNAME & "\[" & DNAME & "]" & Shname & "'!RC"
Ds.Range("A1:BN90").Value = Ds.Range("A1:BN90").Value
Application.Calculation = xlCalculationManual
YourArray = Ds.Cells(2, 2) & "-" & Val(Ds.Cells(5, 5)) & "-" & Val(Ds.Cells(6, 8))
For EE = 1 To Idx
If MyArray(EE) = YourArray Then
SyukeiRow = MyRow(EE)
For BB = 15 To 75 Step 20
JB = (BB - 15) / 20 '集計表の入力行を決定
'本来空白でないが空白かの処理
If Ds.Cells(BB, 2) <> "0" Then
For CC = 4 To 66
Set Rng = Ds.Range(Ds.Cells(BB, CC), Ds.Cells(BB + 15, CC))
'計算式では空白部分が「0」となるが有効な0表示が消去されないように
'処理が必要なところのみを消去する
Rng.Replace What:="0", Replacement:=""
'今回は対象区間でひとつでも空白でないセルがあるかないか
n = WorksheetFunction.CountA(Rng)
If n > 0 Then
Ws.Cells(SyukeiRow + JB, CC + 9) = "●"
End If
Next CC
Else
Ws.Cells(SyukeiRow + JB, 11).Interior.Color = 12632256
Ws.Cells(SyukeiRow + JB, 12) = ""
End If
Next BB
End If
Next EE
Application.Calculation = xlCalculationAutomatic
Ds.Cells.ClearContents
'****************************************************************************
'ビル単位の情報を該当する装置を作成した配列と比較しデータを入力
'****************************************************************************
DNAME = Dir()
Loop