score:2
Accepted answer
Option Explicit
Sub test()
Dim r6 As Range, r7 As Range
Dim ws As Worksheet
Dim LastRow As Long
Dim printareaP As Range, Cell As Range
Set ws = ThisWorkbook.Worksheets("Pricelist")
LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
Set printareaP = ws.Range(ws.Cells(1, 1), ws.Cells(LastRow, 1))
For Each Cell In printareaP
If IsNumeric(Cell.Value) Then
ws.Cells(Cell.Row - 1, 1).EntireRow.Delete
End If
Next Cell
End Sub
score:1
Sub DeleteRowAbove()
Dim r6 As Range, r7 As Range
With ThisWorkbook.Worksheets("Pricelist").Range("Print_Area")
For Each r6 In .Range("A2", .Range("A" & .Rows.Count).End(xlUp))
If Not IsEmpty(r6) And IsNumeric(r6) Then
If r7 Is Nothing Then
Set r7 = r6.Offset(-1, 0)
Else
Set r7 = Union(r7, r6.Offset(-1, 0))
End If
End If
Next
End With
If Not r7 Is Nothing Then
r7.EntireRow.Delete ' .Hidden = True
Set r7 = Nothing
End If
End Sub
Source: stackoverflow.com
Related Articles
- Excel VBA remove one row above number in column
- Excel column number from column name
- How to find text in a column and saving the row number where it is first found - Excel VBA
- How to format column to number format in Excel sheet?
- Get column number by cell value in Excel
- Excel to remove duplicates one column at a time for many columns
- How to set Excel column widths to a certain number of pixels?
- How to remove spaces from an entire Excel column using VBA?
- Remove ALL duplicates from column A in Excel
- Excel VBA - Find Row Number for Given Value in a Table Column
- Excel VBA Copy block of cells with variable row and column number
- VBA convert Excel Style Column Name (with 52 charset) to original number
- Excel Macro Loop to concatenate columns from proceeding rows into a column in row above
- VBa and Excel : sum up highlighted cells value from specific item number and then subtract to cells value from other table and display in next column
- VBA Excel 2007 : Need to loop copy and loop count number except zero every row above
- How to get the number of rows in column A starting from a certain cell in excel
- Excel VBA - For next loop - find column number of displayed columns and result stored
- Function to convert column number to letter?
- Create excel ranges using column numbers in vba?
- How to count the number of rows in excel with data?
- Excel how to find values in 1 column exist in the range of values in another
- VBA Excel sort range by specific column
- How to find a value in an excel column by vba code Cells.Find
- Excel VBA: how to programmatically remove the marching ants after range.copy
- Refer to Excel cell in Table by header name and row number
- Finding the number of non-blank columns in an Excel sheet using VBA
- Getting the number of filled cells in a column (VBA)
- How to import long number from csv to excel without converting to scientific notation in VBA
- Number of elements in a single dimension variant array in excel
- Excel VBA- remove part of the string
- How to strikethrough text in VBA - Programmatically?
- How do I convert a stdole.StdPicture to a different Type?
- Worksheet_Change Never FIres
- Inserting text and fields in Word 2010 header without using .Select
- VBA "This Command is not Available because no document is open"
- Updating email subject in Outlook VBA
- Convert HTML-table to Excel using VBA
- VBA Error handling on ADODB Connection.Open
- Setting a slicer to the value of a variable using VBA macro (Excel)
- Difference between .Delete and .Clear in Excel VBA?
- How to exclude the first row from sorting(vba)
- Variable between worksheet and module not cooperating
- Search a string from text file & Return the Line Number using VBA
- Run PowerShell FTP upload script from VBA and issue message box with the result
- How to send an excel file with a macro by email
- Close UserForm from Module
- Excel Macro in CSV
- How to use VBA to read the values of a checkbox from an Excel userform
- I'm trying to copy the active worksheet to the end of the workbook
- How to set cursor after a table in word document using VBA