Copy one excel value to another without changing the colors

How to value in a excel from particular range and paste it to excel into a range using vb script

Getting error on this
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim excel1 As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim wb1 As Microsoft.Office.Interop.Excel.Workbook
Dim ws1 As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range

        ' Initialize Excel objects
    excel = New Microsoft.Office.Interop.Excel.Application
    wb = excel.Workbooks.Open(Filename)
    excel.Visible = False
    ws = CType(wb.Sheets(TargetSheet), Microsoft.Office.Interop.Excel.Worksheet)
                    excel1 = New Microsoft.Office.Interop.Excel.Application
    wb1 = excel.Workbooks.Open(Filename1)
    excel.Visible = False
    ws1 = CType(wb.Sheets(TargetSheet1), Microsoft.Office.Interop.Excel.Worksheet)
                    ws1.Range("A4","T"+ws.Rows.Count.ToString).value = ws.Range("A2","T"+ws.Rows.Count.ToString)                    
                   
                   
   


    ' Save and close the workbook
    wb.Save()
    wb.Close()
   wb1.Save()
    wb1.Close()
1 Like

@Demo_User

Instead of all this…use copy paste range activity and select all

Cheers

Hi @Demo_User

Better to use the Copy\Paste range activity to copy the specific range paste in the another excel.
image

Check the below workflow image for your better understanding.

In the Source field give the excel1 range
In the Destination field give the excel 2 range.

Hope it helps!!

Hi @Demo_User

Use read range activity and mention the range in the range field and then store that data in variable and then use write range activity and pass the variable and also mention the range so that the data will be written in that particular range in Excel.

Regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.