May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.
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
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Vb.net threads keep increasing||2||59|
|vb.net datagrid scroll automatically to the first found row||11||44|
|VB.net VSTO Excel Ribbon error||4||27|
|Open telerik datetime picker programmatically||13||41|
Join the community of 500,000 technology professionals and ask your questions.