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

Hi,

Have made a couple of adjustments and also note the comments. The following
now appears to test OK. Have not tested all of the code that you posted, only
the part to populate the second combo box based on the selection in the first
combo.

Also everyone appreciates an acknowledgement to an answer (Whether it works
or not). I see that you have used code from a previous answer that I provided
but you didn't previously acknowledge whether it answered your question
satisfactorily.

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 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)

'Note: V in above line will never be an error
'because it is a numeric value representing
'the position in range A2:A1000 of the selection
'and the selection is the Rowsource of the combo so
'it must be found in that range.

'Is it supposed to test in Procode not MANCODE as follows?
V = Application.Match(S, Worksheets("ProCode") _
.Range("A2:A1000"), 0)

'Use If/Else/End If test as follows:-
If IsError(V) = True Then
'Next section commented out by OssieMac
'for testing purposes. Don't know if it works
'FrmProduct.Hide
'FrmManu.Show
Else
With Me.CbxProd

'Following required if you go back
'and change selection in CbxMfg.
'If DbxProd is empty then it is ignored.
If .ListCount 0 Then
For i = .ListCount - 1 To 0 Step -1
.RemoveItem (i)
Next i
End If

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


Regards,

OssieMac
 
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 01:59 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"