#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Macro Error

Hello,

Can someone please help?

I get a COMPILE ERROR on my MAC. I am running OSX

It says: my sub or function is not defined.

Here is my Code:

Sub Picture1_Click()

Dim chipcnt As Variant
Dim MyRange As Range


'Clear the chip distribution cells
Set MyRange = Worksheets("Calculator").Range("F3:F11")
MyRange.Clear

'Loop through each chip denomination
For i = 3 To 11

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime


'Determine the maximum number each player can have
chipcnt = Cells(i, 2).Value / Cells(14, 4).Value
'Round the results down
If Round(chipcnt, 0) chipcnt Then
chipcnt = Round(chipcnt, 0) - 1
Else
chipcnt = Round(chipcnt, 0)
End If


'Grab the desired stack size and determine the current stack size
Cells(i, 6).Value = chipcnt
stack = stack + chipcnt * Cells(i, 3).Value

GoodStack = Cells(15, 4).Value


'Adjust the chip distribution to meet the desired stack size
If stack GoodStack Then
j = i
Do While stack GoodStack
Do While stack - GoodStack = Cells(j, 3).Value
If Cells(j, 6).Value = 0 Then
Exit Do
End If
Cells(j, 6).Value = Cells(j, 6).Value - 1
stack = stack - Cells(j, 3).Value
Loop
j = j - 1
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

Loop
Exit For
End If



Next

'Warn if the user does not have enough chips to reach stack size
If stack < GoodStack Then
MsgBox "You do not have enough chips to generate this stack size.",
vbCritical, "Stack too big!"
MyRange.Clear
Cells(15, 4).Activate

End If

End Sub





What are my errors?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Macro Error


If you are using Office 2008, then you are out of luck.
It does not support VBA.
Otherwise, declare all ten variables and try running the code again.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"sross002"
wrote in message
Hello,
Can someone please help?
I get a COMPILE ERROR on my MAC. I am running OSX
It says: my sub or function is not defined.
Here is my Code:

Sub Picture1_Click()

Dim chipcnt As Variant
Dim MyRange As Range

'Clear the chip distribution cells
Set MyRange = Worksheets("Calculator").Range("F3:F11")
MyRange.Clear

'Loop through each chip denomination
For i = 3 To 11
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
'Determine the maximum number each player can have
chipcnt = Cells(i, 2).Value / Cells(14, 4).Value
'Round the results down
If Round(chipcnt, 0) chipcnt Then
chipcnt = Round(chipcnt, 0) - 1
Else
chipcnt = Round(chipcnt, 0)
End If


'Grab the desired stack size and determine the current stack size
Cells(i, 6).Value = chipcnt
stack = stack + chipcnt * Cells(i, 3).Value
GoodStack = Cells(15, 4).Value
'Adjust the chip distribution to meet the desired stack size
If stack GoodStack Then
j = i
Do While stack GoodStack
Do While stack - GoodStack = Cells(j, 3).Value
If Cells(j, 6).Value = 0 Then
Exit Do
End If
Cells(j, 6).Value = Cells(j, 6).Value - 1
stack = stack - Cells(j, 3).Value
Loop
j = j - 1
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Loop
Exit For
End If
Next

'Warn if the user does not have enough chips to reach stack size
If stack < GoodStack Then
MsgBox "You do not have enough chips to generate this stack size.",
vbCritical, "Stack too big!"
MyRange.Clear
Cells(15, 4).Activate
End If
End Sub

What are my errors?
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Macro Error

I have office 2003

"Jim Cone" wrote:


If you are using Office 2008, then you are out of luck.
It does not support VBA.
Otherwise, declare all ten variables and try running the code again.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"sross002"
wrote in message
Hello,
Can someone please help?
I get a COMPILE ERROR on my MAC. I am running OSX
It says: my sub or function is not defined.
Here is my Code:

Sub Picture1_Click()

Dim chipcnt As Variant
Dim MyRange As Range

'Clear the chip distribution cells
Set MyRange = Worksheets("Calculator").Range("F3:F11")
MyRange.Clear

'Loop through each chip denomination
For i = 3 To 11
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
'Determine the maximum number each player can have
chipcnt = Cells(i, 2).Value / Cells(14, 4).Value
'Round the results down
If Round(chipcnt, 0) chipcnt Then
chipcnt = Round(chipcnt, 0) - 1
Else
chipcnt = Round(chipcnt, 0)
End If


'Grab the desired stack size and determine the current stack size
Cells(i, 6).Value = chipcnt
stack = stack + chipcnt * Cells(i, 3).Value
GoodStack = Cells(15, 4).Value
'Adjust the chip distribution to meet the desired stack size
If stack GoodStack Then
j = i
Do While stack GoodStack
Do While stack - GoodStack = Cells(j, 3).Value
If Cells(j, 6).Value = 0 Then
Exit Do
End If
Cells(j, 6).Value = Cells(j, 6).Value - 1
stack = stack - Cells(j, 3).Value
Loop
j = j - 1
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Loop
Exit For
End If
Next

'Warn if the user does not have enough chips to reach stack size
If stack < GoodStack Then
MsgBox "You do not have enough chips to generate this stack size.",
vbCritical, "Stack too big!"
MyRange.Clear
Cells(15, 4).Activate
End If
End Sub

What are my errors?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default Macro Error

Hmmm.. If you're using Office 2003 on your Mac (not MAC), then you're
running it in a Windows version (i.e., via Parallels or virtual machine
or BootCamp), so it should compile.

If you actually are trying to compile it in Office 2004 (the Mac
version) instead, Mac VBA is at version 5, which doesn't include the
Round() function. Either supply your own or use Application.Round (note
however, that the XL function handles a 5 in the terminal digit
differently than the VBA function does:

=ROUND(0.5, 0) == 1

?Round(0.5, 0) == 0






In article ,
sross002 wrote:

I have office 2003

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Macro error : Application-defined or object-defined error Joe Excel Discussion (Misc queries) 3 January 27th 06 02:32 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Macro error - more help please! Anthony Excel Discussion (Misc queries) 2 March 22nd 05 03:02 PM


All times are GMT +1. The time now is 09:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"