Creating IF statement Through VBA

Trying to convert this below code into an if statement.

If Sheet2 is not exist, code will copy data from Sheet1 and create sheet2 then will paste data in Sheet2 and will return to Sheet1.

The purpose of adding If statement is that if i run that code again over again it gives error. I want that it should not give error.

If Sheet2 is exists code should return as nothing/empty/""

    Dim Destination As Worksheet
If Source.Name = "sheet2" Then
Set Destination = Worksheets.Add(after:=Worksheets("Sheet1"))
Destination.Name = "Sheet2"
Sheets("sheet1").Range("A:D").Copy Sheets("sheet2").Range("A:D")

Hi @Learning!

Seems like you have landed to wrong forum. This is a community forum for KoBoToolbox and we discuss here all the issues related with KoBoToolbox.

Oh alright.

1 Like