ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code not working (https://www.excelbanter.com/excel-programming/274349-re-code-not-working.html)

Bob Phillips[_5_]

Code not working
 
Phil,

Nothing can be assumed, you must spell every test out fully, and include
Worksheet object, and the dot operator.

IF Worksheets("A").[A1] < Worksheets("B").[M1] OR _
Worksheets("A").[A1] < Worksheets("B").[M2] or

etc.
--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Excel 2000

This module code is inteded to give the user a message
when improper data is entered in either the Customer or
Finance worksheet. It isn't working. The "If..." line is
colored red.

Sub On_Update()

If (Worksheets("Customer")Or ("Finance")[M15] < [M16] Or
[M47] < [M48] Or [M79] < [M80]) Then
' MsgBox "Target cannot be greater than Chart Max"

End If
End Sub

Where am I going wrong?

Thanks, Phil




Phil Hageman

Code not working
 
Thanks, Bob. I'll get working on it.
-----Original Message-----
Phil,

Nothing can be assumed, you must spell every test out

fully, and include
Worksheet object, and the dot operator.

IF Worksheets("A").[A1] < Worksheets("B").[M1] OR _
Worksheets("A").[A1] < Worksheets("B").[M2] or

etc.
--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Excel 2000

This module code is inteded to give the user a message
when improper data is entered in either the Customer or
Finance worksheet. It isn't working. The "If..." line

is
colored red.

Sub On_Update()

If (Worksheets("Customer")Or ("Finance")[M15] < [M16] Or
[M47] < [M48] Or [M79] < [M80]) Then
' MsgBox "Target cannot be greater than Chart

Max"

End If
End Sub

Where am I going wrong?

Thanks, Phil



.


Chip Pearson

Code not working
 
Phil,

You code

Dim MyArray() As Integer

creates an un-initialized array. You must then use Redim to
allocate and initialize the array before you can use any of the
elements in the array. E.g.,

ReDim MyArray(1 To 10)

Once you've initialized the array, you can access its elements:

MyArray(8) = 234


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Phil Hageman" wrote in message
...
Bob, here's what I have now:

Sub Descending_Values()

Dim MyArray() As Integer
MyArray(8) = 234

If (Worksheets("1. Customer").[M15] < Worksheets("1.
Customer").[M16] Or _
(Worksheets("2. Financial").[M15] < Worksheets("2.
Financial").[M16])) Then
MsgBox "Target cannot be greater than Chart Max"
End If
End Sub

The Dim statement is causing a compile error: Run-time
error '9': Subscript out of range. I don't know what this
means. I copied the Dim line out of Help, as it
suggested.

Can you help straighten this out?

Thanks, Phil



-----Original Message-----
Phil,

Nothing can be assumed, you must spell every test out

fully, and include
Worksheet object, and the dot operator.

IF Worksheets("A").[A1] < Worksheets("B").[M1] OR _
Worksheets("A").[A1] < Worksheets("B").[M2] or

etc.
--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Excel 2000

This module code is inteded to give the user a message
when improper data is entered in either the Customer or
Finance worksheet. It isn't working. The "If..." line

is
colored red.

Sub On_Update()

If (Worksheets("Customer")Or ("Finance")[M15] < [M16] Or
[M47] < [M48] Or [M79] < [M80]) Then
' MsgBox "Target cannot be greater than Chart

Max"

End If
End Sub

Where am I going wrong?

Thanks, Phil



.




Bob Phillips[_5_]

Code not working
 
Phil,

It's not the Dim that is erroring, but the next line where you have
allocated a value to item 8 in the array, but the array is not dimensioned.
You can either dim in it the declaration
Dim MyArray(8) As Integer
or redim it later
ReDim MyArray(8)

--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Bob, here's what I have now:

Sub Descending_Values()

Dim MyArray() As Integer
MyArray(8) = 234

If (Worksheets("1. Customer").[M15] < Worksheets("1.
Customer").[M16] Or _
(Worksheets("2. Financial").[M15] < Worksheets("2.
Financial").[M16])) Then
MsgBox "Target cannot be greater than Chart Max"
End If
End Sub

The Dim statement is causing a compile error: Run-time
error '9': Subscript out of range. I don't know what this
means. I copied the Dim line out of Help, as it
suggested.

Can you help straighten this out?

Thanks, Phil



-----Original Message-----
Phil,

Nothing can be assumed, you must spell every test out

fully, and include
Worksheet object, and the dot operator.

IF Worksheets("A").[A1] < Worksheets("B").[M1] OR _
Worksheets("A").[A1] < Worksheets("B").[M2] or

etc.
--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Excel 2000

This module code is inteded to give the user a message
when improper data is entered in either the Customer or
Finance worksheet. It isn't working. The "If..." line

is
colored red.

Sub On_Update()

If (Worksheets("Customer")Or ("Finance")[M15] < [M16] Or
[M47] < [M48] Or [M79] < [M80]) Then
' MsgBox "Target cannot be greater than Chart

Max"

End If
End Sub

Where am I going wrong?

Thanks, Phil



.




Phil Hageman

Code not working
 
Bob, I'm over my head here - don't understand what you're
saying (I'm not a programmer). Could you review my
original intent with this module code and suggest the code
to use to get the job done?

Thanks, Phil
-----Original Message-----
Phil,

It's not the Dim that is erroring, but the next line

where you have
allocated a value to item 8 in the array, but the array

is not dimensioned.
You can either dim in it the declaration
Dim MyArray(8) As Integer
or redim it later
ReDim MyArray(8)

--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Bob, here's what I have now:

Sub Descending_Values()

Dim MyArray() As Integer
MyArray(8) = 234

If (Worksheets("1. Customer").[M15] < Worksheets("1.
Customer").[M16] Or _
(Worksheets("2. Financial").[M15] < Worksheets("2.
Financial").[M16])) Then
MsgBox "Target cannot be greater than Chart Max"
End If
End Sub

The Dim statement is causing a compile error: Run-time
error '9': Subscript out of range. I don't know what

this
means. I copied the Dim line out of Help, as it
suggested.

Can you help straighten this out?

Thanks, Phil



-----Original Message-----
Phil,

Nothing can be assumed, you must spell every test out

fully, and include
Worksheet object, and the dot operator.

IF Worksheets("A").[A1] < Worksheets("B").[M1] OR _
Worksheets("A").[A1] < Worksheets("B").[M2]

or

etc.
--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Excel 2000

This module code is inteded to give the user a

message
when improper data is entered in either the Customer

or
Finance worksheet. It isn't working. The "If..."

line
is
colored red.

Sub On_Update()

If (Worksheets("Customer")Or ("Finance")[M15] <

[M16] Or
[M47] < [M48] Or [M79] < [M80]) Then
' MsgBox "Target cannot be greater than Chart

Max"

End If
End Sub

Where am I going wrong?

Thanks, Phil


.



.


Bob Phillips[_5_]

Code not working
 
Phil,

This is what I mean

Sub Descending_Values()

Dim MyArray() As Integer

Redim MyARray ( To 10) ' or your maximum entry
MyArray(8) = 234

If (Worksheets("1. Customer").[M15] < Worksheets("1.
Customer").[M16] Or _
(Worksheets("2. Financial").[M15] < Worksheets("2.
Financial").[M16])) Then
MsgBox "Target cannot be greater than Chart Max"
End If
End Sub



--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Bob, I'm over my head here - don't understand what you're
saying (I'm not a programmer). Could you review my
original intent with this module code and suggest the code
to use to get the job done?

Thanks, Phil
-----Original Message-----
Phil,

It's not the Dim that is erroring, but the next line

where you have
allocated a value to item 8 in the array, but the array

is not dimensioned.
You can either dim in it the declaration
Dim MyArray(8) As Integer
or redim it later
ReDim MyArray(8)

--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Bob, here's what I have now:

Sub Descending_Values()

Dim MyArray() As Integer
MyArray(8) = 234

If (Worksheets("1. Customer").[M15] < Worksheets("1.
Customer").[M16] Or _
(Worksheets("2. Financial").[M15] < Worksheets("2.
Financial").[M16])) Then
MsgBox "Target cannot be greater than Chart Max"
End If
End Sub

The Dim statement is causing a compile error: Run-time
error '9': Subscript out of range. I don't know what

this
means. I copied the Dim line out of Help, as it
suggested.

Can you help straighten this out?

Thanks, Phil



-----Original Message-----
Phil,

Nothing can be assumed, you must spell every test out
fully, and include
Worksheet object, and the dot operator.

IF Worksheets("A").[A1] < Worksheets("B").[M1] OR _
Worksheets("A").[A1] < Worksheets("B").[M2]

or

etc.
--

HTH

Bob Phillips

"Phil Hageman" wrote in message
...
Excel 2000

This module code is inteded to give the user a

message
when improper data is entered in either the Customer

or
Finance worksheet. It isn't working. The "If..."

line
is
colored red.

Sub On_Update()

If (Worksheets("Customer")Or ("Finance")[M15] <

[M16] Or
[M47] < [M48] Or [M79] < [M80]) Then
' MsgBox "Target cannot be greater than Chart
Max"

End If
End Sub

Where am I going wrong?

Thanks, Phil


.



.





All times are GMT +1. The time now is 07:27 PM.

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