Help making code more efficient

ALidstone

New Member
Joined
Feb 15, 2016
Messages
2
Good day, I'm looking to make the following code more efficient. Any suggestions would be greatly appreciated! Thank you in advance.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Good day, I'm looking to make the following code more efficient. Any suggestions would be greatly appreciated! Thank you in advance.
Sub DataVerifier()


'"""""""""Application Settings""""""""
Application.DisplayAlerts = False 'Stops the program from asking if it is ok for the macro to delete sheets
Application.ScreenUpdating = False 'Stops program from showing what is happening when the macro is running
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'"""""""""""""""""""""""""""""""""""""




Dim lastRow As Long 'What row the last data point is in the new sheet (used for formula configuration)
Dim sht As Worksheet


Sheets(1).Select 'Adds a sheet to front of book and names it combined, this will contain all data in one sheet
Dim j As Integer 'Loops through the sheets, selecting all cells on the sheet and moving them to sheet "Combined"
For j = 2 To Sheets.Count
Sheets(j).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy Destination:=Sheets(1).Range("A1000000").End(xlUp)
Next j
Sheets(1).Activate


Dim i As Long
For i = 2 To 50000
If (Cells(i, 5) < 1 And Cells(i, 5) > -1 And Cells(i, 5) <> "") Then
Cells(i, 6) = 1
End If
Next i

Dim k As Long
For k = 2 To 50000
If (Cells(k, 6) = 1) Then
Range(Cells(k, 1), Cells(k, 6)).Delete Shift:=xlUp
End If
Next k




'"""""""""Application Settings""""""""
Application.DisplayAlerts = True 'Stops the program from asking if it is ok for the macro to delete sheets
Application.ScreenUpdating = True 'Stops program from showing what is happening when the macro is running
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
'"""""""""""""""""""""""""""""""""""""


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,544
Messages
6,125,444
Members
449,226
Latest member
Zimcho

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