Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

I am trying to write a data validation in VBA. I know I have the code right
but I can't get it to work. It works fine if the validation was done dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be with
the " Formula1:=" line. I have been scratching my head for the past 24hrs now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Data Validation Help Needed urgently !!!!!!!!!!!

I'd not tried your code, but if it were me, I'd create a workbook level named
range based on this offset formula

=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

Then I'd enter CTRL G and type in the range name to see if it really exists.
Then, based on that, I'd update the validation list.
--
HTH,

Barb Reinhardt



"Ayo" wrote:

I am trying to write a data validation in VBA. I know I have the code right
but I can't get it to work. It works fine if the validation was done dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be with
the " Formula1:=" line. I have been scratching my head for the past 24hrs now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

I have the workbook level named ranges created here in this sub:

Sub defineRANGES()
Dim lRow As Long
lRow = Worksheets("Sites Task List").Cells(Rows.Count, "A").End(xlUp).Row

If lRow 2 Then
ThisWorkbook.Names.Add Name:="MarketStart", _
RefersTo:=Worksheets("Sites Task List").Range("A1")
ThisWorkbook.Names.Add Name:="Markets", _
RefersTo:=Worksheets("Sites Task List").Range("A:A")

ThisWorkbook.Names.Add Name:="SiteStart", _
RefersTo:=Worksheets("Sites Task List").Range("B1")
ThisWorkbook.Names.Add Name:="Sites", _
RefersTo:=Worksheets("Sites Task List").Range("B:B")
End If
End Sub

"Barb Reinhardt" wrote:

I'd not tried your code, but if it were me, I'd create a workbook level named
range based on this offset formula

=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

Then I'd enter CTRL G and type in the range name to see if it really exists.
Then, based on that, I'd update the validation list.
--
HTH,

Barb Reinhardt



"Ayo" wrote:

I am trying to write a data validation in VBA. I know I have the code right
but I can't get it to work. It works fine if the validation was done dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be with
the " Formula1:=" line. I have been scratching my head for the past 24hrs now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Data Validation Help Needed urgently !!!!!!!!!!!

Again, I say manually create a named range using your formula below
=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

If the value of COUNTIF(Markets,B20) = ZERO, the range won't work.


Let's look at the offset formula

=OFFSET(REFERENCE,ROWS,COLUMNS,[HEIGHT], [WIDTH])

[HEIGHT] or [WIDTH] need to be positive non-zero values for the offset
equation to work. Trust me, try creating a named range using the OFFSET
(manually) to see what the result is. Once you've got the range, type CTRL
G and the range name to see what is selected. I bet you have a problem with
[HEIGHT] or your MATCH piece.

--
HTH,

Barb Reinhardt



"Ayo" wrote:

I have the workbook level named ranges created here in this sub:

Sub defineRANGES()
Dim lRow As Long
lRow = Worksheets("Sites Task List").Cells(Rows.Count, "A").End(xlUp).Row

If lRow 2 Then
ThisWorkbook.Names.Add Name:="MarketStart", _
RefersTo:=Worksheets("Sites Task List").Range("A1")
ThisWorkbook.Names.Add Name:="Markets", _
RefersTo:=Worksheets("Sites Task List").Range("A:A")

ThisWorkbook.Names.Add Name:="SiteStart", _
RefersTo:=Worksheets("Sites Task List").Range("B1")
ThisWorkbook.Names.Add Name:="Sites", _
RefersTo:=Worksheets("Sites Task List").Range("B:B")
End If
End Sub

"Barb Reinhardt" wrote:

I'd not tried your code, but if it were me, I'd create a workbook level named
range based on this offset formula

=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

Then I'd enter CTRL G and type in the range name to see if it really exists.
Then, based on that, I'd update the validation list.
--
HTH,

Barb Reinhardt



"Ayo" wrote:

I am trying to write a data validation in VBA. I know I have the code right
but I can't get it to work. It works fine if the validation was done dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be with
the " Formula1:=" line. I have been scratching my head for the past 24hrs now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With

  #5   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

The problem I am having really is this: when I run this sub:
Private Sub Worksheet_Activate()
Rows("5:19").Hidden = True
Range("B20") = ""
Range("B3") = ""
Range("E3") = ""
Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween,

Formula1:="OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)"
End With

Range("E3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween,
Formula1:="OFFSET(SiteStart,MATCH(B3,Sites,0)-1,1,COUNTIF(Sites,B3),1)"
End With
End Sub

If I left the formula1 line like this:
Formula1:="OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)"
the code seem to work except when I look in the validation
range,Range("B3:C3"), and all I see is
OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1) not the
list of sites that I expect.

But when I write the formula1 line like this:
Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
I get a error.

"Barb Reinhardt" wrote:

Again, I say manually create a named range using your formula below
=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

If the value of COUNTIF(Markets,B20) = ZERO, the range won't work.


Let's look at the offset formula

=OFFSET(REFERENCE,ROWS,COLUMNS,[HEIGHT], [WIDTH])

[HEIGHT] or [WIDTH] need to be positive non-zero values for the offset
equation to work. Trust me, try creating a named range using the OFFSET
(manually) to see what the result is. Once you've got the range, type CTRL
G and the range name to see what is selected. I bet you have a problem with
[HEIGHT] or your MATCH piece.

--
HTH,

Barb Reinhardt



"Ayo" wrote:

I have the workbook level named ranges created here in this sub:

Sub defineRANGES()
Dim lRow As Long
lRow = Worksheets("Sites Task List").Cells(Rows.Count, "A").End(xlUp).Row

If lRow 2 Then
ThisWorkbook.Names.Add Name:="MarketStart", _
RefersTo:=Worksheets("Sites Task List").Range("A1")
ThisWorkbook.Names.Add Name:="Markets", _
RefersTo:=Worksheets("Sites Task List").Range("A:A")

ThisWorkbook.Names.Add Name:="SiteStart", _
RefersTo:=Worksheets("Sites Task List").Range("B1")
ThisWorkbook.Names.Add Name:="Sites", _
RefersTo:=Worksheets("Sites Task List").Range("B:B")
End If
End Sub

"Barb Reinhardt" wrote:

I'd not tried your code, but if it were me, I'd create a workbook level named
range based on this offset formula

=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

Then I'd enter CTRL G and type in the range name to see if it really exists.
Then, based on that, I'd update the validation list.
--
HTH,

Barb Reinhardt



"Ayo" wrote:

I am trying to write a data validation in VBA. I know I have the code right
but I can't get it to work. It works fine if the validation was done dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be with
the " Formula1:=" line. I have been scratching my head for the past 24hrs now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Data Validation Help Needed urgently !!!!!!!!!!!

Try adding this code and tell us what happens?

ThisWorkbook.Names.Add Name:="myList", _
RefersToR1C1:= _
"=OFFSET(MarketStart,MATCH(Sheet1!R2C20,Market s,0)-1,1,COUNTIF(Markets,Sheet1!R2C20),1)"

on error resume next
debug.print range("myList").address

if err < 0 then
Msgbox("There is an error in the named range")
end if
on error goto 0


--
HTH,

Barb Reinhardt



"Ayo" wrote:

I have the workbook level named ranges created here in this sub:

Sub defineRANGES()
Dim lRow As Long
lRow = Worksheets("Sites Task List").Cells(Rows.Count, "A").End(xlUp).Row

If lRow 2 Then
ThisWorkbook.Names.Add Name:="MarketStart", _
RefersTo:=Worksheets("Sites Task List").Range("A1")
ThisWorkbook.Names.Add Name:="Markets", _
RefersTo:=Worksheets("Sites Task List").Range("A:A")

ThisWorkbook.Names.Add Name:="SiteStart", _
RefersTo:=Worksheets("Sites Task List").Range("B1")
ThisWorkbook.Names.Add Name:="Sites", _
RefersTo:=Worksheets("Sites Task List").Range("B:B")
End If
End Sub

"Barb Reinhardt" wrote:

I'd not tried your code, but if it were me, I'd create a workbook level named
range based on this offset formula

=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

Then I'd enter CTRL G and type in the range name to see if it really exists.
Then, based on that, I'd update the validation list.
--
HTH,

Barb Reinhardt



"Ayo" wrote:

I am trying to write a data validation in VBA. I know I have the code right
but I can't get it to work. It works fine if the validation was done dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be with
the " Formula1:=" line. I have been scratching my head for the past 24hrs now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With

  #7   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

I get a "Method 'Range' of object '_Worksheet' failed" error on:
Debug.Print Range("myList").Address

"Barb Reinhardt" wrote:

Try adding this code and tell us what happens?

ThisWorkbook.Names.Add Name:="myList", _
RefersToR1C1:= _
"=OFFSET(MarketStart,MATCH(Sheet1!R2C20,Market s,0)-1,1,COUNTIF(Markets,Sheet1!R2C20),1)"

on error resume next
debug.print range("myList").address

if err < 0 then
Msgbox("There is an error in the named range")
end if
on error goto 0


--
HTH,

Barb Reinhardt



"Ayo" wrote:

I have the workbook level named ranges created here in this sub:

Sub defineRANGES()
Dim lRow As Long
lRow = Worksheets("Sites Task List").Cells(Rows.Count, "A").End(xlUp).Row

If lRow 2 Then
ThisWorkbook.Names.Add Name:="MarketStart", _
RefersTo:=Worksheets("Sites Task List").Range("A1")
ThisWorkbook.Names.Add Name:="Markets", _
RefersTo:=Worksheets("Sites Task List").Range("A:A")

ThisWorkbook.Names.Add Name:="SiteStart", _
RefersTo:=Worksheets("Sites Task List").Range("B1")
ThisWorkbook.Names.Add Name:="Sites", _
RefersTo:=Worksheets("Sites Task List").Range("B:B")
End If
End Sub

"Barb Reinhardt" wrote:

I'd not tried your code, but if it were me, I'd create a workbook level named
range based on this offset formula

=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

Then I'd enter CTRL G and type in the range name to see if it really exists.
Then, based on that, I'd update the validation list.
--
HTH,

Barb Reinhardt



"Ayo" wrote:

I am trying to write a data validation in VBA. I know I have the code right
but I can't get it to work. It works fine if the validation was done dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be with
the " Formula1:=" line. I have been scratching my head for the past 24hrs now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Data Validation Help Needed urgently !!!!!!!!!!!

OK then. What that tells me is that the range myList may not exist. Now I
need to know this

What is the address for the range MarketStart? Include worksheet
What is the value for MATCH(B20,Markets,0) - 1
What is the value for COUNTIF(Markets,B20)

I bet one or both of the last two is an error or 0.

--
HTH,

Barb Reinhardt



"Barb Reinhardt" wrote:

Try adding this code and tell us what happens?

ThisWorkbook.Names.Add Name:="myList", _
RefersToR1C1:= _
"=OFFSET(MarketStart,MATCH(Sheet1!R2C20,Market s,0)-1,1,COUNTIF(Markets,Sheet1!R2C20),1)"

on error resume next
debug.print range("myList").address

if err < 0 then
Msgbox("There is an error in the named range")
end if
on error goto 0


--
HTH,

Barb Reinhardt



"Ayo" wrote:

I have the workbook level named ranges created here in this sub:

Sub defineRANGES()
Dim lRow As Long
lRow = Worksheets("Sites Task List").Cells(Rows.Count, "A").End(xlUp).Row

If lRow 2 Then
ThisWorkbook.Names.Add Name:="MarketStart", _
RefersTo:=Worksheets("Sites Task List").Range("A1")
ThisWorkbook.Names.Add Name:="Markets", _
RefersTo:=Worksheets("Sites Task List").Range("A:A")

ThisWorkbook.Names.Add Name:="SiteStart", _
RefersTo:=Worksheets("Sites Task List").Range("B1")
ThisWorkbook.Names.Add Name:="Sites", _
RefersTo:=Worksheets("Sites Task List").Range("B:B")
End If
End Sub

"Barb Reinhardt" wrote:

I'd not tried your code, but if it were me, I'd create a workbook level named
range based on this offset formula

=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)

Then I'd enter CTRL G and type in the range name to see if it really exists.
Then, based on that, I'd update the validation list.
--
HTH,

Barb Reinhardt



"Ayo" wrote:

I am trying to write a data validation in VBA. I know I have the code right
but I can't get it to work. It works fine if the validation was done dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be with
the " Formula1:=" line. I have been scratching my head for the past 24hrs now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Data Validation Help Needed urgently !!!!!!!!!!!

For data validation you need your formula to return a True/False
value.

An example would be setting your formula to SPX:
=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),
1)="SPX"

-Brian
  #10   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

Thanks Brian, but I don't understand the SPX statement you wrote. Is there a
way you can explain further.

"Brian B." wrote:

For data validation you need your formula to return a True/False
value.

An example would be setting your formula to SPX:
=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),
1)="SPX"

-Brian
.



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Data Validation Help Needed urgently !!!!!!!!!!!

The "SPX" was, to quote Brian, an example. The key thing you were supposed
to take from his statement is the need to assign a logical expression the
evaluates to TRUE or FALSE... your original OFFSET statement did not do
this... testing it for some return value, such as a text string like "SPX",
will do that.

--
Rick (MVP - Excel)



"Ayo" wrote in message
...
Thanks Brian, but I don't understand the SPX statement you wrote. Is there
a
way you can explain further.

"Brian B." wrote:

For data validation you need your formula to return a True/False
value.

An example would be setting your formula to SPX:
=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),
1)="SPX"

-Brian
.

  #12   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

Rick,
Thanks for the input but my issue is still the same. I can't seem to be
able to get my point across. This gives an error "=OFFSET" and this doesn't
"OFFSET". But the one without the error still doesn't give me the list just
the string "OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),
1)" in a list form.

I think it's better if I send you the file, about 1MB, so you can see what I
am talking about.

"Rick Rothstein" wrote:

The "SPX" was, to quote Brian, an example. The key thing you were supposed
to take from his statement is the need to assign a logical expression the
evaluates to TRUE or FALSE... your original OFFSET statement did not do
this... testing it for some return value, such as a text string like "SPX",
will do that.

--
Rick (MVP - Excel)



"Ayo" wrote in message
...
Thanks Brian, but I don't understand the SPX statement you wrote. Is there
a
way you can explain further.

"Brian B." wrote:

For data validation you need your formula to return a True/False
value.

An example would be setting your formula to SPX:
=OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),
1)="SPX"

-Brian
.

.

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Data Validation Help Needed urgently !!!!!!!!!!!


I think you are missing double quotes around the strings

from
Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"

to
Formula1:="=OFFSET(MarketStart,MATCH(B20,""Markets "",0)-1,1,COUNTIF(""Markets"",B20),1)"


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=193665

http://www.thecodecage.com/forumz

  #14   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

Thanks Joel. The problem I am getting seem to be with the "=" before the
OFFSET. When I write it like this:
Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
I get an error. But when I write it like this:
Formula1:="OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)"
I don't get an error but there is no list in the cell I am trying to validate.

"joel" wrote:


I think you are missing double quotes around the strings

from
Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"

to
Formula1:="=OFFSET(MarketStart,MATCH(B20,""Markets "",0)-1,1,COUNTIF(""Markets"",B20),1)"


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=193665

http://www.thecodecage.com/forumz

.

  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Data Validation Help Needed urgently !!!!!!!!!!!

Try removing the equal sign inside the quotation marks.



"Ayo" wrote in message
...
I am trying to write a data validation in VBA. I know I have the code
right
but I can't get it to work. It works fine if the validation was done
dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be
with
the " Formula1:=" line. I have been scratching my head for the past 24hrs
now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With





  #16   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

Whan I do that I get the following lines in my cell as my dropdown list.
OFFSET(MarketStart
MATCH(B20
Markets
0)-1
1COUNTIF(Markets
B20)
1)

"JLGWhiz" wrote:

Try removing the equal sign inside the quotation marks.



"Ayo" wrote in message
...
I am trying to write a data validation in VBA. I know I have the code
right
but I can't get it to work. It works fine if the validation was done
dirctly
in excel but I get an error when I try the same thing in VBA. Below is a
snippet of the code I am having a problem with. The problem seem to be
with
the " Formula1:=" line. I have been scratching my head for the past 24hrs
now
trying to figure this out and I am still not coming up with anything. Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With



.

  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Data Validation Help Needed urgently !!!!!!!!!!!

1. What are you expecting to see in the validation list?
2. Can you use VBA code to produce the same result?


"Ayo" wrote in message
...
Whan I do that I get the following lines in my cell as my dropdown list.
OFFSET(MarketStart
MATCH(B20
Markets
0)-1
1COUNTIF(Markets
B20)
1)

"JLGWhiz" wrote:

Try removing the equal sign inside the quotation marks.



"Ayo" wrote in message
...
I am trying to write a data validation in VBA. I know I have the code
right
but I can't get it to work. It works fine if the validation was done
dirctly
in excel but I get an error when I try the same thing in VBA. Below is
a
snippet of the code I am having a problem with. The problem seem to be
with
the " Formula1:=" line. I have been scratching my head for the past
24hrs
now
trying to figure this out and I am still not coming up with anything.
Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With



.



  #18   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Data Validation Help Needed urgently !!!!!!!!!!!

I was expecting a list of numbers.
When I check the validation after run the code, I see:
OFFSET(MarketStart,MATCH(B20,Markets,0)-1,1,COUNTIF(Markets,B20),1)
and when I insert the "=" in front of "OFFSET", I get the result that I
wanted. But when I use it in the code:
Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
I get an error.

"JLGWhiz" wrote:

1. What are you expecting to see in the validation list?
2. Can you use VBA code to produce the same result?


"Ayo" wrote in message
...
Whan I do that I get the following lines in my cell as my dropdown list.
OFFSET(MarketStart
MATCH(B20
Markets
0)-1
1COUNTIF(Markets
B20)
1)

"JLGWhiz" wrote:

Try removing the equal sign inside the quotation marks.



"Ayo" wrote in message
...
I am trying to write a data validation in VBA. I know I have the code
right
but I can't get it to work. It works fine if the validation was done
dirctly
in excel but I get an error when I try the same thing in VBA. Below is
a
snippet of the code I am having a problem with. The problem seem to be
with
the " Formula1:=" line. I have been scratching my head for the past
24hrs
now
trying to figure this out and I am still not coming up with anything.
Any
help will be greatly appreciated.

Range("B3:C3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, _

Formula1:="=OFFSET(MarketStart,MATCH(B20,Markets,0 )-1,1,COUNTIF(Markets,B20),1)"
End With


.



.

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
Help needed urgently AndyW Excel Worksheet Functions 4 May 30th 10 05:07 PM
Help needed urgently..:( harveen Excel Worksheet Functions 8 February 10th 09 09:19 PM
help needed urgently wardah Excel Worksheet Functions 2 October 4th 06 12:02 PM
I'm a newbie, urgently help needed eileen Excel Programming 2 February 1st 06 05:23 PM
Help Needed Urgently John Excel Worksheet Functions 2 September 13th 05 02:58 PM


All times are GMT +1. The time now is 10:57 PM.

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

About Us

"It's about Microsoft Excel"