ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code for Deleting rows by verification (https://www.excelbanter.com/excel-programming/300355-vba-code-deleting-rows-verification.html)

hoffman3

VBA code for Deleting rows by verification
 
Alright i have a list of variables like this
desired output after vba:
a 1 6 a 1 6
b 2 2 c 3 1
c 3 1
d 4 8

Is there a way to alter the row deletion code to search multipl
columns for the number one and if the row doesn't have a 1 then i
will be deleted from the sheet. Thanks
Eric Hoffma

--
Message posted from http://www.ExcelForum.com


hoffman3[_2_]

VBA code for Deleting rows by verification
 
chart suppose to look like this:

a 1 6
b 2 2
c 3 1
d 4 8


desired output after vba:
a 1 6
c 3

--
Message posted from http://www.ExcelForum.com


Ron de Bruin

VBA code for Deleting rows by verification
 
Try this

This will check each whole row for the value 1

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1
With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1

If Application.WorksheetFunction.CountIf(.Rows(Lrow), "1") = 0 _
Then .Rows(Lrow).Delete
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"hoffman3 " wrote in message ...
Alright i have a list of variables like this
desired output after vba:
a 1 6 a 1 6
b 2 2 c 3 1
c 3 1
d 4 8

Is there a way to alter the row deletion code to search multiple
columns for the number one and if the row doesn't have a 1 then it
will be deleted from the sheet. Thanks
Eric Hoffman


---
Message posted from http://www.ExcelForum.com/




hoffman3[_3_]

VBA code for Deleting rows by verification
 
The code in the last reply just seemed to freeze up excel, i waited fo
5 minutes then finally just restarted it. Thanks for the time though.

Eric Hoffma

--
Message posted from http://www.ExcelForum.com


Ron de Bruin

VBA code for Deleting rows by verification
 
How many rows with Data you have?
If you use Ctrl End in what row are you.

Look here if it is below your last row with data
http://www.contextures.com/xlfaqApp.html#Unused


--
Regards Ron de Bruin
http://www.rondebruin.nl


"hoffman3 " wrote in message ...
The code in the last reply just seemed to freeze up excel, i waited for
5 minutes then finally just restarted it. Thanks for the time though.

Eric Hoffman


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 08:37 AM.

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