+ Reply to Thread
Results 1 to 5 of 5

error:Statement invalid outside type block

  1. #1
    Registered User
    Join Date
    06-04-2010
    Location
    NY,USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    error:Statement invalid outside type block

    I am trying to sort a number of columns in my worksheet based on the Cell Color. The columns have variable length of rows.
    I have two questions:
    1. When I run my current code in debug mode then I get the error: "Statement invalid outside type block". I am not sure which parantheses I should remove to get rid of the error.
    2.Ssecondly I think my current code is not going to do the sort that I would like it to do. Can anyone please suggest what changes I should make in my code to get it working.

    Below I have pasted a sample of my sheet as a link:
    http://picasaweb.google.com/manishab...14238835510658

    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: error:Statement invalid outside type block

    1. Which line gives you the error?
    2. Why post a picture, rather than a sample workbook? It would also help if you explained why you think the sort won't do what you want, as well as what you actually do want.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    06-04-2010
    Location
    NY,USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: error:Statement invalid outside type block

    Quote Originally Posted by romperstomper View Post
    1. Which line gives you the error?
    2. Why post a picture, rather than a sample workbook? It would also help if you explained why you think the sort won't do what you want, as well as what you actually do want.

    Thanks romperstomper for replying.

    1. I was able to solve the first problem of the error: Statement invalid outside type block just a few minutes back. I had forgotten to add Dim infront of myRange

    2. I need help with the second part that is sort the rows in each column according to color such that the Red colored cells are on the top and the blue colored on the bottom for each column.

    I pasted a link of the picture of the worksheet to give an example of the format of the data I am dealing with. This time I attach the worksheet to this post for convinience of the readers.

    below is also the edited code that doesnot throw the Statement invalid outside type block error
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: error:Statement invalid outside type block

    Something like this?
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-04-2010
    Location
    NY,USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: error:Statement invalid outside type block

    thanks a lot!!!!! It worked fine. thanks for your help. My code was quite complicated.


    Quote Originally Posted by romperstomper View Post
    Something like this?
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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