Macros not deleting selected ranges

Thomo4321

New Member
Joined
Apr 18, 2019
Messages
44
Office Version
  1. 2016
Platform
  1. Windows
Afternoon,

I have recorded the following Macro on Excel, All i am trying to do is delete all the unwanted info from the reports i download from the system at work and have it set up to how i want it at the hit of the button.

I keep getting a debug message with the activesheet.Paste being highlighted
I have not touched anything with in the macro. Also every time i redo the Macro to try to fix it, it keeps coming up with a different error.

Help!!! im pulling my hair out

I require, in the same order, Columns F,G,A,B,C,E,J,M and N
Then have it Format it as a Table Blue, Table Style Medium 9



Code:
Sub BinLocationReport()
'
' BinLocationReport Macro
'


'
    Sheets("Parts Bin Location Report201904").Select
    Sheets("Parts Bin Location Report201904").Name = "Parts Bin Location Report"
    Sheets.Add After:=ActiveSheet
    Sheets("Parts Bin Location Report").Select
    Columns("F:F").Select
    Selection.Cut
    Columns("F:G").Select
    Application.CutCopyMode = False
    Selection.Cut
    Sheets("Sheet1").Select
    Range("A1").Select
    ActiveSheet.Paste
    Sheets("Parts Bin Location Report").Select
    Columns("A:C").Select
    Selection.Cut
    Sheets("Sheet1").Select
    Range("C1").Select
    ActiveSheet.Paste
    Sheets("Parts Bin Location Report").Select
    Columns("E:E").Select
    Selection.Cut
    Sheets("Sheet1").Select
    Range("F1").Select
    ActiveSheet.Paste
    Sheets("Parts Bin Location Report").Select
    Columns("J:J").Select
    Selection.Cut
    Sheets("Sheet1").Select
    Range("G1").Select
    ActiveSheet.Paste
    Sheets("Parts Bin Location Report").Select
    Columns("M:N").Select
    Selection.Cut
    Sheets("Sheet1").Select
    Range("H1").Select
    ActiveSheet.Paste
    Range("A1:I4328").Select
    Range("C4").Activate
    Application.CutCopyMode = False
    ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$I$4328"), , xlYes).Name = _
        "Table1"
    Range("Table1[#All]").Select
    ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium9"
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Cells.Select
    Cells.EntireColumn.AutoFit
    Columns("C:E").Select
    Selection.NumberFormat = "@"
    Range("J2").Select
    ActiveSheet.Paste
    Range("J2").Select
    ActiveCell.FormulaR1C1 = _
        "=IF([@[Qty_In_Pick]]+[@[Qty_On_Hand]]+[@[Qty_On_Order_Supplier]]<=0,""Y"",""N"")"
    Range("J3").Select
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=10, Criteria1:= _
        "Y"
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=10, Criteria1:= _
        "N"
    Rows("2:2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Delete Shift:=xlUp
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=10
    Columns("J:J").Select
    Selection.Delete Shift:=xlToLeft
    Range("D2").Select
End Sub


Unfortunately i cannot post attachments

Your Help in this is much appreciated.

Thanks
 
Last edited by a moderator:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
you don't tell what the error messages are . . please explain.

But first . . try to clean up your recorded macro:
for instance:
Code:
Sheets("Parts Bin Location Report").Select
Columns("E:E").Select
Selection.Cut
Sheets("Sheet1").Select
Range("F1").Select
ActiveSheet.Paste
after cleanup:
Code:
Sheets("Parts Bin Location Report").Columns("E:E").Cut
Sheets("Sheet1").Range("F1").Paste
so no selecting, activesheet, etc.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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