ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro is deleting everything! (https://www.excelbanter.com/excel-discussion-misc-queries/23255-macro-deleting-everything.html)

vmagal1

Macro is deleting everything!
 
Can anyone tell me why, when I run a macro, it deletes a lot of my
information? I'm just inserting some columns and formatting a row.

Debra Dalgleish

If you paste the macro code into a message, and post it, someone may be
able to help you solve the problem.

vmagal1 wrote:
Can anyone tell me why, when I run a macro, it deletes a lot of my
information? I'm just inserting some columns and formatting a row.



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


vmagal1

Rows("1:1").Select
Selection.Insert Shift:=xlDown
Range("A1").Select
ActiveCell.FormulaR1C1 = "RKP3830C1TEST (Container Report) Date"
Range("A1:M1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Rows("1:1").Select
Selection.RowHeight = 24
Columns("A:A").Select
Range("A2").Activate
Selection.Insert Shift:=xlToRight
Range("A1:N1").Select
Range("B1").Activate
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.UnMerge
With Selection
.HorizontalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Columns("I:I").Select
Range("I2").Activate
Selection.Insert Shift:=xlToRight
Range("I2").Select
ActiveCell.FormulaR1C1 = "Ocean"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Range("K2").Select
End Sub


"Debra Dalgleish" wrote:

If you paste the macro code into a message, and post it, someone may be
able to help you solve the problem.

vmagal1 wrote:
Can anyone tell me why, when I run a macro, it deletes a lot of my
information? I'm just inserting some columns and formatting a row.



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



Dave Peterson

Scroll to your right a few columns.

I put my test data in A1:N47, after I ran your macro, my test data was in
AN2:BA48.

So maybe it's not deleted--just shifted over. (You do insert a bunch with lots
of columns selected.)

vmagal1 wrote:

Rows("1:1").Select
Selection.Insert Shift:=xlDown
Range("A1").Select
ActiveCell.FormulaR1C1 = "RKP3830C1TEST (Container Report) Date"
Range("A1:M1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Rows("1:1").Select
Selection.RowHeight = 24
Columns("A:A").Select
Range("A2").Activate
Selection.Insert Shift:=xlToRight
Range("A1:N1").Select
Range("B1").Activate
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.UnMerge
With Selection
.HorizontalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Columns("I:I").Select
Range("I2").Activate
Selection.Insert Shift:=xlToRight
Range("I2").Select
ActiveCell.FormulaR1C1 = "Ocean"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Range("K2").Select
End Sub

"Debra Dalgleish" wrote:

If you paste the macro code into a message, and post it, someone may be
able to help you solve the problem.

vmagal1 wrote:
Can anyone tell me why, when I run a macro, it deletes a lot of my
information? I'm just inserting some columns and formatting a row.



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



--

Dave Peterson


All times are GMT +1. The time now is 01:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com