Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Looping Through Combobox

I want to loop through every item in a combobox. I have tried

For each item in combobox21

and

For i=4 to 100
combobox.value=sheets("io").cells(i,21) ' where sheets("io").cells(i,
21) from 4 to 100 is the listrange


i get a typemismatch with the for each loop and a object 424 with the
for i=4 to 100

the debugger says the combobox is empty but i can physically see
values in it
any ideas? thanks in advance

here is the code:



For i = 4 To 100

ComboBox21.Value = Sheets("io").Cells(i, 21)
If IsEmpty(Sheets("io").Range("u101")) = True Then Exit For


With Sheets("quote")
.Cells(3 + step * Sheets("io").Range("u101"), 1) =
Sheets("IO").Range("f20")
.Cells(3 + step * Sheets("io").Range("u101"), 2) =
Sheets("io").Range("u101")
.Cells(4 + step * Sheets("io").Range("u101"), 3) = "Building"
.Cells(5 + step * Sheets("io").Range("u101"), 3) = "Personal
Property"
.Cells(6 + step * Sheets("io").Range("u101"), 3) = "Business
Income"





If Sheets("quick rate").Range("b9") < 0 Then 'building
.Cells(4 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("b9")
.Cells(4 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t9")
.Cells(4 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t19")
.Cells(4 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t27") + Sheets("quick rate").Range("t33")

End If

If Sheets("quick rate").Range("a7") < 0 Then 'Personal Property
.Cells(5 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("a9")
.Cells(5 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t13")
.Cells(5 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t23")
.Cells(5 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t29") + Sheets("quick rate").Range("t37")
_
+ Sheets("quick rate").Range("t39")
End If

If Sheets("quick rate").Range("e9") < 0 Then 'business income
.Cells(6 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("e9")
.Cells(6 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t43")
.Cells(6 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t47")
.Cells(6 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t51")


End If


.Columns("D").NumberFormat = "###,###,###"
.Columns("e").NumberFormat = "###,###,###"
.Columns("f").NumberFormat = "###,###,###"
.Columns("g").NumberFormat = "###,###,###"




End With
Next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Looping Through Combobox

this might work:

For each item in combobox21.List

" wrote:

I want to loop through every item in a combobox. I have tried

For each item in combobox21

and

For i=4 to 100
combobox.value=sheets("io").cells(i,21) ' where sheets("io").cells(i,
21) from 4 to 100 is the listrange


i get a typemismatch with the for each loop and a object 424 with the
for i=4 to 100

the debugger says the combobox is empty but i can physically see
values in it
any ideas? thanks in advance

here is the code:



For i = 4 To 100

ComboBox21.Value = Sheets("io").Cells(i, 21)
If IsEmpty(Sheets("io").Range("u101")) = True Then Exit For


With Sheets("quote")
.Cells(3 + step * Sheets("io").Range("u101"), 1) =
Sheets("IO").Range("f20")
.Cells(3 + step * Sheets("io").Range("u101"), 2) =
Sheets("io").Range("u101")
.Cells(4 + step * Sheets("io").Range("u101"), 3) = "Building"
.Cells(5 + step * Sheets("io").Range("u101"), 3) = "Personal
Property"
.Cells(6 + step * Sheets("io").Range("u101"), 3) = "Business
Income"





If Sheets("quick rate").Range("b9") < 0 Then 'building
.Cells(4 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("b9")
.Cells(4 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t9")
.Cells(4 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t19")
.Cells(4 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t27") + Sheets("quick rate").Range("t33")

End If

If Sheets("quick rate").Range("a7") < 0 Then 'Personal Property
.Cells(5 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("a9")
.Cells(5 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t13")
.Cells(5 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t23")
.Cells(5 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t29") + Sheets("quick rate").Range("t37")
_
+ Sheets("quick rate").Range("t39")
End If

If Sheets("quick rate").Range("e9") < 0 Then 'business income
.Cells(6 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("e9")
.Cells(6 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t43")
.Cells(6 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t47")
.Cells(6 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t51")


End If


.Columns("D").NumberFormat = "###,###,###"
.Columns("e").NumberFormat = "###,###,###"
.Columns("f").NumberFormat = "###,###,###"
.Columns("g").NumberFormat = "###,###,###"




End With
Next i

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping Through Combobox

What about this...

For X = 0 To combobox21.ListCount - 1

and in your code, refer to the item currently being processed this way...

combobox21.List(X)

Rick


wrote in message
...
I want to loop through every item in a combobox. I have tried

For each item in combobox21

and

For i=4 to 100
combobox.value=sheets("io").cells(i,21) ' where sheets("io").cells(i,
21) from 4 to 100 is the listrange


i get a typemismatch with the for each loop and a object 424 with the
for i=4 to 100

the debugger says the combobox is empty but i can physically see
values in it
any ideas? thanks in advance

here is the code:



For i = 4 To 100

ComboBox21.Value = Sheets("io").Cells(i, 21)
If IsEmpty(Sheets("io").Range("u101")) = True Then Exit For


With Sheets("quote")
.Cells(3 + step * Sheets("io").Range("u101"), 1) =
Sheets("IO").Range("f20")
.Cells(3 + step * Sheets("io").Range("u101"), 2) =
Sheets("io").Range("u101")
.Cells(4 + step * Sheets("io").Range("u101"), 3) = "Building"
.Cells(5 + step * Sheets("io").Range("u101"), 3) = "Personal
Property"
.Cells(6 + step * Sheets("io").Range("u101"), 3) = "Business
Income"





If Sheets("quick rate").Range("b9") < 0 Then 'building
.Cells(4 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("b9")
.Cells(4 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t9")
.Cells(4 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t19")
.Cells(4 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t27") + Sheets("quick rate").Range("t33")

End If

If Sheets("quick rate").Range("a7") < 0 Then 'Personal Property
.Cells(5 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("a9")
.Cells(5 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t13")
.Cells(5 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t23")
.Cells(5 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t29") + Sheets("quick rate").Range("t37")
_
+ Sheets("quick rate").Range("t39")
End If

If Sheets("quick rate").Range("e9") < 0 Then 'business income
.Cells(6 + step * Sheets("io").Range("u101"), 4) =
Sheets("quick rate").Range("e9")
.Cells(6 + step * Sheets("io").Range("u101"), 5) =
Sheets("quick rate").Range("t43")
.Cells(6 + step * Sheets("io").Range("u101"), 6) =
Sheets("quick rate").Range("t47")
.Cells(6 + step * Sheets("io").Range("u101"), 7) =
Sheets("quick rate").Range("t51")


End If


.Columns("D").NumberFormat = "###,###,###"
.Columns("e").NumberFormat = "###,###,###"
.Columns("f").NumberFormat = "###,###,###"
.Columns("g").NumberFormat = "###,###,###"




End With
Next i


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
Combobox items determined by the selection in another combobox Alerion Excel Programming 2 September 13th 06 01:07 PM
Combobox options based on the input of another combobox afmullane[_5_] Excel Programming 1 May 3rd 06 01:44 PM
ComboBox list reliant on the entry from a different ComboBox ndm berry[_2_] Excel Programming 4 October 4th 05 04:40 PM
Problem looping through combobox Martin Los[_3_] Excel Programming 3 October 4th 05 04:27 PM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman[_4_] Excel Programming 3 October 26th 04 07:58 PM


All times are GMT +1. The time now is 09:29 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"