+ Reply to Thread
Results 1 to 2 of 2

Macro wiping out worksheet

  1. #1
    Traci
    Guest

    Macro wiping out worksheet

    I've built a macro to perform some general formatting. The only catch is
    that this spreadsheet is an export from a web based application. The headers
    export as hyperlinks, so I have converted those headers to text PRIOR to
    running the macro.

    I've included the code from the macro here. Does anyone see any reason why
    all the data seems to disappear from the spreadsheet when the macro
    completes? It's like you highlighted all the columns and deleted them. The
    title bar still shows that I am in the correct spreadsheet.

    Sub Traci()
    '
    ' Traci Macro
    ' Macro recorded 5/18/2006 by TReavis
    '
    ' Keyboard Shortcut: Ctrl+b
    '
    Columns("H:K").Select
    Selection.Delete Shift:=xlToLeft
    Columns("C:D").Select
    Selection.Delete Shift:=xlToLeft
    Cells.Select
    With Selection
    .VerticalAlignment = xlBottom
    .Orientation = 0
    .AddIndent = False
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
    End With
    Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    Range("H19").Select
    ActiveWorkbook.Save
    ActiveWindow.WindowState = xlNormal
    ActiveWindow.WindowState = xlMaximized
    End Sub


  2. #2
    Don Guillett
    Guest

    Re: Macro wiping out worksheet

    When I run yours or this I get a,b,e,f,g columns left. Notice NO selections.
    You probably don't want ALL of the cells and you probably only want to
    unmerge the cells?

    Sub deletecolumns()
    Columns("H:k").Delete
    Columns("c:d").Delete
    With Cells 'probably only want merge cells
    .VerticalAlignment = xlBottom
    .Orientation = 0
    .AddIndent = False
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
    End With
    End Sub

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Traci" <[email protected]> wrote in message
    news:[email protected]...
    > I've built a macro to perform some general formatting. The only catch is
    > that this spreadsheet is an export from a web based application. The
    > headers
    > export as hyperlinks, so I have converted those headers to text PRIOR to
    > running the macro.
    >
    > I've included the code from the macro here. Does anyone see any reason
    > why
    > all the data seems to disappear from the spreadsheet when the macro
    > completes? It's like you highlighted all the columns and deleted them.
    > The
    > title bar still shows that I am in the correct spreadsheet.
    >
    > Sub Traci()
    > '
    > ' Traci Macro
    > ' Macro recorded 5/18/2006 by TReavis
    > '
    > ' Keyboard Shortcut: Ctrl+b
    > '
    > Columns("H:K").Select
    > Selection.Delete Shift:=xlToLeft
    > Columns("C:D").Select
    > Selection.Delete Shift:=xlToLeft
    > Cells.Select
    > With Selection
    > .VerticalAlignment = xlBottom
    > .Orientation = 0
    > .AddIndent = False
    > .ShrinkToFit = False
    > .ReadingOrder = xlContext
    > .MergeCells = False
    > End With
    > Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _
    > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    > DataOption1:=xlSortNormal
    > Range("H19").Select
    > ActiveWorkbook.Save
    > ActiveWindow.WindowState = xlNormal
    > ActiveWindow.WindowState = xlMaximized
    > End Sub
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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