+ Reply to Thread
Results 1 to 4 of 4

Simple Question About An Error

  1. #1
    Registered User
    Join Date
    10-16-2011
    Location
    montana, usa
    MS-Off Ver
    Excel 2007
    Posts
    31

    Simple Question About An Error

    So I have this VBA code that is supposed to look through a declared range and add up the values if the cell is equal to a certain value here is the code i have

    Please Login or Register  to view this content.
    and when i try to run the sub

    Please Login or Register  to view this content.
    that gets highlighted and i dont understand why?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Simple Question About An Error

    Hello Cfallscat,

    The Cells property returns all cells in the range the property is attached to. Your statement in effect is returning an array. You can not check an entire array's content against a single value.

    I suspect you want to check each cell in the range and test if the value is equal to one. If so then this version of your code will do that.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Simple Question About An Error

    Hi Cfallscat, try the following code
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  4. #4
    Registered User
    Join Date
    10-16-2011
    Location
    montana, usa
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Simple Question About An Error

    Well I was messing around with it and came up with a very similiar code that works the exact same

    Please Login or Register  to view this content.
    ok now the only problem i have is i want it to not add that cell value but to offset to the next column and add that value?

    how would i do that i tried

    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