LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default Help with applying code

Can someone please look over the code I have posted and please tell me why
its that when it is applied to my current project it will not work right. It
is suppose to work like this. When you select a value from combobox1 it
checks to see it it is on sheet1 column'A' and if it is return what ever
value matches that value to combobox2 from sheet2 column'B'. This is what
sheet 2 looks like.

column A column B
a 1
a 2
b 1
c 1
a 3

For ever "a" in column 'a' it is suppose to return the column 'B' value so
(1,2,3). Whuch works just fine in the test version, however when it is
applied to my project code it does not work right it return to combobox2 the
same values as combobox1 which is wrong. Here is the code from both my forms.

**My test from code**

Private Sub Cbo1_Change()
Application.EnableEvents = True

Dim S As String
Dim V As Variant
Dim J As Range
'catches user input and checks to see if it's
S = Me.Cbo1.Text
V = Application.Match(S, Worksheets("sheet1").Range("A1:A10"), 0)
If IsError(V) = True Then
frm1.Hide
frm2.Show
End If
If IsError(V) = False Then
With Me.Cbo2
..Clear
For Each J In Worksheets("test").Range("A1:A18")
If J.Text = S Then
..AddItem J(1, 2)
End If
Next J
..SetFocus
If .ListCount 0 Then
..ListIndex = 0
End If
End With
End If
End Sub

Private Sub UserForm_Initialize()
Cbo1.RowSource = Worksheets("sheet1").Range("A1:A10").Address(exter nal:=True)

End Sub

**My project form code**


Me.CkBox3.Value = False
Me.CboFire.Value = ""
Me.CboHealth.Value = ""
Me.CboReact.Value = ""
Me.CboSpec.Value = ""
Me.CboDisp.Value = ""
Me.TxtQuan.Value = ""
Me.TxtDate.Value = ""
ender:
MsgBox "Value not found"
End Sub

Private Sub CbxMfg_Change()
Dim S As String
Dim V As Variant
Dim J As Range
S = Me.CbxMfg.Text
V = Application.Match(S, Worksheets("MANCODE").Range("A2:A1000"), 0)
If IsError(V) = True Then
FrmProduct.Hide
FrmManu.Show
End If
If IsError(V) = False Then
With Me.CbxProd
' .Clear
For Each J In Worksheets("ProCode").Range("A2:A1000")
If J.Text = S Then
..AddItem J(1, 2)
End If
Next J
..SetFocus
If .ListCount 0 Then
..ListIndex = 0
End If
End With
End If
End Sub

Private Sub TxtDate_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
FrmCalendar.Show
End Sub

Private Sub UserForm_Initialize()
CbxMfg.RowSource =
Worksheets("MANCODE").Range("A2:A1000").Address(ex ternal:=True)
'CboFire.RowSource =
Worksheets("Lists").Range("D2:D5").Address(externa l:=True)
'CboHealth.RowSource =
Worksheets("Lists").Range("D2:D5").Address(externa l:=True)
'CboReact.RowSource =
Worksheets("Lists").Range("D2:D5").Address(externa l:=True)
'CboDisp.RowSource =
Worksheets("Lists").Range("E2:E4").Address(externa l:=True)
'CboDept.RowSource =
Worksheets("Lists").Range("C2:C10").Address(extern al:=True)

End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
'Cancel = False
FrmManu.Hide
StrtUpFrm.Show
End If
End Sub
 
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
Applying BODMAS to $P23/7*$X23+$Q23 BODMAS application Excel Worksheet Functions 3 May 2nd 07 12:08 AM
Applying Protection Perameters With VBA Code [email protected] Excel Programming 1 January 30th 07 09:47 PM
Applying Colours Sanjay[_2_] Excel Programming 3 December 10th 06 01:37 AM
Autofilter - Applying changes Nigel Excel Programming 10 August 10th 05 03:48 PM
Worksheet Changes and applying code Nigel Bennett Excel Worksheet Functions 1 March 13th 05 06:49 PM


All times are GMT +1. The time now is 10:40 AM.

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"