[mso] Re: EXCEL integer division

  • From: "Colli, Anthony G" <Anthony.Colli@xxxxxxx>
  • To: "'mso@xxxxxxxxxxxxx'" <mso@xxxxxxxxxxxxx>
  • Date: Mon, 5 Aug 2002 16:53:01 -0400

I am actually working in Access VBA trying to write a function for an
inventory management thing. In Excel I need to create a map of the actual
inventory. 'x','y' coordinates in a box. I have the function in VBA done, I
have been trying to create the same thing on an Excel sheet. The idea was to
give the user a input box and the sheet would be created on the fly
depending on the variables entered. Instead of a massive document just
create what is needed. 







-----Original Message-----
From: Greg Chapman [mailto:greg@xxxxxxxxxxxxx]
Sent: Monday, August 05, 2002 4:21 PM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Re: EXCEL integer division



Not a problem. Excel isn't home for me, either.<g>

Where is that '0' being returned from? Is it ADO? I ask because there
are ways within VBA to test the value of variables and the types of
data. If you're using Excel as a COM server (we used to call it an OLE
automation server), you can use the IsEmpty, IsNumeric, etc.

Here's a sample VBA macro that is hardcoded to the cell range $A$1 in
Sheet1 that will show you Empty, Numeric and Non-Numeric values in that
cell:

Sub TestforCellContents()

Dim TestCell

Set TestCell = Worksheets("Sheet1").Cells(1, 1)

If IsEmpty(TestCell.Value) Then
    MsgBox "$A$1 has no entry"
Else
    If IsNumeric(TestCell.Value) Then
        MsgBox "$A$1 has a numeric value: " & _
        TestCell.Value
    Else
        MsgBox "$A$1 has a non-numeric entry: " & _
        Chr(34) & TestCell.Value & Chr(34)
    End If
End If

End Sub

Greg Chapman
http://www.mousetrax.com 
"Counting in binary is as easy as 01, 10, 11!
With thinking this clear, is coding really a good idea?"


> -----Original Message-----
> From: mso-bounce@xxxxxxxxxxxxx 
> [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of Colli, Anthony G
> Sent: Monday, August 05, 2002 2:51 PM
> To: 'mso@xxxxxxxxxxxxx'
> Subject: [mso] Re: EXCEL integer division
> 
> 
> Thanks Greg, I really don't know much about Excel, I do most 
> of my stuff in Access and VBA. It looks like I might have to 
> create a function, because any empty cell that is treated as 
> '0' will return an error, can't have that, and I know that it 
> will be the case occasionally. 
> 
> 
> -Anthony
> 
> -----Original Message-----
> From: Greg Chapman [mailto:greg@xxxxxxxxxxxxx]
> Sent: Monday, August 05, 2002 3:16 PM
> To: mso@xxxxxxxxxxxxx
> Subject: [mso] Re: EXCEL integer division
> 
> 
> 
> Assuming that you mean "Other than creating a function" = to 
> a VBA solution, sure!
> 
> >From Excel VBA Help on the VBA MOD function:
> "result = number1 Mod number2
> 
> The Mod operator syntax has these parts:
> 
> Part Description 
> result Required; any numeric variable. 
> number1 Required; any numeric expression. 
> number2 Required; any numeric expression. 
> 
> Remarks
> 
> The modulus, or remainder, operator divides number1 by 
> number2 (rounding floating-point numbers to integers) and 
> returns only the remainder as result. For example, in the 
> following expression, A (result) equals 5.
> 
> A = 19 Mod 6.7
> 
> Usually, the data type of result is a Byte, Byte variant, 
> Integer, Integer variant, Long, or Variant containing a Long, 
> regardless of whether or not result is a whole number. Any 
> fractional portion is truncated. However, if any expression 
> is Null, result is Null. Any expression that is Empty is 
> treated as 0."
> 
> For clarity, I'm going to refer to the functions you create 
> in Excel's UI as Cell or Range functions. VBA supports 
> functions, too, but it's a different kind of function.<g>
> 
> In a Cell Function, the formula would be:
> =MOD($A$1,$A$2)
> 
> If cell $A$1 has 11 and cell $A$2 has 4, the cell function 
> should return 3
> 
> Greg Chapman
> http://www.mousetrax.com 
> "Counting in binary is as easy as 01, 10, 11!
> With thinking this clear, is coding really a good idea?"
> 
> 
> > -----Original Message-----
> > From: mso-bounce@xxxxxxxxxxxxx
> > [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of Colli, Anthony G
> > Sent: Monday, August 05, 2002 1:45 PM
> > To: 'mso@xxxxxxxxxxxxx'
> > Subject: [mso] Re: EXCEL integer division
> > 
> > 
> > So I guess this leads me to another question. Is there a way
> > in Excel to return the modulus (remainder) of division? Other 
> > than creating a function?
> > 
> > Where 19 MOD 11 = 8
> > 
> > 
> > 
> > 
> 
> *************************************************************
> You are receiving this mail because you subscribed to 
> mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx
> 
> To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> 
> To Unsubscribe from this group, send an email to 
> mso-request@xxxxxxxxxxxxx?Subject=unsubscribe
> 
> Or, visit the group's homepage and use the dropdown menu.  
> This will also allow you to change your email settings to 
> digest or vacation (no mail). //www.freelists.org/webpage/mso
> 
> To be able to use the files section for sharing files with 
> the group, send a request to mso-moderators@xxxxxxxxxxxxx and 
> you will be sent an invitation with instructions.  Once you 
> are a member of the files group, you can go here to 
> upload/download files: http://www.smartgroups.com/vault/msofiles
> *************************************************************
> 
> 
> *************************************************************
> You are receiving this mail because you subscribed to 
> mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx
> 
> To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> 
> To Unsubscribe from this group, send an email to 
> mso-request@xxxxxxxxxxxxx?Subject=unsubscribe
> 
> Or, visit the group's homepage and use the dropdown menu.  
> This will also allow you to change your email settings to 
> digest or vacation (no mail). //www.freelists.org/webpage/mso
> 
> To be able to use the files section for sharing files with 
> the group, send a request to mso-moderators@xxxxxxxxxxxxx and 
> you will be sent an invitation with instructions.  Once you 
> are a member of the files group, you can go here to 
> upload/download files: http://www.smartgroups.com/vault/msofiles
> *************************************************************
> 
> 

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also
allow you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation
with instructions.  Once you are a member of the files group, you can go
here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************


*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: