To change field values from one excel to other
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set ObjExcelFile1 = objExcel.Workbooks.Open("D:ABCa.xls")
Set ObjExcelSheet1 = ObjExcelFile1.Sheets("Sheet1")
Set ObjExcelFile2 = objExcel.Workbooks.Open("D:ABCb.xls")
Set ObjExcelSheet2 = ObjExcelFile2.Sheets("Sheet1")
For i = 1 to ObjExcelSheet1.UsedRange.Rows.Count
strValue = ObjExcelSheet1.Cells(i 8)
ObjExcelSheet2.Cells(i 4) = strValue
strValue1 = ObjExcelSheet1.Cells(i 11)
ObjExcelSheet2.Cells(i 5) = strValue1
Next
ObjExcelFile2.Save
ObjExcelFile1.Close
ObjExcelFile2.Close
objExcel.Quit
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set ObjExcelFile1 = objExcel.Workbooks.Open("D:ABCa.xls")
Set ObjExcelSheet1 = ObjExcelFile1.Sheets("Sheet1")
Set ObjExcelFile2 = objExcel.Workbooks.Open("D:ABCb.xls")
Set ObjExcelSheet2 = ObjExcelFile2.Sheets("Sheet1")
For i = 1 to ObjExcelSheet1.UsedRange.Rows.Count
strValue = ObjExcelSheet1.Cells(i 8)
ObjExcelSheet2.Cells(i 4) = strValue
strValue1 = ObjExcelSheet1.Cells(i 11)
ObjExcelSheet2.Cells(i 5) = strValue1
Next
ObjExcelFile2.Save
ObjExcelFile1.Close
ObjExcelFile2.Close
objExcel.Quit
No comments:
Post a Comment