[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『VBAでの非連続のセルの選択について』(chamofu)
マクロ素人です。
お力をお借りしたいです。
セルの選択がうまくできず困っております。
5行目まではタイトルなどでデータは6行目からです。A〜GとAB列をH列の最終行のところまでセルを選択したいです。
下記で組んでみたのですが、A〜AB列まですべて選択されてしまいます。
また、セル選択後に空白セルは上のセルと同じにするコードと組み合わせたいです。
行数が6万行を超えることも多いため、少しでも処理の軽いのにできたら幸いです。
Sum LastRow as LongSub テスト()
Dim blanks As Range
Dim LastRow As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
LastRow = Cells(Rows.Count, 8).End(xlUp).Row
Range(“A6:G” & LastRow, “AB6:AB” & LastRow).Select
If Selection.Cells.Count >1 Then On Error Resume Next For Each blanks In Selection.SpecialCells(xlCellTypeBlanks).Areas If blanks.Row >1 Then blanks.Rows(1).Offset(-1, 0).Copy blanks End If Next On Error GoTo 0 End If
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
どうぞよろしくお願いします。
< 使用 Excel:Excel2010、使用 OS:Windows7 >
(γ) 2018/06/09(土) 11:46
Sub test()
Dim Rng As Range Dim a As Range
On Error Resume Next Set Rng = Intersect(Range("A:G,AB:AB"), _ Range("H6", Cells(Rows.Count, "H").End(xlUp).EntireRow)) _ .SpecialCells(xlCellTypeBlanks) On Error GoTo 0 If Rng Is Nothing Then Exit Sub
For Each a In Rng.Areas a.Rows(0).Copy a Next End Sub (まっつわん) 2018/06/09(土) 12:04
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.