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(quot;H:Kquot;).Select
Selection.Delete Shift:=xlToLeft
Columns(quot;Cquot;).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(quot;A2quot;), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range(quot;H19quot;).Select
ActiveWorkbook.Save
ActiveWindow.WindowState = xlNormal
ActiveWindow.WindowState = xlMaximized
End SubWhen 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(quot;H:kquot;).Delete
Columns(quot;c:dquot;).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
quot;Traciquot; gt; wrote in message
...
gt; I've built a macro to perform some general formatting. The only catch is
gt; that this spreadsheet is an export from a web based application. The
gt; headers
gt; export as hyperlinks, so I have converted those headers to text PRIOR to
gt; running the macro.
gt;
gt; I've included the code from the macro here. Does anyone see any reason
gt; why
gt; all the data seems to disappear from the spreadsheet when the macro
gt; completes? It's like you highlighted all the columns and deleted them.
gt; The
gt; title bar still shows that I am in the correct spreadsheet.
gt;
gt; Sub Traci()
gt; '
gt; ' Traci Macro
gt; ' Macro recorded 5/18/2006 by TReavis
gt; '
gt; ' Keyboard Shortcut: Ctrl b
gt; '
gt; Columns(quot;H:Kquot;).Select
gt; Selection.Delete Shift:=xlToLeft
gt; Columns(quot;Cquot;).Select
gt; Selection.Delete Shift:=xlToLeft
gt; Cells.Select
gt; With Selection
gt; .VerticalAlignment = xlBottom
gt; .Orientation = 0
gt; .AddIndent = False
gt; .ShrinkToFit = False
gt; .ReadingOrder = xlContext
gt; .MergeCells = False
gt; End With
gt; Selection.Sort Key1:=Range(quot;A2quot;), Order1:=xlAscending, Header:=xlYes, _
gt; OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
gt; DataOption1:=xlSortNormal
gt; Range(quot;H19quot;).Select
gt; ActiveWorkbook.Save
gt; ActiveWindow.WindowState = xlNormal
gt; ActiveWindow.WindowState = xlMaximized
gt; End Sub
gt;
- Jan 12 Mon 2009 20:48
Macro wiping out worksheet
close
全站熱搜
留言列表
發表留言