+ Reply to Thread
Results 1 to 2 of 2

Thread: Do While loop is not retaining correct values

  1. #1
    Registered User
    Join Date
    08-05-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    37

    Do While loop is not retaining correct values

    Hello all,

    I am using a Do While loop in order to add up values in a column up to a certain point. Problem is, when checking what numbers the loop has stored, it only shows a value of 0, which in turn gives me a "divisible by 0" error down the line when I have to plug in said values in my formula. I have declared the variables as LONG in my macro.

    Let me know if you need any further information. Any help would be massively appreciated. Thank you!

                    Do While Sheets("Data").Cells(7 + c, 4) <> ""
                    
                        VPL = VPL + Cells(7 + c, 10)
                        MARKUP = MARKUP + Cells(7 + c, 14)
                    
                        c = c + 1
                
                    Loop
    Last edited by farzyness; 12-16-2010 at 09:44 AM.

  2. #2
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,300

    Re: Do While loop is not retaining correct values

    Hi,

    Try adding a ".Value" after your Cells(...) statements and see if that helps.

    IE instead of Cells(...), make it Cells(...).Value

    hth.
    One test is worth a thousand opinions.
    Click the * below to say thanks.

+ 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.2.0