+ Reply to Thread
Results 1 to 4 of 4

Writing elements of array to a range

Hybrid View

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Writing elements of array to a range

    Hello everyone
    I have this code and need to get the results in a range starting in H3
    Sub CheckForDuplicates()
        With ThisWorkbook.Worksheets("sheet1")
            
            Dim dict As Object
            Set dict = CreateObject("Scripting.Dictionary")
                    
            Dim iRow As Long
            For iRow = 1 To 100
                If Not dict.exists(.Cells(iRow, 1).Value) Then
                    dict.Add .Cells(iRow, 1).Value, 1
                End If
            Next iRow
                    
            Dim element As Variant
            For Each element In dict.keys
                Debug.Print element
            Next
                    
            Set dict = Nothing
        End With
    End Sub
    i appreciate your help
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Writing elements of array to a range

    maybe so
    For iRow = 3 To 100
          If Not dict.exists(.Cells(iRow, "H").Value) Then
              dict.Add .Cells(iRow, "H").Value, 1
          End If
    Next iRow

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Writing elements of array to a range

    get the results in a range starting in H3
    [h3].resize(dict.count).value=application.transpose(dict.keys)

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Writing elements of array to a range

    Mr. nilem
    Thanks for offering help but it doesn't work with this change

    Mr. Jindon
    Great and simple and very effective .. Thanks for help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. writing a range to an array then writing the array to a new range
    By prjames3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2014, 08:57 PM
  2. Please help with input form, arrays and a function
    By jbaich in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2014, 01:50 PM
  3. [SOLVED] Removing specific elements from an Array based on matching elements in a different Array
    By jamesdeuce in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2014, 10:35 PM
  4. Writing Multi-Dimensional Array To Range
    By Dan_Dollar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-04-2007, 04:11 PM
  5. Writing a range to an array...
    By Alex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2005, 10:10 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1