+ Reply to Thread
Results 1 to 4 of 4

Why do I get a subscript out of range error for the following code line in VBA?

  1. #1
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Why do I get a subscript out of range error for the following code line in VBA?

    Hi all,

    Quick question, I created a table on Sheet3 (just in excel not in VB), named it RT and its only headers (Data1, Data2, Data3) and as you create a table and tick my table had headers it immediately adds an empty line.

    So I enter VB and write this code line:

    Please Login or Register  to view this content.
    and I get subscript out of range error on it. WHY??

    Please help!

    Thanks!
    Last edited by AliGW; 02-20-2019 at 07:07 AM. Reason: Irrelevant section of thread title removed.

  2. #2
    Forum Guru Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Why do I get a subscript out of range error for the following code line in VBA? (Simpl

    Because there are no rows of data in your table, and won't be until you put something into the 'empty' line.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: Why do I get a subscript out of range error for the following code line in VBA?

    Okay.. It is what I was thinking but its confusing because

    Please Login or Register  to view this content.
    does work..

    Anyway. Thank you!

  4. #4
    Forum Guru Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Why do I get a subscript out of range error for the following code line in VBA?

    You may find this useful, to explain the listobject model: https://www.thespreadsheetguru.com/b...t-excel-tables

+ 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. Getting Subscript out of range error in the following code
    By kwadh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-29-2017, 01:18 AM
  2. [SOLVED] VBA 'convert date' code giving 'run time error 9 - subscript out of range'
    By seputus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-05-2017, 07:43 PM
  3. "Subscript out of range error" in a simple code
    By Mutak in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-30-2016, 04:35 PM
  4. Code is giving Runtime Error 9 Subscript out of range
    By clpickett3 in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 03-05-2015, 01:45 PM
  5. [SOLVED] Can't debug this code. The Arrays are producing a Subscript out of Range error
    By seigna in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-06-2013, 05:14 PM
  6. Subscript out of range error & code not working
    By HP RodNuclear in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-01-2011, 03:53 PM
  7. Subscript out of range error using all possible combinations code
    By alisalamiii in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2010, 09:57 AM

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