Moving Data Between Sheets Based On Dates

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:

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.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,216,101
Messages
6,128,844
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top