Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting rows in two columns with a code in visual basic Ruben Excel Discussion (Misc queries) 5 August 27th 08 09:10 AM
Ideal Code deleting rows/based on bold text Samm Excel Programming 1 April 9th 04 03:20 AM
Deleting code in a file with code.. KimberlyC Excel Programming 3 March 4th 04 09:24 PM
visual basic macro code for deleting referenced rows mudraker[_132_] Excel Programming 3 January 29th 04 05:01 PM
visual basic macro code for deleting referenced rows Frank Kabel Excel Programming 0 January 28th 04 10:05 PM


All times are GMT +1. The time now is 02:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"