excel - Copy 2 cells and paste do a different sheet once combobox has changed -


i have workbook user can add information i.e username , password.

sheet2 data store. use column's a, b , c.

i have combobox on userform. raw source combobox column a. when user selects 1 of options combobox want copy values column b & c , paste values worksheet. have far:

activesheet.range("$a$1:$f$3").autofilter field:=1, criteria1:=combobox1.value range("b2:c2").select selection.copy sheets("displaypage").select range("a1").select activesheet.paste sheets("database").select activesheet.range("$a$1:$f$3").autofilter field:=1 range("a2").select 

but when run autofilter method of range class failed

has got other ideas?

assuming combobox populated rowsource property, give try:

private sub combobox1_change()      dim cbo combobox     dim wsdest worksheet     dim rngdata range      set cbo = me.combobox1     set wsdest = sheets("displaypage")     set rngdata = range(cbo.rowsource)      wsdest.range("a1:b1").clearcontents 'remove previous data (if any)     if cbo.listindex = -1 exit sub 'nothing selected      rngdata.cells(1).offset(cbo.listindex, 1).resize(, 2).copy wsdest.range("a1")  end sub 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -