#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default list box

I have successfully populated "Frm_ValueStore.lst_Cols" with 6 intergers;
"Frm_ValueStore.lst_Rows" with 4 intergers. This form is hidden, but still
loaded.

On a second form, text box "txt_CellSelection" is populated with the address
of where the user just right clicked.

I want to test to see if the column & row the user right click into are in
either "Frm_ValueStore.lst_Cols" or "Frm_ValueStore.lst_Rows", respectively.
In the code below, Frm_ValueStore.lst_Cols.ListCount is correctly evaluating
to "6".

I am getting runtime error 9, Subscript out of range on "var(i)"

Thanks in advance for your help!

Private Sub cmd_Spread_Click()
Dim i As Integer
Dim j As Integer
Dim Total_Test As Boolean
Dim var As Variant

'Test to see if cell is on a subtotal column
Total_Test = False

var = Frm_ValueStore.lst_Cols.List
For i = 0 To Frm_ValueStore.lst_Cols.ListCount - 1
If var(i) = Range(txt_CellSelection).Column Then Total_Test = True
Next i

Redim var
var = Frm_ValueStore.lst_Rows.List
For i = 1 To Frm_ValueStore.lst_Rows.ListCount
If var(i) = Range(txt_CellSelection).Row Then Total_Test = True
Next i

Debug.Print Total_Test
Unload frm_Spread

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default list box

You can use 0 for a column reference as a relative reference when using
something like Offset(1, 0), but it will not work in an absolute reference as
you are using with Var(i) = Something.Column. You can try:

If var(i + 1) = Range(txt_CellSelection).Column Then Total_Test = True

That would then start with the positive value of one.

"Cinque Terra" wrote:

I have successfully populated "Frm_ValueStore.lst_Cols" with 6 intergers;
"Frm_ValueStore.lst_Rows" with 4 intergers. This form is hidden, but still
loaded.

On a second form, text box "txt_CellSelection" is populated with the address
of where the user just right clicked.

I want to test to see if the column & row the user right click into are in
either "Frm_ValueStore.lst_Cols" or "Frm_ValueStore.lst_Rows", respectively.
In the code below, Frm_ValueStore.lst_Cols.ListCount is correctly evaluating
to "6".

I am getting runtime error 9, Subscript out of range on "var(i)"

Thanks in advance for your help!

Private Sub cmd_Spread_Click()
Dim i As Integer
Dim j As Integer
Dim Total_Test As Boolean
Dim var As Variant

'Test to see if cell is on a subtotal column
Total_Test = False

var = Frm_ValueStore.lst_Cols.List
For i = 0 To Frm_ValueStore.lst_Cols.ListCount - 1
If var(i) = Range(txt_CellSelection).Column Then Total_Test = True
Next i

Redim var
var = Frm_ValueStore.lst_Rows.List
For i = 1 To Frm_ValueStore.lst_Rows.ListCount
If var(i) = Range(txt_CellSelection).Row Then Total_Test = True
Next i

Debug.Print Total_Test
Unload frm_Spread

End Sub

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
Comparing List A to List B and add what's missing from List B Gilbert Excel Discussion (Misc queries) 1 July 20th 09 08:41 PM
create new list from list A, but with exclusions from a list B Harold Good Excel Worksheet Functions 3 April 11th 08 11:23 PM
validation list--list depends on the selection of first list Michael New Users to Excel 2 April 27th 06 10:23 PM
list 1 has 400 names List 2 has 4000. find manes from list 1 on 2 Ed Excel Worksheet Functions 5 September 12th 05 09:48 AM
find names on list 1 in list 2. list 1 4000 names list 2 400 name Ed Excel Worksheet Functions 1 September 4th 05 12:48 AM


All times are GMT +1. The time now is 09:07 AM.

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"