ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting rows based on cell criteria (https://www.excelbanter.com/excel-programming/296462-deleting-rows-based-cell-criteria.html)

jgranda

Deleting rows based on cell criteria
 
I would like to write a macro that takes a standard output file into a new file that can be used by a software package that requires a slightly different file. I am a novice VB programmer

The hurdle I would like to solve is removing rows of data that must be removed. I know the rows I want to eliminate since they all have the value "Credit Rating: Foreign Currency" in column B. What is the best way to remove these rows

BTW, these are generally small files of less than 500 records

Thanks...Joe

RSnyder

Deleting rows based on cell criteria
 
If everyline has something in it on the column B cell use this otherwise you a terminating value to no when this would terminate

Worksheet("worksheet name").Activat
If moCurrCell.Value = "Credit Rating: Foreign Currency" The
Selection.EntireRow.Delet
Set CurrLine = Range("B1"
Set NextLine = CurrLine.Offset(0, 1
CurrLine.Selec
D
If CurrLine.Value = "Credit Rating: Foreign Currency" The
Selection.EntireRow.Delet
End I
Set CurrLine = NextLin
Set NextLine = CurrLine.Offset(0, 1
CurrLine.Selec
Loop Until CurrLine.Value = "

Change "Loop Until CurrLine. Value = " comparison of "" to "xx" if you know that the last line has an "xx" in it.



All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com