File size increasing

JoeyGaspard

Board Regular
Joined
Jul 22, 2019
Messages
147
Hi all, with some of the members help, I was able to create a worksheet that does exactly what I need, so thanks to all that helped! Now, my problem is, every time I run the macro, my file size increases dramatically! how can I fix this? the code is below, it is a compilation for several different functions:

VBA Code:
Sub PasteSpecial_ValuesOnly()

'Clear UploadData Cells
Worksheets("PayrollData").Select
    Range("A2:F50").Select
    Selection.ClearContents
   
'Import Payroll Data
   Dim Ws As Worksheet
  
   Set Ws = Worksheets("PayrollData")
   With Worksheets("PayrollReportImport")
      .Range("A1").AutoFilter 1, "12-*"
      .AutoFilter.Range.Offset(1).EntireRow.Copy Ws.Range("A" & Rows.Count).End(xlUp).Offset(1)
      .AutoFilterMode = False
   End With
 
 
'ClearGeneralJournal Macro
    Worksheets("GeneralJournal").Select
    Range("B17:eek:54").Select
    Selection.Clear

'Copy A Range of Data
  Worksheets("UploadData").Range("A2:M21").Copy

'PasteSpecial Values Only
  Worksheets("GeneralJournal").Range("B17").PasteSpecial Paste:=xlPasteValues

'Clear Clipboard
  Application.CutCopyMode = False
 
'Deletes blank rows if cells in Column B are empty
  On Error Resume Next
    Worksheets("GeneralJournal").Select
    Range("B17:B54").Select
    Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    Range("B17").Select
End Sub

TIA for any help!
 
Last edited by a moderator:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Range("B17:eek:54")

In that line you have additional ":"

But that's not the problem.
__________________________________________________________________________
Your macro has no problems. Do you have formulas on your sheets?

Maybe you should copy the data from each sheet into a new book.
Create a new book, in the new book create the sheets with the names you have in the current book.
Select a sheet of the current book, select only the range of data, copy the data and paste in the corresponding sheet of the new book and so on for each of the sheets.
Try the macro again.
 
Upvote 0
Check both worksheets for usedrange size !
Press CTRL + END and see where the cursor gos to.....if it waaaay down the worksheet, you will need to reset the used range !!
 
Upvote 0
Check both worksheets for usedrange size !
Press CTRL + END and see where the cursor gos to.....if it waaaay down the worksheet, you will need to reset the used range !!

Michael, thank you! that was the problem, for some reason one of my tables had over 1m rows, Again, thank you so much!
 
Upvote 0
Glad to help...and thanks for the feedback..?
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

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