Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Data Validation If statement moved to userform

I currently have a worksheet that uses a Data validation List called
"counties". When the user selects a "county" the following code runs on the
sheet.
'(Target.Row/Column is C3, on countyselect sheet)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 3 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End If
End Sub

I used the code from one of contexures.com files.
It populates the current sheet at location B40 with information from another
sheet called ("Places") Based on which county the users selected.

My Goal is to put this onto the userform I have in the workbook. Thus far I
have created the combobox on the userform, and I used the Rowsource
properties to populate the combobox. Counties!A1:A25 (a sheet with the
listings).

I have moved part of the code over to the userform combobox, but of course
nothing happens for me. I don't program alot in vba, but use examples of code
to achive my task.
How do I get the combobox to do the same thing that is taking place on the
worksheet when "C3" is changed.

Private Sub cboCountySelect_Change()

End Sub

Thanks very much, I appreciate your efforts in helping me.
thom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Data Validation If statement moved to userform

Untested

Private Sub Combobox1_Click()
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

but I don't see where cell C3 comes into play?

--
HTH

Bob Phillips

"thom hoyle" wrote in message
...
I currently have a worksheet that uses a Data validation List called
"counties". When the user selects a "county" the following code runs on

the
sheet.
'(Target.Row/Column is C3, on countyselect sheet)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 3 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End If
End Sub

I used the code from one of contexures.com files.
It populates the current sheet at location B40 with information from

another
sheet called ("Places") Based on which county the users selected.

My Goal is to put this onto the userform I have in the workbook. Thus far

I
have created the combobox on the userform, and I used the Rowsource
properties to populate the combobox. Counties!A1:A25 (a sheet with the
listings).

I have moved part of the code over to the userform combobox, but of course
nothing happens for me. I don't program alot in vba, but use examples of

code
to achive my task.
How do I get the combobox to do the same thing that is taking place on the
worksheet when "C3" is changed.

Private Sub cboCountySelect_Change()

End Sub

Thanks very much, I appreciate your efforts in helping me.
thom



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Data Validation If statement moved to userform

Hi Bob.
I tried you code, nothing seems to be happening.
would you mind if I sent you the file? U may email me At

I will reply with file.

thanks

"Bob Phillips" wrote:

Untested

Private Sub Combobox1_Click()
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

but I don't see where cell C3 comes into play?

--
HTH

Bob Phillips

"thom hoyle" wrote in message
...
I currently have a worksheet that uses a Data validation List called
"counties". When the user selects a "county" the following code runs on

the
sheet.
'(Target.Row/Column is C3, on countyselect sheet)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 3 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End If
End Sub

I used the code from one of contexures.com files.
It populates the current sheet at location B40 with information from

another
sheet called ("Places") Based on which county the users selected.

My Goal is to put this onto the userform I have in the workbook. Thus far

I
have created the combobox on the userform, and I used the Rowsource
properties to populate the combobox. Counties!A1:A25 (a sheet with the
listings).

I have moved part of the code over to the userform combobox, but of course
nothing happens for me. I don't program alot in vba, but use examples of

code
to achive my task.
How do I get the combobox to do the same thing that is taking place on the
worksheet when "C3" is changed.

Private Sub cboCountySelect_Change()

End Sub

Thanks very much, I appreciate your efforts in helping me.
thom




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Data Validation If statement moved to userform

Since everything appears to be based on having the value in C3 of the sheet
CountySelect, then you need to put it there.
Private Sub Combobox1_Click()
Worksheets("CountySelect").Range("C3").Value = Combobox1.Value
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

Otherwise you need to change you approach, such as putting it directly in G2

Private Sub Combobox1_Click()
Worksheets("Places").Range("G2").Value = Combobox1.Value
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

--
Regards,
Tom Ogilvy


"thom hoyle" wrote in message
...
Hi Bob.
I tried you code, nothing seems to be happening.
would you mind if I sent you the file? U may email me At

I will reply with file.

thanks

"Bob Phillips" wrote:

Untested

Private Sub Combobox1_Click()
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

but I don't see where cell C3 comes into play?

--
HTH

Bob Phillips

"thom hoyle" wrote in message
...
I currently have a worksheet that uses a Data validation List called
"counties". When the user selects a "county" the following code runs

on
the
sheet.
'(Target.Row/Column is C3, on countyselect sheet)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 3 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End If
End Sub

I used the code from one of contexures.com files.
It populates the current sheet at location B40 with information from

another
sheet called ("Places") Based on which county the users selected.

My Goal is to put this onto the userform I have in the workbook. Thus

far
I
have created the combobox on the userform, and I used the Rowsource
properties to populate the combobox. Counties!A1:A25 (a sheet with the
listings).

I have moved part of the code over to the userform combobox, but of

course
nothing happens for me. I don't program alot in vba, but use examples

of
code
to achive my task.
How do I get the combobox to do the same thing that is taking place on

the
worksheet when "C3" is changed.

Private Sub cboCountySelect_Change()

End Sub

Thanks very much, I appreciate your efforts in helping me.
thom






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Data Validation If statement moved to userform

As I said, I failed to see where C3 comes into it. You don't use it at all
in the code you gave. You could simply set it to the selection from the
Combo (Worksheets("Places").Range("C3").Value = Combobox1.Value), but it
doesn't seem to drive anything. What do you do with it?

--
HTH

Bob Phillips

"thom hoyle" wrote in message
...
Hi Bob.
I tried you code, nothing seems to be happening.
would you mind if I sent you the file? U may email me At

I will reply with file.

thanks

"Bob Phillips" wrote:

Untested

Private Sub Combobox1_Click()
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

but I don't see where cell C3 comes into play?

--
HTH

Bob Phillips

"thom hoyle" wrote in message
...
I currently have a worksheet that uses a Data validation List called
"counties". When the user selects a "county" the following code runs

on
the
sheet.
'(Target.Row/Column is C3, on countyselect sheet)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 3 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End If
End Sub

I used the code from one of contexures.com files.
It populates the current sheet at location B40 with information from

another
sheet called ("Places") Based on which county the users selected.

My Goal is to put this onto the userform I have in the workbook. Thus

far
I
have created the combobox on the userform, and I used the Rowsource
properties to populate the combobox. Counties!A1:A25 (a sheet with the
listings).

I have moved part of the code over to the userform combobox, but of

course
nothing happens for me. I don't program alot in vba, but use examples

of
code
to achive my task.
How do I get the combobox to do the same thing that is taking place on

the
worksheet when "C3" is changed.

Private Sub cboCountySelect_Change()

End Sub

Thanks very much, I appreciate your efforts in helping me.
thom








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Data Validation If statement moved to userform

That worked great. Excellent.. Thanks for the reply so quickly.

thomas

"Tom Ogilvy" wrote:

Since everything appears to be based on having the value in C3 of the sheet
CountySelect, then you need to put it there.
Private Sub Combobox1_Click()
Worksheets("CountySelect").Range("C3").Value = Combobox1.Value
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

Otherwise you need to change you approach, such as putting it directly in G2

Private Sub Combobox1_Click()
Worksheets("Places").Range("G2").Value = Combobox1.Value
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

--
Regards,
Tom Ogilvy


"thom hoyle" wrote in message
...
Hi Bob.
I tried you code, nothing seems to be happening.
would you mind if I sent you the file? U may email me At

I will reply with file.

thanks

"Bob Phillips" wrote:

Untested

Private Sub Combobox1_Click()
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End Sub

but I don't see where cell C3 comes into play?

--
HTH

Bob Phillips

"thom hoyle" wrote in message
...
I currently have a worksheet that uses a Data validation List called
"counties". When the user selects a "county" the following code runs

on
the
sheet.
'(Target.Row/Column is C3, on countyselect sheet)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 3 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("Places").Range("G2").Calculate
Worksheets("Places").Range("PlacesDatabase") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Places").Range("G1:G2"), _
CopyToRange:=Range("B40:C40"), Unique:=False
End If
End Sub

I used the code from one of contexures.com files.
It populates the current sheet at location B40 with information from
another
sheet called ("Places") Based on which county the users selected.

My Goal is to put this onto the userform I have in the workbook. Thus

far
I
have created the combobox on the userform, and I used the Rowsource
properties to populate the combobox. Counties!A1:A25 (a sheet with the
listings).

I have moved part of the code over to the userform combobox, but of

course
nothing happens for me. I don't program alot in vba, but use examples

of
code
to achive my task.
How do I get the combobox to do the same thing that is taking place on

the
worksheet when "C3" is changed.

Private Sub cboCountySelect_Change()

End Sub

Thanks very much, I appreciate your efforts in helping me.
thom






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
Data Validation w/an If Statement Steve Excel Worksheet Functions 1 February 18th 09 05:00 PM
Data Validation w/If Statement Jeff Gross Excel Worksheet Functions 3 November 19th 07 11:52 PM
Data Validation Cell - Move to UserForm thom hoyle Excel Worksheet Functions 0 April 28th 05 12:23 AM
Using a Userform instead of Data Validation Knut Dahl Excel Programming 2 April 10th 05 11:02 AM
using the if statement with data validation GreenMonster[_2_] Excel Programming 2 March 16th 05 07:29 PM


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