Range as long macro

KaaNunL

New Member
Joined
Jun 27, 2019
Messages
9
Hi Guys,

I have selected DIm Ingrows As Long and set it up as Range ("C2:C" & lngrows & ",D2:D" & lngrows & ",E2:E" & lngrows & ",F2:F" & lngrows & ",G2:G" & lngrows & ",H2:H" & lngrows & ",I2:I" & Ingrows & ",J2:J").Select Selection.Copy

some how it does not work :( most probably i am selecting something wrong or missed

Do you have any idea how to finish this ?

Code:
Sub GetFilterForFails12()
'
' GetFilterForFails Macro
'


'


    Dim CurrentYear As Integer
    Dim Previousweek As Integer
    Dim slaUK As String
    Dim lFails As Long
    Dim Ingrows As Long
    


    CurrentYear = DatePart("yyyy", Date)
    Previousweek = DatePart("ww", Date) - 1
    slaUK = "SLA builder UK.xlsm"


    Sheets("SLA - Order delivery").Select
    Selection.AutoFilter
    ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=30, _
        Criteria1:=CurrentYear
    ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=29, _
        Criteria1:=Previousweek
    ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=28, _
        Criteria1:="Fail"
        
Range("C2:C" & lngrows & ",D2:D" & lngrows & ",E2:E" & lngrows & ",F2:F" & lngrows & ",G2:G" & lngrows & ",H2:H" & lngrows & ",I2:I" & Ingrows & ",J2:J").Select
    Selection.Copy
    Windows("SLA mitigation template v2.xlsx").Activate
    Range("A3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Windows("SLA builder UK.xlsm").Activate


        On Error Resume Next
lFails = ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").DataBodyRange.SpecialCells(xlCellTypeVisible).Rows.Count
On Error GoTo 0


If lFails = 0 Then MsgBox "Keep Calm and There were no FAILS this week :)"
        
End Sub


Many Thanks :)
 
Last edited by a moderator:
And this is working without opening the workbook
:confused: Workbooks.Open does what it says, it opens the workbook.

I've no idea what you mean about saving a blank file.
If you want to save the newly opened workbook with a new name, just use the macro recorder to record yourself doing a SaveAs.
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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