Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default 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
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
NEED HELP MODIFING A CELL miguel_0319 Excel Discussion (Misc queries) 1 August 2nd 09 05:55 PM
modifing the find function Chris Excel Discussion (Misc queries) 1 March 18th 08 07:00 PM
Help with modifing code?? Mekinnik Excel Programming 4 October 23rd 07 03:39 PM
Modifing a userform txtbox code [email protected] Excel Programming 0 June 13th 07 03:41 PM
Modifing a recorded macro. Duane Reynolds Excel Programming 1 August 9th 06 05:27 AM


All times are GMT +1. The time now is 07:59 PM.

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"