Public Sub extract()
Dim i As Long
Dim tmp As Variant
Dim Last_Row1 As Long
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim myRange As Range
'抽出処理...〆(・ω・ )メモメモ
Set sh1 = ThisWorkbook.Sheets("test")
Set sh2 = ThisWorkbook.Sheets("出力結果")
sh1.UsedRange.Copy Destination:=sh2.Range("A5")
With sh2
Last_Row1 = .Cells(Rows.Count, "A").End(xlUp).Row
For i = Last_Row1 To 7 Step -1
If WorksheetFunction.CountIf(.Range("A" & i & ":F" & i), "Null") = 0 _
And WorksheetFunction.CountIf(.Range("A" & i & ":F" & i), "") = 0 _
And WorksheetFunction.CountIf(.Range("A" & i), "日付") = 0 Then
.Rows(i).Delete
End If
Next i
End With
'---------------------------
With sh2
Last_Row1 = .Cells(Rows.Count, "A").End(xlUp).Row
For i = 5 To Last_Row1
If .Cells(i, "A").Value = "千葉県" _
Or .Cells(i, "A").Value = "茨城県" Then
.Range("A" & i).CurrentRegion.Borders.LineStyle = xlContinuous
.Range("A" & i & ":F" & i).Borders.LineStyle = xlLineStyleNone
End If
Next i
.Columns("A:H").Replace "Null", ""
.Columns("A:F").AutoFit
End With
End Sub
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00