Results 1 to 16 of 16

Referring to columns by header in code, error 1004 method range of object global failed?

Threaded View

LIL2606 Referring to columns by... 02-11-2019, 03:38 PM
Richard Buttrey Re: Referring to columns by... 02-11-2019, 03:50 PM
LIL2606 Re: Referring to columns by... 02-11-2019, 04:02 PM
Richard Buttrey Re: Referring to columns by... 02-11-2019, 06:44 PM
LIL2606 Re: Referring to columns by... 02-12-2019, 05:29 AM
nigelog Re: Referring to columns by... 02-13-2019, 09:38 AM
LIL2606 Re: Referring to columns by... 02-13-2019, 12:45 PM
nigelog Re: Referring to columns by... 02-13-2019, 01:32 PM
LIL2606 Re: Referring to columns by... 02-13-2019, 03:44 PM
nigelog There is a thread here that... 02-13-2019, 07:50 PM
nigelog Re: Referring to columns by... 02-13-2019, 08:05 PM
LIL2606 Re: Referring to columns by... 02-14-2019, 05:09 AM
nigelog Re: Referring to columns by... 02-14-2019, 05:18 AM
jindon Re: Referring to columns by... 02-14-2019, 05:21 AM
LIL2606 Re: Referring to columns by... 02-14-2019, 07:25 AM
jindon Re: Referring to columns by... 02-14-2019, 07:54 AM
  1. #1
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Referring to columns by header in code, error 1004 method range of object global failed?

    Hi all,

    Code:

    Sub Lil2606()
       Dim Data As Range, delRng As Range
       Dim DictKey As String
       Dim Dict As New Scripting.dictionary
       
    Dict.CompareMode = TextCompare
       
          For Each Data In Sheet1.ListObjects("Table1").ListColumns("First name").DataBodyRange
             
             DictKey = Join(Range("Table1([First name], [Surname], [Fruit])", "|"))
             
             If Not Dict.Exists(DictKey) Then
                Dict.Add DictKey, Nothing
             Else
                If delRng Is Nothing Then Set delRng = Data.Resize(, ListColumns.Count) Else Set delRng = Union(delRng, Data.Resize(, ListColumns.Count))
             End If
          Next Data
       If Not delRng Is Nothing Then delRng.Delete
    End Sub
    Just debugging at the minute so more issues may come up, but at the minute

    DictKey = Join(Range ... etc.) is the row highlighted, saying Run-time Error 1004, Method 'Range' of object '_Global' failed...

    I really would like to refer to the table columns by their headers as it would make sure it doesn't matter if the data it is in workbook column A B or so..

    Please help?
    Attached Files Attached Files
    Last edited by LIL2606; 02-11-2019 at 03:41 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Runtime error 1004 Method 'Range' of object_ Global Failed
    By stevoDE in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-30-2017, 11:33 AM
  2. Error Method Range of Object - Global Failed
    By bdrod in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2016, 06:32 PM
  3. Run Time error 1004 method sheets of object global failed
    By bevc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-27-2016, 04:09 PM
  4. [SOLVED] Error - Method 'range of object' - Global failed
    By highlystrung in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2015, 06:18 AM
  5. Run-time error '1004': Method 'Range' of object 'Global' failed
    By djwestholm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2012, 04:52 PM
  6. Run-time error '1004': Method 'Range' of object '_ Global' failed
    By mdvc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2011, 11:48 AM
  7. runtime error 1004 method range of object global failed
    By dreamz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-26-2006, 03:25 PM

Tags for this Thread

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