Friday, 15 May 2015

VBA script to search combination of values -



VBA script to search combination of values -

i hope can help me following. have sheet on each row client/patient record (starting row 3) , 56 colums of medical info (conditions, medication etc) search in. have userform several comboboxes select item or combination of items search for. made script search combination of items. problem result not close of result should be.

private sub cmdcombi_click() dim combirange range dim lastrow long dim lastcol long dim cbo1 string dim cbo2 string dim cbo3 string dim par1 integer dim par2 integer dim par3 integer dim conb integer lastrow = worksheets("source").cells(rows.count, 1).end(xlup).row set combirange = worksheets("source").range("a2:bo" & lastrow) if not cboincl1.text = "" cbo1 = cboincl1.value par1 = 1 else cbo1 = "--" par1 = 0 end if if not cboincl2.text = "" cbo2 = cboincl2.value par2 = 1 else cbo2 = "--" par2 = 0 end if if not cboincl3.text = "" cbo3 = cboincl3.value par3 = 1 else cbo3 = "--" par3 = 0 end if partotal = par1 + par2 + par3 conb = 0 ir = 3 lastrow ic = 11 67 if worksheets("source").cells(ir, ic).value = cbo1 or worksheets("source").cells(ir, ic).value = cbo2 or worksheets("source").cells(ir, ic).value = cbo3 inc = inc + 1 end if next ic if inc = partotal conb = conb + 1 end if next ir formmenu.tboresin.value = conb end sub

anyone idee of i'm doing wrong?

thank in advance!

ok, found problem myself. forgot declare inc 0 start of each new row.

for ir = 3 lastrow inc = 0 ic = 11 67

vba combinations

No comments:

Post a Comment