0

I have created an array holding Cells() locations as parameters.

When I run the code below it doesn't grab those parameter as I'd hope. Is there something I'm doing wrong or will what I'm trying to do not work this way? The other arrays you see are working accordingly so please ignore those.

Dim varDept As Variant
Dim varSheet As Variant
Dim varCell As Variant 
Set DRag = Range("D2:D200")


varCell = Array(Cells(9, 1), Cells(15, 1), Cells(21, 1))

For Each Custom In DRag
    If PDrag = Empty And Custom = varDept(0) And Custom.Offset(0, -1) = "551098218" Then
        PDrag = Custom.Address(0, 0) & "," & Custom.Offset(0, -3).Address(0, 0)
    ElseIf Custom = varDept(0) And Custom.Offset(0, -1) = "551098218" Then
        PDrag = PDrag & "," & Custom.Address(0, 0) & "," & Custom.Offset(0, -3).Address(0, 0)
    End If
Next Custom

If PDrag = Empty Then Exit Sub

PDrag = Replace(PDrag, "D", "E")
Range(PDrag).Select
Selection.Copy
Worksheets(varSheet(0)).Activate
varCell(0).Select
Selection.PasteSpecial xlPasteAll

0 Answers0