+ Reply to Thread
Results 1 to 6 of 6

Help programming a Macro.... really new to VBA :(

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    Costa Rica
    MS-Off Ver
    Excel 2013
    Posts
    5

    Help programming a Macro.... really new to VBA :(

    So I created this VBA Module

    Please Login or Register  to view this content.
    After a lot of time thinking about the logic it should have I can't even debug it cause I get a Type Mismatch error on this line: stockAvailable = CInt(Worksheets("4WEEKS").Cells(rowIndex, stockTracker).Value)
    Can someone plz help me out

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help programming a Macro.... really new to VBA :(

    Hi AlonQ,

    Maybe use Int rather than CInt:

    stockAvailable =Int(Worksheets("4WEEKS").Cells(rowIndex, stockTracker).Value)

    there are no Strings in your declarations??
    Last edited by xladept; 05-15-2013 at 03:55 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    Costa Rica
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Help programming a Macro.... really new to VBA :(

    Nope, its either a number o nothing at all

  4. #4
    Registered User
    Join Date
    05-10-2013
    Location
    Costa Rica
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Help programming a Macro.... really new to VBA :(

    Or nevermid aparently the formula that's assigned to that cell puts a "" in the cell if the resulting sum is 0.... so I guess "" counts as a String?

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help programming a Macro.... really new to VBA :(

    Hi AlonQ,

    Yes - The quotation marks around anything is the way we define a string, and to use the CInt,CSng,CDbl etc you must have a string.

    Did using the Int rather than the CInt not work???

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Help programming a Macro.... really new to VBA :(

    Quote Originally Posted by xladept View Post
    to use the CInt,CSng,CDbl etc you must have a string.
    not so-CInt will work with numbers as well

    perhaps
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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