Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Validation list using code

My sheet ('Purchases') contains a list of medicines, the code below provides
me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in stock").Range("A65536").End(xlUp).Offset(1, 0).Value
= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in stock and apply
that list to the next 20 blank cells in column A on sheet 'Medicine Record'.

My problem is that I want to have the Change Event of that sheet work when
an item in the data validation list is picked and work has Excel '97 and I
believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the control, is it
possible to do this by macro??

Thanks in advance.

Gareth


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Validation list using code

Gareth,

Data Validation doesn't trigger the Change event in 97, but what you could
do is to set another cell linked to your data validation cell, and have a
calculate event do the work for you. I used this technique to have dynamic
data validation list in XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
...
My sheet ('Purchases') contains a list of medicines, the code below

provides
me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in stock").Range("A65536").End(xlUp).Offset(1,

0).Value
= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in stock and

apply
that list to the next 20 blank cells in column A on sheet 'Medicine

Record'.

My problem is that I want to have the Change Event of that sheet work when
an item in the data validation list is picked and work has Excel '97 and I
believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the control, is

it
possible to do this by macro??

Thanks in advance.

Gareth




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Validation list using code

If you enter the data validation source into the control it does work (eg -
yes,no,maybe)

what I want to do is get the list of medicines in B2:B? which have 0 in
H2:H? into a data validation list.

Any ideas?

Gareth
"Bob Phillips" wrote in message
...
Gareth,

Data Validation doesn't trigger the Change event in 97, but what you could
do is to set another cell linked to your data validation cell, and have a
calculate event do the work for you. I used this technique to have dynamic
data validation list in XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
...
My sheet ('Purchases') contains a list of medicines, the code below

provides
me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in stock").Range("A65536").End(xlUp).Offset(1,

0).Value
= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in stock and

apply
that list to the next 20 blank cells in column A on sheet 'Medicine

Record'.

My problem is that I want to have the Change Event of that sheet work

when
an item in the data validation list is picked and work has Excel '97 and

I
believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the control, i

s
it
possible to do this by macro??

Thanks in advance.

Gareth






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Validation list using code

It may not be a problem in your worksheet, but the delimited list has a
maximum of 255 characters:

'=================================
Sub Medicineinstock()
Dim c As Range
Dim str As String
str = ""
With Worksheets("Purchases")
For Each c In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(c.Value) Then
If IsNumeric(c.Value) Then
If c.Value 0 Then
str = str & c.Offset(0, -6).Value & ","
End If
End If
End If
Next
str = Left(str, Len(str) - 1)
str = Left(str, 255)
End With
Debug.Print str
End Sub
'===============================

Gareth wrote:
If you enter the data validation source into the control it does work (eg -
yes,no,maybe)

what I want to do is get the list of medicines in B2:B? which have 0 in
H2:H? into a data validation list.

Any ideas?

Gareth
"Bob Phillips" wrote in message
...

Gareth,

Data Validation doesn't trigger the Change event in 97, but what you could
do is to set another cell linked to your data validation cell, and have a
calculate event do the work for you. I used this technique to have dynamic
data validation list in XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
.. .

My sheet ('Purchases') contains a list of medicines, the code below


provides

me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in stock").Range("A65536").End(xlUp).Offset(1,


0).Value

= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in stock and


apply

that list to the next 20 blank cells in column A on sheet 'Medicine


Record'.

My problem is that I want to have the Change Event of that sheet work


when

an item in the data validation list is picked and work has Excel '97 and


I

believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the control, i


s

it

possible to do this by macro??

Thanks in advance.

Gareth








--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Validation list using code

Debra

Thanks for this, works just great. You are right about the 255 characters
causing a problem though.

Therefore, I would like to try Bob's suggestion of using a linked cell.
Unfortunately I have no idea how to go about it, could anyone please offer
any assistance?

Gareth

"Debra Dalgleish" wrote in message
...
It may not be a problem in your worksheet, but the delimited list has a
maximum of 255 characters:

'=================================
Sub Medicineinstock()
Dim c As Range
Dim str As String
str = ""
With Worksheets("Purchases")
For Each c In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(c.Value) Then
If IsNumeric(c.Value) Then
If c.Value 0 Then
str = str & c.Offset(0, -6).Value & ","
End If
End If
End If
Next
str = Left(str, Len(str) - 1)
str = Left(str, 255)
End With
Debug.Print str
End Sub
'===============================

Gareth wrote:
If you enter the data validation source into the control it does work

(eg -
yes,no,maybe)

what I want to do is get the list of medicines in B2:B? which have 0 in
H2:H? into a data validation list.

Any ideas?

Gareth
"Bob Phillips" wrote in message
...

Gareth,

Data Validation doesn't trigger the Change event in 97, but what you

could
do is to set another cell linked to your data validation cell, and have

a
calculate event do the work for you. I used this technique to have

dynamic
data validation list in XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
.. .

My sheet ('Purchases') contains a list of medicines, the code below

provides

me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in stock").Range("A65536").End(xlUp).Offset(1,

0).Value

= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in stock and

apply

that list to the next 20 blank cells in column A on sheet 'Medicine

Record'.

My problem is that I want to have the Change Event of that sheet work

when

an item in the data validation list is picked and work has Excel '97

and

I

believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the control,

i

s

it

possible to do this by macro??

Thanks in advance.

Gareth








--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Validation list using code

Gareth,

Can I just check exactly what you want to do?

You have a list of Purchases on one sheet.
You have a Data Validation cell linked to a list - where is that, is it just
one cell or many?
What do you want to do when the Data Validation is selected from?
Do you want the DV list to update automatically when you change purchases
(e.g. something may come in to/go out of stock)?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
...
Debra

Thanks for this, works just great. You are right about the 255 characters
causing a problem though.

Therefore, I would like to try Bob's suggestion of using a linked cell.
Unfortunately I have no idea how to go about it, could anyone please offer
any assistance?

Gareth

"Debra Dalgleish" wrote in message
...
It may not be a problem in your worksheet, but the delimited list has a
maximum of 255 characters:

'=================================
Sub Medicineinstock()
Dim c As Range
Dim str As String
str = ""
With Worksheets("Purchases")
For Each c In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(c.Value) Then
If IsNumeric(c.Value) Then
If c.Value 0 Then
str = str & c.Offset(0, -6).Value & ","
End If
End If
End If
Next
str = Left(str, Len(str) - 1)
str = Left(str, 255)
End With
Debug.Print str
End Sub
'===============================

Gareth wrote:
If you enter the data validation source into the control it does work

(eg -
yes,no,maybe)

what I want to do is get the list of medicines in B2:B? which have 0

in
H2:H? into a data validation list.

Any ideas?

Gareth
"Bob Phillips" wrote in message
...

Gareth,

Data Validation doesn't trigger the Change event in 97, but what you

could
do is to set another cell linked to your data validation cell, and

have
a
calculate event do the work for you. I used this technique to have

dynamic
data validation list in XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
.. .

My sheet ('Purchases') contains a list of medicines, the code below

provides

me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in stock").Range("A65536").End(xlUp).Offset(1,

0).Value

= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in stock

and

apply

that list to the next 20 blank cells in column A on sheet 'Medicine

Record'.

My problem is that I want to have the Change Event of that sheet work

when

an item in the data validation list is picked and work has Excel '97

and

I

believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the

control,
i

s

it

possible to do this by macro??

Thanks in advance.

Gareth








--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Validation list using code

The DV list is applied to column A (or 20 rows at the bottom of the column).

The list is updated before being created (the 0 bit of my macro). What I
want to do is use the change event to use vlookup to get two bits of data
from the Medicines sheet. I cannot use the vlookup formula, it has to be
done by code.

This is why I tried putting the list of medicines straight into the control
but with it having a 255 max of characters it causes a problem.

Hope you understand what I'm after.

Gareth
"Bob Phillips" wrote in message
...
Gareth,

Can I just check exactly what you want to do?

You have a list of Purchases on one sheet.
You have a Data Validation cell linked to a list - where is that, is it

just
one cell or many?
What do you want to do when the Data Validation is selected from?
Do you want the DV list to update automatically when you change purchases
(e.g. something may come in to/go out of stock)?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
...
Debra

Thanks for this, works just great. You are right about the 255

characters
causing a problem though.

Therefore, I would like to try Bob's suggestion of using a linked cell.
Unfortunately I have no idea how to go about it, could anyone please

offer
any assistance?

Gareth

"Debra Dalgleish" wrote in message
...
It may not be a problem in your worksheet, but the delimited list has

a
maximum of 255 characters:

'=================================
Sub Medicineinstock()
Dim c As Range
Dim str As String
str = ""
With Worksheets("Purchases")
For Each c In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(c.Value) Then
If IsNumeric(c.Value) Then
If c.Value 0 Then
str = str & c.Offset(0, -6).Value & ","
End If
End If
End If
Next
str = Left(str, Len(str) - 1)
str = Left(str, 255)
End With
Debug.Print str
End Sub
'===============================

Gareth wrote:
If you enter the data validation source into the control it does

work
(eg -
yes,no,maybe)

what I want to do is get the list of medicines in B2:B? which have

0
in
H2:H? into a data validation list.

Any ideas?

Gareth
"Bob Phillips" wrote in message
...

Gareth,

Data Validation doesn't trigger the Change event in 97, but what you

could
do is to set another cell linked to your data validation cell, and

have
a
calculate event do the work for you. I used this technique to have

dynamic
data validation list in XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
.. .

My sheet ('Purchases') contains a list of medicines, the code below

provides

me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in stock").Range("A65536").End(xlUp).Offset(1,

0).Value

= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in stock

and

apply

that list to the next 20 blank cells in column A on sheet 'Medicine

Record'.

My problem is that I want to have the Change Event of that sheet

work

when

an item in the data validation list is picked and work has Excel

'97
and

I

believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the

control,
i

s

it

possible to do this by macro??

Thanks in advance.

Gareth








--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Validation list using code

Gareth,

Have you got your 20 rows of DV aligned to the DV list? I am assuming you
have this, if not just post back.

To get a selection to trigger an event, I will just display values from
'Purchases' in a MsgBox. I think you will be able to use it as you need.

First, let's assume that the DV cells are in A41:A60. Setup links to these
cells somewhere off-stage so to speak.. For instance, in AZ41 input =A41.
This is to fire the Calculate event. Repeat down to A60.

Input this code in the 'Medicines in stock' worksheet code module.

Private Sub Worksheet_Calculate()
Dim sValue
Dim oFind As Range

sValue = ActiveCell.Value
Set oFind = Worksheets("Purchases").Columns(1).Find(sValue)
If oFind Is Nothing Then
MsgBox "Something's wrong!"
Else
MsgBox "Value " & sValue & vbCrLf & _
"Column 2 is " & oFind.Offset(0, 1).Value & vbCrLf & _
"Column 7 is " & oFind.Offset(0, 7).Value
End If

End Sub

Haven't tried this particular solution on XL97, although I have used the
technique before on XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
...
The DV list is applied to column A (or 20 rows at the bottom of the

column).

The list is updated before being created (the 0 bit of my macro). What I
want to do is use the change event to use vlookup to get two bits of data
from the Medicines sheet. I cannot use the vlookup formula, it has to be
done by code.

This is why I tried putting the list of medicines straight into the

control
but with it having a 255 max of characters it causes a problem.

Hope you understand what I'm after.

Gareth
"Bob Phillips" wrote in message
...
Gareth,

Can I just check exactly what you want to do?

You have a list of Purchases on one sheet.
You have a Data Validation cell linked to a list - where is that, is it

just
one cell or many?
What do you want to do when the Data Validation is selected from?
Do you want the DV list to update automatically when you change

purchases
(e.g. something may come in to/go out of stock)?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
...
Debra

Thanks for this, works just great. You are right about the 255

characters
causing a problem though.

Therefore, I would like to try Bob's suggestion of using a linked

cell.
Unfortunately I have no idea how to go about it, could anyone please

offer
any assistance?

Gareth

"Debra Dalgleish" wrote in message
...
It may not be a problem in your worksheet, but the delimited list

has
a
maximum of 255 characters:

'=================================
Sub Medicineinstock()
Dim c As Range
Dim str As String
str = ""
With Worksheets("Purchases")
For Each c In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(c.Value) Then
If IsNumeric(c.Value) Then
If c.Value 0 Then
str = str & c.Offset(0, -6).Value & ","
End If
End If
End If
Next
str = Left(str, Len(str) - 1)
str = Left(str, 255)
End With
Debug.Print str
End Sub
'===============================

Gareth wrote:
If you enter the data validation source into the control it does

work
(eg -
yes,no,maybe)

what I want to do is get the list of medicines in B2:B? which have

0
in
H2:H? into a data validation list.

Any ideas?

Gareth
"Bob Phillips" wrote in

message
...

Gareth,

Data Validation doesn't trigger the Change event in 97, but what

you
could
do is to set another cell linked to your data validation cell, and

have
a
calculate event do the work for you. I used this technique to have
dynamic
data validation list in XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
.. .

My sheet ('Purchases') contains a list of medicines, the code

below

provides

me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in

stock").Range("A65536").End(xlUp).Offset(1,

0).Value

= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in

stock
and

apply

that list to the next 20 blank cells in column A on sheet

'Medicine

Record'.

My problem is that I want to have the Change Event of that sheet

work

when

an item in the data validation list is picked and work has Excel

'97
and

I

believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the

control,
i

s

it

possible to do this by macro??

Thanks in advance.

Gareth








--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html









  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Validation list using code

Just found a basic flaw in the code. It is triggered by any change not just
the DV, so try this

Private Sub Worksheet_Calculate()
Dim sValue
Dim oFind As Range

If Not Intersect(ActiveCell, Range("A41:A60")) Is Nothing Then
sValue = ActiveCell.Value
Set oFind = Worksheets("Purchases").Columns(1).Find(sValue)
If oFind Is Nothing Then
MsgBox "Something's wrong!"
Else
MsgBox "Value " & sValue & vbCrLf & _
"Column 2 is " & oFind.Offset(0, 1).Value & vbCrLf & _
"Column 7 is " & oFind.Offset(0, 7).Value
End If
End If

End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
Gareth,

Have you got your 20 rows of DV aligned to the DV list? I am assuming you
have this, if not just post back.

To get a selection to trigger an event, I will just display values from
'Purchases' in a MsgBox. I think you will be able to use it as you need.

First, let's assume that the DV cells are in A41:A60. Setup links to these
cells somewhere off-stage so to speak.. For instance, in AZ41 input =A41.
This is to fire the Calculate event. Repeat down to A60.

Input this code in the 'Medicines in stock' worksheet code module.

Private Sub Worksheet_Calculate()
Dim sValue
Dim oFind As Range

sValue = ActiveCell.Value
Set oFind = Worksheets("Purchases").Columns(1).Find(sValue)
If oFind Is Nothing Then
MsgBox "Something's wrong!"
Else
MsgBox "Value " & sValue & vbCrLf & _
"Column 2 is " & oFind.Offset(0, 1).Value & vbCrLf & _
"Column 7 is " & oFind.Offset(0, 7).Value
End If

End Sub

Haven't tried this particular solution on XL97, although I have used the
technique before on XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
...
The DV list is applied to column A (or 20 rows at the bottom of the

column).

The list is updated before being created (the 0 bit of my macro). What

I
want to do is use the change event to use vlookup to get two bits of

data
from the Medicines sheet. I cannot use the vlookup formula, it has to

be
done by code.

This is why I tried putting the list of medicines straight into the

control
but with it having a 255 max of characters it causes a problem.

Hope you understand what I'm after.

Gareth
"Bob Phillips" wrote in message
...
Gareth,

Can I just check exactly what you want to do?

You have a list of Purchases on one sheet.
You have a Data Validation cell linked to a list - where is that, is

it
just
one cell or many?
What do you want to do when the Data Validation is selected from?
Do you want the DV list to update automatically when you change

purchases
(e.g. something may come in to/go out of stock)?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
...
Debra

Thanks for this, works just great. You are right about the 255

characters
causing a problem though.

Therefore, I would like to try Bob's suggestion of using a linked

cell.
Unfortunately I have no idea how to go about it, could anyone please

offer
any assistance?

Gareth

"Debra Dalgleish" wrote in message
...
It may not be a problem in your worksheet, but the delimited list

has
a
maximum of 255 characters:

'=================================
Sub Medicineinstock()
Dim c As Range
Dim str As String
str = ""
With Worksheets("Purchases")
For Each c In .Range("H2:H" & .Range("H65536").End(xlUp).Row)
If Not IsEmpty(c.Value) Then
If IsNumeric(c.Value) Then
If c.Value 0 Then
str = str & c.Offset(0, -6).Value & ","
End If
End If
End If
Next
str = Left(str, Len(str) - 1)
str = Left(str, 255)
End With
Debug.Print str
End Sub
'===============================

Gareth wrote:
If you enter the data validation source into the control it does

work
(eg -
yes,no,maybe)

what I want to do is get the list of medicines in B2:B? which

have
0
in
H2:H? into a data validation list.

Any ideas?

Gareth
"Bob Phillips" wrote in

message
...

Gareth,

Data Validation doesn't trigger the Change event in 97, but what

you
could
do is to set another cell linked to your data validation cell,

and
have
a
calculate event do the work for you. I used this technique to

have
dynamic
data validation list in XL97.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gareth" wrote in message
.. .

My sheet ('Purchases') contains a list of medicines, the code

below

provides

me with a list of medicines which haven't run out.

The list is put in column A on the 'Medicine in stock' sheet.

Sub Medicineinstock()
With Worksheets("Purchases")
For Each cell In .Range("H2:H" &

..Range("H65536").End(xlUp).Row)
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
If cell.Value 0 Then
Worksheets("Medicine in

stock").Range("A65536").End(xlUp).Offset(1,

0).Value

= cell.Offset(0, -6).Value
End If
End If
End If
Next
End With
End Sub

I want to make a data validation list out of the medicine in

stock
and

apply

that list to the next 20 blank cells in column A on sheet

'Medicine

Record'.

My problem is that I want to have the Change Event of that

sheet
work

when

an item in the data validation list is picked and work has

Excel
'97
and

I

believe it doesn't 'fire' in '97.

A previos workaround was to enter the items directly into the
control,
i

s

it

possible to do this by macro??

Thanks in advance.

Gareth








--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html











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
How do I get a Data validation list to select another validation l langston35 New Users to Excel 1 September 28th 09 08:38 AM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
data validation invalid in dynamic validation list ilia Excel Worksheet Functions 0 November 7th 06 12:54 PM
validation list--list depends on the selection of first list Michael New Users to Excel 2 April 27th 06 10:23 PM


All times are GMT +1. The time now is 11:26 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"