Results 1 to 10 of 10

VBA code adjustment to include only current month and previous month automatically.

Threaded View

  1. #1
    Registered User
    Join Date
    08-24-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    78

    VBA code adjustment to include only current month and previous month automatically.

    Need the code below to automatically include current month and previous month without having to change the code each month. Thanks!

    Sub ImportServiceJobs()
    
    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
        .EnableEvents = False
    
        Workbooks.Open Filename:="F:\Purchasing\SERVICE.xls"
    
        Dim LastRow As Long
        
        With Sheets("Master")
            LastRow = .Cells(Rows.Count, 2).End(xlUp).Row
            .Range("$A$4298:$F$14000").AutoFilter Field:=2, Criteria1:=">" & CStr(Date - Day(Date)), Operator:=xlAnd
            .Range("B2:F" & LastRow).SpecialCells(xlCellTypeVisible).Copy _
                Workbooks("Test MATERIAL - TOOL REQUISITION FORM.xlsm").Worksheets("5 Digit Job List").Range("A2")
            .AutoFilterMode = False
        End With
    
        ActiveWorkbook.Close
    
        .ScreenUpdating = True
        .DisplayAlerts = True
        .EnableEvents = True
    End With
    
    End Sub
    Last edited by ElmerFud; 08-04-2015 at 08:17 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Formula for amount on previous month based on current month
    By Yu Marquez in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-21-2014, 12:42 AM
  2. [SOLVED] "copy worksheet from previous month and rename to current month" modified?
    By jerrydiaz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-07-2013, 08:18 AM
  3. Macro using vlookups comparing 2 months paysheet(previous month and current month)
    By srinivasan1965 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-07-2012, 03:45 AM
  4. Replies: 5
    Last Post: 10-04-2012, 07:06 AM
  5. [SOLVED] VBA to identify the current month and previous month based on system date
    By ravikumar00008 in forum Excel General
    Replies: 10
    Last Post: 07-26-2012, 10:04 AM
  6. [SOLVED] copy worksheet from previous month and rename to current month
    By Dan E. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-08-2005, 05:45 PM
  7. [SOLVED] automatically update chart plotting current month and previous 6
    By Jane in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-01-2005, 06:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1