ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Round Function has stopped working - Urgent (https://www.excelbanter.com/excel-programming/293458-round-function-has-stopped-working-urgent.html)

Stuart[_5_]

Round Function has stopped working - Urgent
 
The Round function no longer works. It fails with the
message:
Wrong number of arguments or invalid property
assignment.

With ng help, I was given this slightly amended code:
Sub TestRound2()
Dim ws As Worksheet, R As Range, C As Range
Dim qty As Double, rate As Double, Data As Double

With ActiveSheet
'.Unprotect
Set C = .Range("D2")
Data = C.Offset(0, 9).Value
qty = C.Value
rate = C.Offset(0, 2).Value
If Data 0 Then
If Data = 5 Then
C.Offset(0, 4).Value = Round(qty * rate * Data / 100, 2)
ElseIf Data = 17.5 Then
C.Offset(0, 5).Value = Round((qty * rate * Data) / 100, 2)
End If
End If
End With
MsgBox Round(qty * rate * Data / 100, 2)
End Sub

This fails as well, if I paste it into a module in the same Project.

However, if placed in a different Project (or a newly created
Project), then all is well.

Another routine in that same Project is now giving the same
Round error message .

Is there anything to resolve this, please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.601 / Virus Database: 382 - Release Date: 29/02/2004



Tom Ogilvy

Round Function has stopped working - Urgent
 
You have probably declared round as a function somewhere in that project.
The local definition is taking precedence over the built in function.

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
The Round function no longer works. It fails with the
message:
Wrong number of arguments or invalid property
assignment.

With ng help, I was given this slightly amended code:
Sub TestRound2()
Dim ws As Worksheet, R As Range, C As Range
Dim qty As Double, rate As Double, Data As Double

With ActiveSheet
'.Unprotect
Set C = .Range("D2")
Data = C.Offset(0, 9).Value
qty = C.Value
rate = C.Offset(0, 2).Value
If Data 0 Then
If Data = 5 Then
C.Offset(0, 4).Value = Round(qty * rate * Data / 100, 2)
ElseIf Data = 17.5 Then
C.Offset(0, 5).Value = Round((qty * rate * Data) / 100, 2)
End If
End If
End With
MsgBox Round(qty * rate * Data / 100, 2)
End Sub

This fails as well, if I paste it into a module in the same Project.

However, if placed in a different Project (or a newly created
Project), then all is well.

Another routine in that same Project is now giving the same
Round error message .

Is there anything to resolve this, please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.601 / Virus Database: 382 - Release Date: 29/02/2004





JE McGimpsey

Round Function has stopped working - Urgent
 
Look for a sub or function in your project named Round() and rename it.

A local sub will override a VBA method.

In article ,
"Stuart" wrote:

The Round function no longer works. It fails with the
message:
Wrong number of arguments or invalid property
assignment.

With ng help, I was given this slightly amended code:
Sub TestRound2()
Dim ws As Worksheet, R As Range, C As Range
Dim qty As Double, rate As Double, Data As Double

With ActiveSheet
'.Unprotect
Set C = .Range("D2")
Data = C.Offset(0, 9).Value
qty = C.Value
rate = C.Offset(0, 2).Value
If Data 0 Then
If Data = 5 Then
C.Offset(0, 4).Value = Round(qty * rate * Data / 100, 2)
ElseIf Data = 17.5 Then
C.Offset(0, 5).Value = Round((qty * rate * Data) / 100, 2)
End If
End If
End With
MsgBox Round(qty * rate * Data / 100, 2)
End Sub

This fails as well, if I paste it into a module in the same Project.

However, if placed in a different Project (or a newly created
Project), then all is well.

Another routine in that same Project is now giving the same
Round error message .

Is there anything to resolve this, please?


Stuart[_5_]

Round Function has stopped working - Urgent
 
Many thanks to you both.
That was my error.

Regards and thanks.


"JE McGimpsey" wrote in message
...
Look for a sub or function in your project named Round() and rename it.

A local sub will override a VBA method.

In article ,
"Stuart" wrote:

The Round function no longer works. It fails with the
message:
Wrong number of arguments or invalid property
assignment.

With ng help, I was given this slightly amended code:
Sub TestRound2()
Dim ws As Worksheet, R As Range, C As Range
Dim qty As Double, rate As Double, Data As Double

With ActiveSheet
'.Unprotect
Set C = .Range("D2")
Data = C.Offset(0, 9).Value
qty = C.Value
rate = C.Offset(0, 2).Value
If Data 0 Then
If Data = 5 Then
C.Offset(0, 4).Value = Round(qty * rate * Data / 100, 2)
ElseIf Data = 17.5 Then
C.Offset(0, 5).Value = Round((qty * rate * Data) / 100, 2)
End If
End If
End With
MsgBox Round(qty * rate * Data / 100, 2)
End Sub

This fails as well, if I paste it into a module in the same Project.

However, if placed in a different Project (or a newly created
Project), then all is well.

Another routine in that same Project is now giving the same
Round error message .

Is there anything to resolve this, please?



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.601 / Virus Database: 382 - Release Date: 29/02/2004




All times are GMT +1. The time now is 05:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com