ShumsFaruk
Board Regular
- Joined
- Jul 24, 2009
- Messages
- 93
Good Day All Experts,
I am trying to move data from one sheet to another with the help of below code through UserForm; the problem is its taking longer. I dont want to have .value = .value because some cell format needs to be in that format.
Is there any way to speed up below code:
I do have speeding code as below; but it doesn't help:
Need your advice. Please do the needful.
I am trying to move data from one sheet to another with the help of below code through UserForm; the problem is its taking longer. I dont want to have .value = .value because some cell format needs to be in that format.
Is there any way to speed up below code:
Code:
Private Sub AddUpdate_Click()
Call FunctionalityOff
Dim StartDate As Date, EndDate As Date
Dim SourceRow As Long, DestRow As Long, DestLR As Long, SourceLR As Long
Dim SourceSheet As Worksheet, DestSheet As Worksheet
Dim SourceCount As Long
Dim iHeader As Integer
Set SourceSheet = Sheets("Utilization")
Set DestSheet = Sheets("Inv_Workbook")
DestLR = DestSheet.Cells(Rows.Count, "A").End(xlUp).Row
DestSheet.Range("A3:V" & DestLR).ClearContents
SourceCount = 0
DestRow = 3
SourceSheet.Activate
With SourceSheet.ListObjects("Utilization")
SourceLR = SourceSheet.ListObjects("Utilization").ListRows.Count
iHeader = 2
End With
StartDate = CDate(FromDateMonthView.Value)
EndDate = CDate(ToDateMonthView.Value)
For SourceRow = 2 To SourceLR
If CDate(Cells(SourceRow, "D").Value) >= StartDate And CDate(Cells(SourceRow, "AG").Value) <= EndDate Then
SourceSheet.Cells(SourceRow, "A").Copy
DestSheet.Cells(DestRow, "A").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "G").Copy
DestSheet.Cells(DestRow, "B").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "H").Copy
DestSheet.Cells(DestRow, "D").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "M").Copy
DestSheet.Cells(DestRow, "E").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "R").Copy
DestSheet.Cells(DestRow, "G").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "S").Copy
DestSheet.Cells(DestRow, "H").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "T").Copy
DestSheet.Cells(DestRow, "I").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "U").Copy
DestSheet.Cells(DestRow, "J").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "AA").Copy
DestSheet.Cells(DestRow, "K").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "K").Copy
DestSheet.Cells(DestRow, "Q").PasteSpecial xlPasteValues
SourceSheet.Cells(SourceRow, "AG").Copy
DestSheet.Cells(DestRow, "S").PasteSpecial xlPasteValues
Application.CutCopyMode = False
DestRow = DestRow + 1
SourceCount = SourceCount + 1
End If
Next SourceRow
MsgBox SourceCount & " Significant rows copied", vbInformation, "Transfer Done"
Unload Me
DestSheet.Activate
Call FunctionalityOn
End Sub
I do have speeding code as below; but it doesn't help:
Code:
Sub FunctionalityOn()
With Application
.ScreenUpdating = True
.DisplayStatusBar = True
.StatusBar = False
.EnableEvents = True
.Calculation = xlAutomatic
End With
End Sub
Code:
Sub FunctionalityOff()
With Application
.ScreenUpdating = False
.DisplayStatusBar = True
.StatusBar = "!!! Please Be Patient...Updating Records !!!"
.EnableEvents = False
.Calculation = xlManual
End With
Need your advice. Please do the needful.