+ Reply to Thread
Results 1 to 3 of 3

Macro Broken

  1. #1
    Forum Contributor
    Join Date
    11-13-2013
    Location
    California
    MS-Off Ver
    Excel 365 Apps for enterprise
    Posts
    180

    Macro Broken

    Hello all,

    A new employee screwed up and saved a file over our macro. Luckily, I had an older version saved, but unluckily, it's not working right and I don't know code well enough to figure out why it's not doing what it needs to do.

    Where it's broken is that when it copies the headers to the permlrg file, all the data below B1:O1 is disappearing. Below is the code, tell me if you need where my problem might be. Thanks!



    Sub BENEFITAR5()
    '
    ' BENEFITAR5 Macro
    '

    '
    ChDir "G:\DOWNLOAD"
    Workbooks.OpenText Filename:="G:\DOWNLOAD\Permlrg.xls", Origin:=437, _
    StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
    ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
    , Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
    Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), _
    Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1)), _
    TrailingMinusNumbers:=True
    Columns("K:K").Select
    Rows("2:68").Select
    Selection.Delete Shift:=xlUp
    Cells.Select
    ActiveWorkbook.Worksheets("Permlrg").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Permlrg").Sort.SortFields.Add Key:=Range("N2:N58") _
    , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Permlrg").Sort
    .SetRange Range("A1:N58")
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.ColumnWidth = 22.43
    ChDir "G:\Templates\BENEFITS"
    Workbooks.Open Filename:="G:\Templates\BENEFITS\BENEFIT AR HEADERS.xlsx", _
    Origin:=xlWindows
    Range("A9:A16").Select
    Selection.Copy
    Windows("Permlrg.xls").Activate
    Range("A1").Select
    ActiveSheet.Paste
    Windows("BENEFIT AR HEADERS.xlsx").Activate
    Range("A1:G1").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Permlrg.xls").Activate
    Range("P1").Select
    ActiveSheet.Paste
    Sheets("Permlrg").Select
    Sheets("Permlrg").Name = "ORIG"
    Sheets("ORIG").Select
    Columns("A:A").EntireColumn.AutoFit
    Windows("BENEFIT AR HEADERS.xlsx").Activate
    Windows("BENEFIT AR MACRO.xls").Activate
    End Sub


    Thanks!
    Last edited by JennOlsen; 04-12-2019 at 12:48 PM.

  2. #2
    Forum Contributor
    Join Date
    11-13-2013
    Location
    California
    MS-Off Ver
    Excel 365 Apps for enterprise
    Posts
    180

    Re: Macro Broken

    I fixed it. I just spotted the line of code that was deleting my lines. Tested the macro and seems to be working properly now.

    Thanks!

  3. #3
    Forum Contributor
    Join Date
    05-10-2012
    Location
    Paris, France
    MS-Off Ver
    2016/365
    Posts
    123

    Re: Macro Broken

    Hi JennOlsen

    Try something as
    Please Login or Register  to view this content.
    @+

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. I have broken my macro
    By cdhampshire in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-27-2017, 01:18 PM
  2. [SOLVED] Complex macro broken, please send help
    By Ashe77 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2016, 09:48 AM
  3. Tally Macro: Broken Code
    By jaredmccullough in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-15-2014, 04:43 PM
  4. [SOLVED] Basic Macro suddenly broken
    By Alaniz/MetroGroup in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2014, 10:40 AM
  5. MACRO that created new tabs is broken
    By lissa843 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2010, 05:44 PM
  6. Macro broken with workbook name change
    By Annabelle in forum Excel General
    Replies: 2
    Last Post: 02-02-2006, 08:50 PM
  7. Broken macro in Excel 2003
    By kmbarz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2005, 08:06 AM

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