Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I wamt to make third option button where is possible to choose both horse
and pig. Whta I need to change in my code? If .OptionButton1 Then sOne = "Horse" Else sOne = "Pig" |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is it on a userform? If so, then
If Me.OptionButton1.Value Then sOne = "Horse" Else sOne = "Pig" End If -- HTH RP (remove nothere from the email address if mailing direct) "Alen32" wrote in message lkaboutsoftware.com... I wamt to make third option button where is possible to choose both horse and pig. Whta I need to change in my code? If .OptionButton1 Then sOne = "Horse" Else sOne = "Pig" |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have 3 optionbutton 1.Horse 2.Pig 3.Both This work only for first 2 buttons. What to change so third one also work? If Me.OptionButton1.Value Then sOne = "Horse" Else sOne = "Pig" End If |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you mean
If Me.OptionButton1.Value Then sOne = "Horse" ElseIf Me.Optionbutton2.Value Then sOne = "Pig" ElseIf Me.Optionbutton3.Value sOne = "Horse & Pig" End If -- HTH RP (remove nothere from the email address if mailing direct) "Alen32" wrote in message lkaboutsoftware.com... I have 3 optionbutton 1.Horse 2.Pig 3.Both This work only for first 2 buttons. What to change so third one also work? If Me.OptionButton1.Value Then sOne = "Horse" Else sOne = "Pig" End If |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
sorry I have difuculties to explain in english what I want. I got this code
here which works well. Now I want to make third optionbutton where user can choose both horse and pig. That means program should look for either horse or pig in the samme row. and if program find either horse or pig in one row + sTwo and Sthree insert that row in listbox. With UserForm1 If Me.OptionButton1.Value Then sOne = "Horse" ElseIf Me.OptionButton2.Value Then sOne = "Pig" ?????ElseIf Me.OptionButton5.Value Then sOne = "Horse Or Pig" ???????? End If If .OptionButton3 Then sTwo = "Danish" Else sTwo = "Foreign" End If sThree = .TextBox1.Text End With With Worksheets(1).Cells Set c = .Find(sOne, LookIn:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do If Application.CountIf(c.EntireRow, "*" & sTwo & "*") And _ Application.CountIf(c.EntireRow, "*" & sThree & "*") Then UserForm1.ListBox1.AddItem c.Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 1) _ = c.Offset(0, 2).Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 2) _ = c.Offset(0, 5).Value End If Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End With |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about this
With UserForm1 If .OptionButton1.Value Then sOne = "Horse" sOnePlus = "" ElseIf .OptionButton2.Value Then sOne = "Pig" sOnePlus = "" ElseIf .OptionButton5.Value Then sOne = "Horse" sOnePlus = "Pig" End If If .OptionButton3 Then stwo = "Danish" Else stwo = "Foreign" End If sThree = .TextBox1.Text End With With Worksheets(1).Cells Set c = Nothing Set c = .Find(sOne, LookIn:=xlValues) If c Is Nothing And stwo < "" Then Set c = .Find(sOnePlus, LookIn:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do If Application.CountIf(c.EntireRow, "*" & stwo & "*") And _ Application.CountIf(c.EntireRow, "*" & sThree & "*") Then UserForm1.ListBox1.AddItem c.Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 1) _ = c.Offset(0, 2).Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 2) _ = c.Offset(0, 5).Value End If Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End If End With -- HTH RP (remove nothere from the email address if mailing direct) "Alen32" wrote in message lkaboutsoftware.com... sorry I have difuculties to explain in english what I want. I got this code here which works well. Now I want to make third optionbutton where user can choose both horse and pig. That means program should look for either horse or pig in the samme row. and if program find either horse or pig in one row + sTwo and Sthree insert that row in listbox. With UserForm1 If Me.OptionButton1.Value Then sOne = "Horse" ElseIf Me.OptionButton2.Value Then sOne = "Pig" ?????ElseIf Me.OptionButton5.Value Then sOne = "Horse Or Pig" ???????? End If If .OptionButton3 Then sTwo = "Danish" Else sTwo = "Foreign" End If sThree = .TextBox1.Text End With With Worksheets(1).Cells Set c = .Find(sOne, LookIn:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do If Application.CountIf(c.EntireRow, "*" & sTwo & "*") And _ Application.CountIf(c.EntireRow, "*" & sThree & "*") Then UserForm1.ListBox1.AddItem c.Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 1) _ = c.Offset(0, 2).Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 2) _ = c.Offset(0, 5).Value End If Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End With |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This makro doesn't fill listbox.
|
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, my fault
With UserForm1 If .OptionButton1.Value Then sOne = "Horse" sOnePlus = "" ElseIf .OptionButton2.Value Then sOne = "Pig" sOnePlus = "" ElseIf .OptionButton5.Value Then sOne = "Horse" sOnePlus = "Pig" End If If .OptionButton3 Then stwo = "Danish" Else stwo = "Foreign" End If sThree = .TextBox1.Text End With With Worksheets(1).Cells Set c = Nothing Set c = .Find(sOne, LookIn:=xlValues) If c Is Nothing And stwo < "" Then Set c = .Find(sOnePlus, LookIn:=xlValues) End If If Not c Is Nothing Then firstAddress = c.Address Do If Application.CountIf(c.EntireRow, "*" & stwo & "*") And _ Application.CountIf(c.EntireRow, "*" & sThree & "*") Then UserForm1.ListBox1.AddItem c.Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 1) _ = c.Offset(0, 2).Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 2) _ = c.Offset(0, 5).Value End If Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End With -- HTH RP (remove nothere from the email address if mailing direct) "Alen32" wrote in message lkaboutsoftware.com... This makro doesn't fill listbox. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok now is much better first and third optionsbottons work but when I select
second optionbotton then I get error message Aplication-defined or object-defined error and this piece of code get yellow UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 2) _ = c.Offset(0, 5).Value |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can't reproduce the error Alen.
What data are you checking when you get this? -- HTH RP (remove nothere from the email address if mailing direct) "Alen32" wrote in message lkaboutsoftware.com... Ok now is much better first and third optionsbottons work but when I select second optionbotton then I get error message Aplication-defined or object-defined error and this piece of code get yellow UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 2) _ = c.Offset(0, 5).Value |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When I search for pig and pig doesn't exist on sheet. it should be just
empty listbox. |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Also third optionbutton doesn't work in case where I have both pig and
horse in column. Only horse is inserted into listbox and not pig. |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There are two problems in Makro:
1) Third optionbutton doesn't work in case where I have both pig and horse in column. Only horse is inserted into listbox and not pig. 2) When I search for pig and pig doesn't exist on sheet it comes error message. it should be just empty listbox. |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I got answer :
Private Sub CommandButton1_Click() Dim sOne, sOneItem With UserForm1 '****** If .OptionButton1 Then sOne = Array("Horse") If .OptionButton2 Then sOne = Array("Pig") If .OptionButton5 Then sOne = Array("Horse", "Pig") '****** If .OptionButton3 Then sTwo = "Danish" Else sTwo = "Foreign" End If sThree = .TextBox1.Text End With '****** For Each sOneItem In sOne '****** 'MsgBox sOneItem With Worksheets(1).Cells Set c = .Find(sOneItem, LookIn:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do If Application.CountIf(c.EntireRow, "*" & sTwo & "*") And _ Application.CountIf(c.EntireRow, "*" & sThree & "*") Then UserForm1.ListBox1.AddItem c.Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 1) _ = c.Offset(0, 2).Value UserForm1.ListBox1.List( _ UserForm1.ListBox1.ListCount - 1, 2) _ = c.Offset(0, 5).Value End If Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End With '****** Next '****** End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
keep source formatting is not an option in paste option button | Excel Discussion (Misc queries) | |||
Getting value of Option button | Excel Discussion (Misc queries) | |||
Option Button | Excel Discussion (Misc queries) | |||
Option Button Value | Excel Programming | |||
VBA - Option Button | Excel Programming |