Hi
I have this macro thats supposed to ask me for a new sheet name ( which it does) , Copy over the data to the new sheet and this is where it goes wrong.
As stated it copies the data over to the new sheet but only in all columns 1-9 as there is data in them rows. Im trying to copy everything even if there is no data in the cells as then its not deleting rows fully.
Any Ideas?
I have this macro thats supposed to ask me for a new sheet name ( which it does) , Copy over the data to the new sheet and this is where it goes wrong.
As stated it copies the data over to the new sheet but only in all columns 1-9 as there is data in them rows. Im trying to copy everything even if there is no data in the cells as then its not deleting rows fully.
Any Ideas?
VBA Code:
Option Explicit
Sub TransferData()
Dim lngLastRow As Long
Dim lngRow As Long
Dim strSheetName As String
Dim wsSource As Worksheet
lngLastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Set wsSource = ActiveSheet
With Application
.EnableEvents = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
strSheetName = InputBox("Please enter the name of the new worksheet", "Transfer Data")
If StrPtr(strSheetName) = 0 Then
MsgBox "No worksheet name entered"
Exit Sub
End If
Sheets.Add(After:=Sheets(Sheets.Count)).Name = strSheetName
wsSource.Range("A1:Y" & lngLastRow).Copy
With ActiveSheet
.Range("A1").PasteSpecial
.Range("G10:Y" & lngLastRow).Clear
For lngRow = lngLastRow To 1 Step -1
If Not IsEmpty(.Cells(lngRow, "Y")) Then
If .Cells(lngRow, "Y") = 0 Then
.Cells(lngRow, "Y").EntireRow.Delete
End If
End If
Next
End With
With Application
.Calculation = xlCalculationAutomatic
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub