excel - Loop each cell from sheet1 and always replace in 1 cell at sheet2 -


i had problem, when want use each name c1 c21 sheet1 , insert in nameuser url address. delete each name sheet1 c1 c21 not replace destination b2 @ sheet2 every name.

sub url_get_query()  dim wb workbook dim src worksheet dim tgt worksheet  set wb = thisworkbook set src = wb.sheets("sheet1") set tgt = wb.sheets("sheet2")  dim url string dim symbol string  tgt.columns("b:c").select selection.clearcontents src.select  dim c range dim rng range set rng = range("c3:c21") each c in rng msgbox (c.address)  rng = namerange  nameuser = namerange 'nameuser = src.range("c3") url1 = "url;http://my001vs0253:81/user.aspx?username=" url = url1 & nameuser & "&userdomain=tp"  '"url;http://my001vs0253:81/user.aspx?username=afiqg&userdomain=tp",  nameuser1 = "user.aspx?username=" nameurl = nameuser1 & nameuser & "&userdomain=tp_7" 'nameurl = nameuser1 & rrng & "&userdomain=tp_7"  tgt.querytables.add(connection:= _     url, destination:=tgt.range("b2"))       '.commandtype = 0     .name = nameurl     .fieldnames = true     .rownumbers = false     .filladjacentformulas = false     .preserveformatting = true     .refreshonfileopen = false     .backgroundquery = true     .refreshstyle = xlinsertdeletecells     .savepassword = false     .savedata = true     .adjustcolumnwidth = true     .refreshperiod = 0     .webselectiontype = xlspecifiedtables     .webformatting = xlwebformattingnone     .webtables = "22"     .webpreformattedtexttocolumns = true     .webconsecutivedelimitersasone = true     .websingleblocktextimport = false     .webdisabledaterecognition = false     .webdisableredirections = false     .refresh backgroundquery:=false end  next end sub 

hope may opinion. advance.

perhaps can first read data in src worksheet array, , use array build data in tgt worksheet. remove direct link between 2 worksheets, , possibly issue. question why need delete columns? deleting columns can provide issues 1 having now, try avoid doing so.


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 -