slow code

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
755
Office Version
  1. 365
  2. 2010
this is running slowing....could someone pls recommend a way to speed this up? im afraid of doing calculation xlmanual....will that mena the loops wont work?

Code:
    Dim chk As String
    Dim amtc
    Dim found As String
    Dim clear_c As Integer  'total record count on "Cleared" sheet
    Dim os_c As Integer     'total record count on "Outstanding Cheques" sheet
    Dim nf_c As Integer     'total record count on "Cleared Not Outstanding" sheet
    Dim nf_r As Range
    
    
    'Clear "Cleared Not Outstanding" data
    Sheets("Cleared-Not-In-Outstanding").Select
    Selection.CurrentRegion.ClearContents
    Range("A1") = "Reference"
    Range("B1") = "Gross Amount"
    
    'Count total number of records on "Outstanding Cheques" sheet
    Sheets("Outstanding_Cheques").Select
    os_c = Range("A6").CurrentRegion.Rows.Count
    
    'Count total number of records on "Cleared" sheet
    Sheets("Cleared").Select
    clear_c = Range("A1").CurrentRegion.Rows.Count
    
    'Loop through each record on "Clear" sheet.
    'Check to see if the record exists on "Outstanding" sheet.
    For I = 1 To clear_c
      Let found = "False"
      chk = ActiveCell.Offset(I - 1, 0).Value
      amtc = ActiveCell.Offset(I - 1, 1).Value
        
        Sheets("Outstanding_Cheques").Select
        Range("A6").Select
        For y = 1 To os_c - 1
        'If the value reference and amount agree, cut the cleared cheque from the outstandings list and move it to cashed
          If (ActiveCell.Offset(y - 1, 1).Value = chk) And (ActiveCell.Offset(y - 1, 2).Value = amtc) Then
            ActiveCell.Offset(y - 1, 0).Select
            ActiveCell.EntireRow.Cut Sheets("Cashed").Range("A65536").End(xlUp).Offset(1, 0)
            ActiveCell.EntireRow.Delete
            os_c = os_c - 1
            Let found = "True"
            Exit For
          End If
        Next y
        
        'If the cleared cheque doesn't match any items in the outstanding list, paste the data on the cleared not os sheet
        If found = "False" Then
          Sheets("Cleared-Not-In-Outstanding").Select
          Range("A1").Select
          nf_c = Range("A1").CurrentRegion.Rows.Count
          ActiveCell.Offset(nf_c, 0).Value = chk
          ActiveCell.Offset(nf_c, 1).Value = amtc
           
        End If
      
      
      Sheets("Cleared").Select
      Range("A1").Select


Next I


'update cashed tab
Dim clear_date As String


clear_date = Range("D1")


 
 Sheets("Cashed").Select
 Range("e65536").End(xlUp).Activate
 ActiveCell.Offset(1, 0).EntireRow.Insert
 ActiveCell.Offset(2, 0).Select
 Do


    ActiveCell.Value = clear_date


    ActiveCell.Offset(1, 0).Select


    Loop Until IsEmpty(ActiveCell.Offset(0, -1))


Sheets("Reconciliation").Select
Range("d3").Select
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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