|
Range object(変数 Rng) をFunctionに引渡す場合以下のようにしましたが
引渡されていません。原因がわかりません
宜しくお願いします
Sub Comb入力()
Dim LastRow As Long
Dim Retu As Integer
Dim Rng As Range
Set sht = Workbooks("Bookname.xls").Worksheets("Sheet1")
Set Rng = Range("E4", Range("E65536").End(xlUp))
sht.Activate
Retu = 5
LastRow = Cells(65536, Retu).End(xlUp).Row
sht.Cells(LastRow + 1, Retu) ="2020
Comb sht, Rng, Retu
End Sub
Function Comb(sht As Worksheet, Rng As Range, Retu As Integer)
Dim jyufuku As Integer
Dim i As Integer
For i = Cells(65536, Retu).End(xlUp).Row To 4 Step -1
jyufuku = WorksheetFunction.CountIf(Rng, Cells(i, Retu).Value)
If jyufuku > 1 Then
sht.Cells(i, Retu).Select
Selection.Delete Shift:=xlUp
End If
Next i
End Function
Functionで
jyufuku = WorksheetFunction.CountIf(Rng, Cells(i, Retu).Value)
を以下のようにしますと上手く処理できます
jyufuku = WorksheetFunction.CountIf(Range("E4", Range("E65536").End(xlUp)), Cells(i, Retu).Value)
|
|