Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Modifing example code
Hi - Beginner at code here!
I have taken this sample code from http://www.contextures.on.ca/xlUserForm01.html#SetUp (which was a great help) and downloaded the sample for Enhanced User forms with Combo boxes but I am stuck on how to modify the first part. Private Sub UserForm_Initialize() Dim cPart As Range "This is the part I cannot work out what to change it to. Dim cLoc As Range I cannot see anything in the sheet or the form that Dim ws As Worksheet refers to cPart" Set ws = Worksheets("LookupLists") "This I understand along with the rest that would make sense when I work out the first part - I think" For Each cPart In ws.Range("PartIDList") With Me.cboPart .AddItem cPart.Value .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value End With Next cPart For Each cLoc In ws.Range("LocationList") With Me.cboLocation .AddItem cLoc.Value .List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value End With Next cLoc If anyone could help that would be great. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Modifing example code
Hi,
The first 2 lines simply tell the code that cPart cLoc are ranges of cells, they exist only within the code memory and not as named ranges anywhere. The are referred to again in the lines For Each cPart In ws.Range("PartIDList") In this line the code loops through every cell(cPart) in the named range "PartIDList" and this you will need to create as a named range on your worksheet and put into it the data you want to populate into the (I assume) combobox called cboPart Hope this helps Mike "Leanne" wrote: Hi - Beginner at code here! I have taken this sample code from http://www.contextures.on.ca/xlUserForm01.html#SetUp (which was a great help) and downloaded the sample for Enhanced User forms with Combo boxes but I am stuck on how to modify the first part. Private Sub UserForm_Initialize() Dim cPart As Range "This is the part I cannot work out what to change it to. Dim cLoc As Range I cannot see anything in the sheet or the form that Dim ws As Worksheet refers to cPart" Set ws = Worksheets("LookupLists") "This I understand along with the rest that would make sense when I work out the first part - I think" For Each cPart In ws.Range("PartIDList") With Me.cboPart .AddItem cPart.Value .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value End With Next cPart For Each cLoc In ws.Range("LocationList") With Me.cboLocation .AddItem cLoc.Value .List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value End With Next cLoc If anyone could help that would be great. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Modifing example code
Hi Mike,
Yeah thanks for that. I thought that is what it would refer to but I could not find the range in the sheet that was called cPart - Hence my question. Thanks I will give it a go and see how I get on. "Mike H" wrote: Hi, The first 2 lines simply tell the code that cPart cLoc are ranges of cells, they exist only within the code memory and not as named ranges anywhere. The are referred to again in the lines For Each cPart In ws.Range("PartIDList") In this line the code loops through every cell(cPart) in the named range "PartIDList" and this you will need to create as a named range on your worksheet and put into it the data you want to populate into the (I assume) combobox called cboPart Hope this helps Mike "Leanne" wrote: Hi - Beginner at code here! I have taken this sample code from http://www.contextures.on.ca/xlUserForm01.html#SetUp (which was a great help) and downloaded the sample for Enhanced User forms with Combo boxes but I am stuck on how to modify the first part. Private Sub UserForm_Initialize() Dim cPart As Range "This is the part I cannot work out what to change it to. Dim cLoc As Range I cannot see anything in the sheet or the form that Dim ws As Worksheet refers to cPart" Set ws = Worksheets("LookupLists") "This I understand along with the rest that would make sense when I work out the first part - I think" For Each cPart In ws.Range("PartIDList") With Me.cboPart .AddItem cPart.Value .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value End With Next cPart For Each cLoc In ws.Range("LocationList") With Me.cboLocation .AddItem cLoc.Value .List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value End With Next cLoc If anyone could help that would be great. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
NEED HELP MODIFING A CELL | Excel Discussion (Misc queries) | |||
modifing the find function | Excel Discussion (Misc queries) | |||
Help with modifing code?? | Excel Programming | |||
Modifing a userform txtbox code | Excel Programming | |||
Modifing a recorded macro. | Excel Programming |