Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    why error 1004 in copy range??? (2000)

    In effect i want to recopy in Q filtered data cells from C...
    and after fill combo1...

    Option Explicit
    Sub COMBO1()
    Dim wbBook As Workbook
    Dim wsSheet As Worksheet
    Dim rnData As Range
    Dim vaData As Variant
    Dim i As Long

    Set wsSheet = Sheets("t0018")


    With wsSheet
    Set rnData = .Range(.Range("C3"), .Range("C13224").End(xlUp))
    rnData.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Range( _
    "Q3"), Unique:=True
    With UserForm1.ComboBox1
    .Clear
    .List = vaData
    .ListIndex = -1
    End With
    .Range(.Range("Q3"), .Range("Q13224").End(xlUp)).ClearContents
    End With

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: why error 1004 in copy range??? (2000)

    You don't set vaData anywhere in the code.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: why error 1004 in copy range??? (2000)

    Peraph solved with a code...
    i want to fill the combobox PROVA1 without dupes and ordered item, from all cells in column C but only if in column B is present the value "PIEMONTE"...(for this condition use the value in textbox.)
    Attached my example to fill combobox but no idea to use the second condition...
    Hope you undertstand me?

    substituite original code with:
    Private Sub UserForm_Initialize()
    Dim ULTIMA As Long
    Dim DIC As Object, X, R As Range

    ULTIMA = Sheets("TI001F").Cells(Rows.Count, 2).End(xlUp).Row
    Set DIC = CreateObject("scripting.dictionary")
    DIC.CompareMode = vbTextCompare
    With Sheets("TI001F")
    For Each R In .Range("C3", .Range("C" & ULTIMA))
    If Not IsEmptyŽ Then
    If Not DIC.Exists(R.Value) Then
    DIC.Add R.Value, Nothing
    End If
    End If
    Next
    End With
    X = DIC.Keys: Set DIC = Nothing
    Me.PROVA1.List = X
    Erase X

    End Sub

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: why error 1004 in copy range??? (2000)

    You can add another If ... Then line to check the value in column B - this is R.Offset(0, -1)

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: why error 1004 in copy range??? (2000)

    ok resolved with othe if condition...
    tks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •