excel vba - Copy data from one workbook to other with special condition -



excel vba - Copy data from one workbook to other with special condition -

i have 2 columns in excel sheet . first column has other cell address illustration - column has contents f1, f2, f3, f4 , f5. sec column has other cell address illustration - column b has contents x1, x13, x17, x72.

now want macro can re-create contents of cells mentioned in first column (want re-create contents of f1 ...f5) cells mentioned in sec column.

i have written next code working :

sub transfervalues() dim rnga range dim rngb range dim srcaddress range dim destaddress range dim r long 'row iterator varw1 = "a.xlsx" sht1 = "sheet1" set rnga = range("a2", range("a2").end(xldown)) set rngb = rnga.offset(0, 1) r = 1 rnga.rows.count set srcaddress = range(rnga(r).value) set destaddress = workbooks(varw1).sheets(sht1).range(rngb(r).value) destaddress.value = srcaddress.value next end sub

now problem unable above operations without opening file. please amend code can re-create without opening other file.

actually, simplicity had moved info 1 sheet other within 1 workbook. when source workbook "a.xlsx" , destination workbook "b.xlsx" how move info "a.xlsx" "b.xlsx" without opening "a.xlsx" , running macro in "b.xlsx"

edit modified code as:

sub transfervalues() dim rnga range dim rngb range dim srcaddress range dim destaddress range dim r long 'row iterator varw1 = "b.xlsx" sht1 = "sheet1" set rnga = workbooks("a.xlsx").sheets(sheet1).range("a2", range("a2").end(xldown)) set rngb = rnga.offset(0, 1) r = 1 rnga.rows.count set srcaddress = range(rnga(r).value) set destaddress = workbooks(varw1).sheets(sht1).range(rngb(r).value) destaddress.formula = "='[" & "a.xlsx" & "]sheet1'!" & srcaddress next end sub

but still getting error. please help

excel-vba

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -