+ Reply to Thread
Results 1 to 7 of 7

Counting rows with active sheet problem

  1. #1
    Forum Contributor
    Join Date
    02-16-2012
    Location
    London, England
    MS-Off Ver
    Excel mac 2011
    Posts
    238

    Counting rows with active sheet problem

    Hi

    Can't seem to get the row counting thing to work with ActiveSheet.

    This is what I have:
    Please Login or Register  to view this content.
    to summarize, I have a workbook that generates a new sheet after the last one, names it then adds filtered data. On a different sheet I have all the workings out to produce a graph, fairly standard stuff I think. But I can't seem to use the new sheet, I have set a global variable (CurrentWS) as a worksheet so that it can be used in the whole module, and that seems fine elsewhere. But in this one line to simply count all the rows in that sheet, I get a runtime error 13, type mismatch.

    So I have substituted CurrentWS for active sheet sheet and that doesn't work either. The code above is confusing me, the first line assigning variable Last, uses the data dump sheet that I have named in the sheet properties as Data, and this works fine, then second line using active sheet, when I have the latest sheet active with enough data on it to produce a result fails. Can any one spot my error please?

    Kind regards

    Rob

  2. #2
    Forum Guru
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,122

    Re: Counting rows with active sheet problem

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-16-2012
    Location
    London, England
    MS-Off Ver
    Excel mac 2011
    Posts
    238

    Re: Counting rows with active sheet problem

    Still get runtime error 13 type mismatch.

    Googling type mismatch gets that there is a mismatch in variable type, if this is the case, what does "count" actually return if it is not an integer?

  4. #4
    Registered User
    Join Date
    01-31-2014
    Location
    East Coast, England
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Counting rows with active sheet problem

    dim as string not int

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Counting rows with active sheet problem

    Do you get an error with this?

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,122

    Re: Counting rows with active sheet problem

    You need to check if you are working on the active sheet. I do not see any error on the code I have provided you.
    The line could work in any sheet. If the sheet is blank, it still returns 1.

  7. #7
    Forum Contributor dlow's Avatar
    Join Date
    08-12-2013
    Location
    EveryWhere
    MS-Off Ver
    Excel 2007, 2010
    Posts
    275

    Re: Counting rows with active sheet problem

    runtime error 13 type mismatch.
    Option Explicit
    produce a graph
    is it a Chart I think you need to do ActiveWorkSheet

+ 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] Copy rows from active sheet to another sheet (last row) if condition in column X is met
    By mortless in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2013, 08:11 AM
  2. Delete Rows that contains zero and Copy active sheet to New Sheet
    By antoni in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2009, 02:02 AM
  3. Addin active sheet problem
    By tonyscullion@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-10-2005, 10:55 AM
  4. Replies: 1
    Last Post: 11-24-2005, 07:29 AM

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