Counting - Ms Excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mitsy
    New Member
    • Sep 2007
    • 9

    Counting - Ms Excel

    Hello. I have been trying to do this for a LONG time but not getting anywhere so I was wondering if anyone could help me out.

    This is the problem. I'm gonna out sum values (radius of disks) in Excel, and I want VB to count how many values (disks) I have put. I have to use a While statement and this is what i have done (wrongly) so far...
    Help anyone??

    [CODE=vb]DimRadiusOFDisk As Integer

    Initial Value = 0
    While RadiusOFDisk > 0
    ActiveSheet.Cel ls(ROW_NUMDISKS , COL_DATA) = "Initial Value" + "New Value"
    Wend[/CODE]
    Last edited by Killer42; Sep 28 '07, 02:41 AM. Reason: Added CODE=vb tag
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    A couple of questions.

    What version of VB are you using? Or are you just using the VBA editor built into Excel?

    Can you show us the actual code please, rather than an approximation?

    Comment

    • mitsy
      New Member
      • Sep 2007
      • 9

      #3
      Originally posted by Killer42
      A couple of questions.

      What version of VB are you using? Or are you just using the VBA editor built into Excel?

      Can you show us the actual code please, rather than an approximation?
      I'm using VBA built in Excel 2003.
      I'm not sure I understand what you mean by "the actual code" because I don't really have any code yet... I'm trying to make a code to make Excel count the number of values I put in a certain column... do you know what I'm saying? Hope that helps! Coz I need yours!

      Comment

      • BlackMustard
        New Member
        • Aug 2007
        • 88

        #4
        Originally posted by mitsy
        Hello. I have been trying to do this for a LONG time but not getting anywhere so I was wondering if anyone could help me out.

        This is the problem. I'm gonna out sum values (radius of disks) in Excel, and I want VB to count how many values (disks) I have put. I have to use a While statement and this is what i have done (wrongly) so far...
        Help anyone??

        [CODE=vb]DimRadiusOFDisk As Integer

        Initial Value = 0
        While RadiusOFDisk > 0
        ActiveSheet.Cel ls(ROW_NUMDISKS , COL_DATA) = "Initial Value" + "New Value"
        Wend[/CODE]
        If this code does what you want it to except for counting the values, you could simply insert code to use an integer variable as counter and increase the value of it each time the loop is run.


        [CODE=vb]Dim RadiusOFDisk As Integer
        Dim intValueCount As Integer

        intValueCount = 0
        Initial Value = 0
        While RadiusOFDisk > 0
        intValueCount = intValueCount + 1
        ActiveSheet.Cel ls(ROW_NUMDISKS , COL_DATA) = "Initial Value" + "New Value"
        Wend

        ' The number of times the loop has been run is now stored in intValueCount[/CODE]

        Comment

        • mitsy
          New Member
          • Sep 2007
          • 9

          #5
          Originally posted by BlackMustard
          If this code does what you want it to except for counting the values, you could simply insert code to use an integer variable as counter and increase the value of it each time the loop is run.
          thank you i tried to do it in a different way! now its working! thanks anyway:)

          Comment

          Working...