Hi,
When I run the code below for some reason I keep getting an Excel error and Excel crashes? It happens before I delete some rows. I have noted below The point at which Excel crashes. Any help would be appreciated.
Public ProcessFile
Public AppDir$
Public old As Variant
Public current As Variant
Public myWB$
Public r As Long
Public DataRow As Long
Public CS_PB As String
Public Name As String
Sub PasteSpecial()
'ctrl-l shortcut macro
'paste formulas as values
Range(Cells(3, 3), Cells(Range("C3"
.End(xlDown).Row, 4)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("C3"
.Select
'format column
Columns("D
"
.Select
Selection.NumberFormat = "#,##0"
Columns("E:E"
.Select
Selection.NumberFormat = "General"
Range("C3"
.Select
'add formula for cap
Range(Cells(3, 5), Cells(Range("A3"
.End(xlDown).Row, 5)).FormulaR1C1 = "=IF(RC[-1]="""",""?"",IF(RC[-1]=""#N/A N.A."",""?"",IF(RC[-1]=""#N/A Sec"",""?"",IF(RC[-1]>=2500000000,""L"",IF(AND(RC[-1]>=0,RC[-1]<2500000000),""S"",""?""
))))"
'get sheet ready to loop through to change the date to character
Columns("H:H"
.Select
Selection.Insert Shift:=xlToRight
'loop through cells to update data
r = 3
Do Until Cells(r, 9).Value = ""
If Cells(r, 9).Value <> "" Then
Cells(r, 1).Value = Format(Cells(r, 1), ">"
Cells(r, 4).Select
ActiveCell.FormulaR1C1 = Cells(r, 4).Value
Cells(r, 8).Select
ActiveCell.FormulaR1C1 = _
"=TEXT(YEAR(RC[-1]),""0000""
& TEXT(MONTH(RC[-1]),""00""
& TEXT(DAY(RC[-1]),""00""
"
End If
r = r + 1
Loop
Columns("H:H"
.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("H1"
.Value = "Trade Date"
ActiveWorkbook.Save
Deleting
End Sub
***********************HERE**********************
Sub Deleting()
Columns("B:H"
.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Rows("2:2"
.Select
Selection.Delete Shift:=xlUp
Columns("I:I"
.Select
Selection.Delete Shift:=xlToLeft
Range("A1"
.Select
End Sub
When I run the code below for some reason I keep getting an Excel error and Excel crashes? It happens before I delete some rows. I have noted below The point at which Excel crashes. Any help would be appreciated.
Public ProcessFile
Public AppDir$
Public old As Variant
Public current As Variant
Public myWB$
Public r As Long
Public DataRow As Long
Public CS_PB As String
Public Name As String
Sub PasteSpecial()
'ctrl-l shortcut macro
'paste formulas as values
Range(Cells(3, 3), Cells(Range("C3"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("C3"
'format column
Columns("D
Selection.NumberFormat = "#,##0"
Columns("E:E"
Selection.NumberFormat = "General"
Range("C3"
'add formula for cap
Range(Cells(3, 5), Cells(Range("A3"
'get sheet ready to loop through to change the date to character
Columns("H:H"
Selection.Insert Shift:=xlToRight
'loop through cells to update data
r = 3
Do Until Cells(r, 9).Value = ""
If Cells(r, 9).Value <> "" Then
Cells(r, 1).Value = Format(Cells(r, 1), ">"
Cells(r, 4).Select
ActiveCell.FormulaR1C1 = Cells(r, 4).Value
Cells(r, 8).Select
ActiveCell.FormulaR1C1 = _
"=TEXT(YEAR(RC[-1]),""0000""
End If
r = r + 1
Loop
Columns("H:H"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("H1"
ActiveWorkbook.Save
Deleting
End Sub
***********************HERE**********************
Sub Deleting()
Columns("B:H"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Rows("2:2"
Selection.Delete Shift:=xlUp
Columns("I:I"
Selection.Delete Shift:=xlToLeft
Range("A1"
End Sub