djdiplomat
New Member
- Joined
- Sep 7, 2009
- Messages
- 32
Hi
I'm using the following to delete rows when cell value is blank. It first calculates the sum of the row column D to I, places the result in J then copies column J, paste special values then uses some more code to delete the blank cells.
This 'remove blank' code works fine on it's own but when run in this macro it tries to work but then I get 'Excel is not responding' and have to shut down. Is there a better way to achieve this? Length of data (rows) is always different.
Here is the code I'm using:
'Remove rows from Infor data
Sheets("Infor Data").Select
Range("J1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Empty"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-5]:RC[-1])"
Range("J2").Select
Selection.AutoFill Destination:=Range("J2:J30000")
Range("J2:J30000").Select
Columns("J:J").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Sheets("Infor Data").Select
Columns("J:J").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Thanks
Will
I'm using the following to delete rows when cell value is blank. It first calculates the sum of the row column D to I, places the result in J then copies column J, paste special values then uses some more code to delete the blank cells.
This 'remove blank' code works fine on it's own but when run in this macro it tries to work but then I get 'Excel is not responding' and have to shut down. Is there a better way to achieve this? Length of data (rows) is always different.
Here is the code I'm using:
'Remove rows from Infor data
Sheets("Infor Data").Select
Range("J1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Empty"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-5]:RC[-1])"
Range("J2").Select
Selection.AutoFill Destination:=Range("J2:J30000")
Range("J2:J30000").Select
Columns("J:J").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Sheets("Infor Data").Select
Columns("J:J").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Thanks
Will