VBA Variable within "Name" -


i've got several check boxes going change visibility , caption of based on index of loop. have array of 1 x. form passing along array total , each array element string.

anyway, on worksheet passing:

sub stripdown_button_click()     lastupdatecolumn = sheets("update").usedrange.columns.count     header_array = range(cells(7, 1), cells(7, lastupdatecolumn)).value     header_form.header_select lastupdatecolumn, header_array()     header_form.show end sub 

lastupdatecolumn integer, header_array array of strings.

my form, screwing @ point follows...

public sub header_select(index integer, header_list() string)      x = 1 index         if header_list(1) <> ""             cb & index.visible = true             cb & index.caption = header_list(index)         else             msgbox "form error. contact engineering", vbokonly         on error resume next     end sub 

you cannot create variable name string; forms have controls default property accepting control name index

dim cb checkbox  set cb =  controls("cb" & index) cb.visible = true cb.caption = header_list(index) 

since property default property, other syntax works:

set cb =  me("cb" & index)