|
本来なら、質問内容を変えたら再回答はしないのですが、いちおう今回に限り
組み直したサンプルコードを提示しておきます。
Sub Get_Def_Value2()
Dim LRa As Long, LRb As Long
LRa = Sheets("Sheet1").Range("A65536").End(xlUp).Row
LRb = Sheets("Sheet2").Range("A65536").End(xlUp).Row
Application.ScreenUpdating = False
With Sheets("Sheet3")
.Range("A1:A" & LRb).Formula = _
"=CONCATENATE(Sheet2!A1,"","",Sheet2!B1,"",""," & _
"Sheet2!C1,"","",Sheet2!D1)"
.Range("E1:E" & LRb).Formula = "=Sheet2!E1"
.Range("F1:F" & LRa).Formula = _
"=CONCATENATE(Sheet1!A1,"","",Sheet1!B1,"",""," & _
"Sheet1!C1,"","",Sheet1!D1)"
With .Range("A:F")
.Copy
.PasteSpecial xlPasteValues
End With
With .Range("H1:H" & LRb)
.Formula = "=MATCH($A1,$F$1:$F$" & LRa & ",0)"
If WorksheetFunction.Count(.Cells) = LRb Then
MsgBox "存在しないデータは見つかりませんでした", 64
.Parent.Cells.ClearContents: GoTo ELine
End If
.SpecialCells(3, 1).EntireRow.ClearContents
End With
.Range("F:H").ClearContents
With .Range("A:E")
.Columns(1).TextToColumns DataType:=xlDelimited, _
Comma:=True
.Sort Key1:=.Columns(1), Order1:=xlAscending, _
Header:=xlNo, Orientation:=xlSortColumns
End With
End With
ELine:
With Application
.Goto Sheets("Sheet3").Range("A1"), True
.CutCopyMode = False
.ScreenUpdating = True
End With
End Sub
|
|