Copy Excel Sheet/Range from 1 Excel to Another

Hi, I would like to copy excel sheets from 1 Excel to another.
The “Copy Sheet” function doesn’t exactly work because the sheet name exists in both Excel. I would need to delete the sheet in the target file first, but I would like to have Excel run in background, so hot keys delete sheet wouldn’t work.

@inyourgravity

use Read Range activity to read data from first excel file and store result in dataTable variable say ‘DT1’ and then use Write Range activity to write into another excel file and pass output ‘DT1’ here and provide sheet name. If it doesn’t exist then will create it write into it.

@inyourgravity,

As @lakshman mentioned, you can use Read and Write Range.
Still if you face any issue and you want to delete sheet in a excel, please use Delete Sheet activity.

Thanks,
Saranya K R

1 Like

Hi @inyourgravity

This is what I normally do when I need to copy the sheet.

  • Use Excel macro to Delete the sheet first before you use “Copy Sheet” activity

  • Later Use Copy Sheet activity to copy over sheet.

I have attached the workflow for your reference.

Safest Macro that I use to delete sheet is

Sub VBA_Delete_Sheet()
For Each Sheet In ActiveWorkbook.Worksheets
If Sheet.Name = “Sheet Name” Then
Application.DisplayAlerts = False
Worksheets(“Sheet Name”).Delete
Application.DisplayAlerts = True
End If
Next Sheet
End Sub

Don’t forget to mark as solution if this one can solve your issue.

Thanks,

CopyExcelSheet.xaml (7.8 KB)

4 Likes

The reason why I can’t use Read and Write Range is because I want to copy the formatting and formulas as well.

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