In Excel, if no value needs to be selected from a listbox in a userform, how can I prevent the contents of a range from being cleared? -
In Excel, if no value needs to be selected from a listbox in a userform, how can I prevent the contents of a range from being cleared? -
for example, there listbox select sample type if needs changed in spreadsheet existing data. have no code listbox, have made changes in properties identify source of list , leave single selection.
there command button code behind send listbox , textbox values user entered active sheet.
private sub cmdsendpiddata_click() cells.autofilter 'advance lastly row range("b1").end(xldown).offset(1, 0).select 'constants , user info range("b" & (activecell.row)).value = "'" & samplepointid range("j" & (activecell.row)).value = "'pid measurement" range("n" & (activecell.row)).value = "'ppb" range("f" & (activecell.row)).value = "'" & dtpsampledate.value range("g" & (activecell.row)).value = "'" & txttime.value range("h" & (activecell.row)).value = "'" & lbxsampletype.value range("k" & (activecell.row)).value = "'" & txtconcentration.value range("ak" & (activecell.row)).value = "'" & lbxsamplelocation.value range("an" & (activecell.row)).value = "'" & lbxsampledby.value unload me frmpiddataentry.show
end sub
if nil selected in list box, it's clearing existing value in corresponding range.
you add together if statement check list box value , exit if see =nothing. question little vague, reply too.
private sub cmdsendpiddata_click() ' add together this. if listbox.value = vbnullstring exit sub cells.autofilter 'advance lastly row range("b1").end(xldown).offset(1, 0).select 'constants , user info range("b" & (activecell.row)).value = "'" & samplepointid range("j" & (activecell.row)).value = "'pid measurement" range("n" & (activecell.row)).value = "'ppb" range("f" & (activecell.row)).value = "'" & dtpsampledate.value range("g" & (activecell.row)).value = "'" & txttime.value range("h" & (activecell.row)).value = "'" & lbxsampletype.value range("k" & (activecell.row)).value = "'" & txtconcentration.value range("ak" & (activecell.row)).value = "'" & lbxsamplelocation.value range("an" & (activecell.row)).value = "'" & lbxsampledby.value unload me frmpiddataentry.show end sub
excel-vba listbox userform
Comments
Post a Comment