+ Reply to Thread
Results 1 to 8 of 8

Help with DIM statement

  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Question Help with DIM statement

    I have this code, and I've declared LastRow() as Long, but it gives a compile error expected array notice on the
    Please Login or Register  to view this content.
    line. I don't know what it needs to be instead.

    Please Login or Register  to view this content.
    Last edited by narrowgate88; 10-27-2015 at 02:38 PM. Reason: Solved

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,528

    Re: Help with DIM statement

    The parentheses () tell VBA that you intend to use lastrow as an array of longs. You do not specify the size (how many elements) this array should use. VBA expects that, sometime before using lastrow(), you will specify the number of elements using a Redim statement.

    Your use of lastrow() in the 3rd statement looks more like you want to treat lastrow() as a function procedure. You will give the function a worksheet and it will figure out what the lastrow is. A variable is not a function, so you first need to decide how you really want to use lastrow(), then amend your code to reflect the desired use of lastrow().
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Re: Help with DIM statement

    I'm just attempting to identify the last row of data in the DestSh worksheet. I originally had the DIM statement without the () but got the same error. Do I need to use something instead of "Long"?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Help with DIM statement

    I found some things and I highlighted them in Red. Let us know what your objective is a perhaps we can help.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Re: Help with DIM statement

    Here is the entire code. I'm basically trying to consolidate the data from multiple worksheets onto a summary worksheet. I found most of this code online, so I'm trying to work through the bugs.
    Please Login or Register  to view this content.
    End Sub

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Help with DIM statement

    Test this on a copy of your workbook too see if it does what you require.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Re: Help with DIM statement

    Yes, this works. Wow, much shorter. Thank you.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Help with DIM statement

    You're welcome. Glad to help out and thanks for the feedback.

+ 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. Replies: 2
    Last Post: 07-09-2015, 04:25 PM
  2. [SOLVED] If statement to select data - nested statement - assistance
    By petitesouris in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-29-2015, 09:55 PM
  3. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  4. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  5. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  6. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  7. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 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