VBA Example- Inserting new Sheet and copying firstSheets data to this sheet

COPY THIS CODE ON BUTTON CLICK OF THE ATTACHED SHEET. SAVE THE FILE AS MACRO ENABLED (IN .XLSM FORMAT) InsertSheet

Instructions as listed in the Instructions tab in attached file.

Dim lastRow As Long

With ActiveSheet
inputfile.UsedRange.Copy Destination:=.Range(“A1”)
lastRow = .Cells(Rows.Count, “A”).End(xlUp).Row
.Columns(“D:E”).Insert

.Range(“D1”) = “CE”
.Range(“E1”) = “CE Name”

.Range(“B2:B” & lastRow).Copy Destination:=.Range(“D2”)

.Range(“C2:C” & lastRow).Copy Destination:=.Range(“E2”)
Dim i As Integer

For i = 2 To lastRow

If .Range(“D” & i).Value = 1000 Then
.Range(“E” & i).Value = “new Project”

End If
Next i

End With

Leave a Reply