excel vba - Listview to retrieve the data from other file -


i want retrieve data in listview below path instead of same file. can please advise changes required in code.

myfilenamedir = "c:\users\gshaikh\desktop\book16.xlsx" workbooks.open filename:=myfilenamedir, updatelinks:=0 set ws1 = worksheets("students")    'code retieving data same file.  dim wkssource worksheet dim rngdata range dim rngcell range dim lstitem listitem dim rowcount long dim colcount long dim long dim j long   set wkssource = worksheets("sheet1")  set rngdata = wkssource.range("a1").currentregion      each rngcell in rngdata.rows(1).cells         me.listview1.columnheaders.add text:=rngcell.value, width:=90     next rngcell  rowcount = rngdata.rows.count  colcount = rngdata.columns.count      = 2 rowcount         set lstitem = me.listview1.listitems.add(text:=rngdata(i, 1).value)         j = 2 colcount             lstitem.listsubitems.add text:=rngdata(i, j).value         next j     next 

you add data listview rngdata range, , here set range:

    set rngdata = wkssource.range("a1").currentregion 

if want use data workbook opened, should modify rngdata refer workbook instead:

    set rngdata = ws1.range("a1").currentregion 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -