Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.
Sub DeleteRowWithContents() '======================================================================== ' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D '======================================================================== Last = Cells(Rows.Count, "D").End(xlUp).Row For i = Last To 1 Step -1 If (Cells(i, "B").Value) = "MLD24" Then 'Cells(i, "A").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW Cells(i, "A").EntireRow.Delete() End If Next i End Sub
Public Sub deleterowsfromexcel() Dim xlApp As Excel.Application = Nothing Dim xlWorkBooks As Excel.Workbooks = Nothing Dim xlWorkBook As Excel.Workbook = Nothing Dim xlWorkSheet As Excel.Worksheet = Nothing xlApp = New Excel.Application xlApp.DisplayAlerts = False xlWorkBooks = xlApp.Workbooks xlWorkBook = xlWorkBooks.Open("C:\Temp2\pass.csv") xlWorkSheet = CType(xlWorkBook.ActiveSheet, Excel.Worksheet) 'MessageBox.Show(xlWorkSheet.Name) Dim xlCells As Excel.Range = Nothing Dim therows As Integer = xlWorkSheet.UsedRange.Rows.Count() MsgBox(therows.ToString) Dim SingleCellToRead = xlWorkSheet.Range("B2:B" & xlWorkSheet.UsedRange.Rows.Count()) For Each row In SingleCellToRead.Rows.Value MsgBox(row.ToString) Next xlApp = Nothing xlWorkBooks = Nothing xlWorkBook = Nothing xlWorkSheet = Nothing xlWorkBook.Close() xlApp.UserControl = True xlApp.Quit() End Sub
Join the community of 500,000 technology professionals and ask your questions.