+ Reply to Thread
Results 1 to 3 of 3

transfering a range to an array

  1. #1
    Registered User
    Join Date
    07-18-2022
    Location
    Manchester England
    MS-Off Ver
    MS365
    Posts
    91

    transfering a range to an array

    I have a range roughly 2000 rows and 7 columns. I was looking for duplicate values in two columns direct from the excel worksheet. This was very slow so I decided to transfer the two columns of data to an array ( LoadAr) and do the duplicate search on that recording the row no of the duplicates found on another array (DupsAr). The code for loading the Array is this:-
    [CODE]Sub Doubles2()

    Dim nextRow As Long
    Dim lastRow As Long
    Dim thisRow As Long
    Dim DupsAr As Variant
    Dim LoadAr As Variant
    Dim CellVal As Variant
    Application.ScreenUpdating = False
    With Sheets("Sheet1")
    nextRow = 0
    lastRow = WorksheetFunction.CountA(.Range("C:C"))
    ReDim DupsAr(lastRow, 0)
    ReDim LoadAr(lastRow, 1)
    For x = 0 To lastRow
    For y = 0 To 1

    1 LoadAr(x, 0) = .Range(Cells(x + 1, 2)).Value
    2 LoadAr(x, 1)= .Range(Cells(x+1,5).Value



    Next y
    Next x
    'code to find duplicates in LoadAr put the RowN0 in the array DupsAr then transfer it to col J
    For a = 1 To lastRow
    Sheets("Sheet1").Range(Cells(a, 10).Value) = DupsAr(a, 1)
    Next a
    End With
    Application.ScreenUpdating = True

    End Sub
    [/
    I get an
    Application defined or Object defined error at lines 1 & 2, and I cant see what is wrong with those lines. Can someone tell me please?
    Last edited by Osprey3; 12-02-2022 at 11:02 AM.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,085

    Re: transfering a range to an array

    Maybe you could use a dictionary object?

    Please Login or Register  to view this content.
    Last edited by ByteMarks; 12-02-2022 at 11:46 AM.

  3. #3
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,337

    Re: transfering a range to an array

    what is the 'y' loop doing ? - also where have you loaded 'DupsAr'
    upload your workbook - see big yellow banner.
    please put your code between code tags as required by forum rules - makes it easier to copy with formatting.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

+ 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. [SOLVED] VBA Evaluate Array then imput into range adjusting forumla in Array down with the Range
    By fireguy7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2019, 03:40 PM
  2. [SOLVED] Transfering data in a range to another sheet (ommiting the blank cells)
    By pick-six in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-18-2016, 02:27 PM
  3. Replies: 0
    Last Post: 03-26-2014, 07:52 AM
  4. Transfering Range of Cells with Merge & Grouping
    By gimgandi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-25-2013, 12:29 PM
  5. Replies: 0
    Last Post: 09-15-2012, 06:51 AM
  6. [SOLVED] Add Range to Array find Array value and Paste back to Range
    By Foreverlearning in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-28-2012, 05:45 PM
  7. using selection/range for transfering tables of data to records for database
    By nonplussed in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-22-2011, 05:42 PM

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