Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2013, 02:05 PM
joflow21 joflow21 is offline Deleting rows with specific criteria Windows XP Deleting rows with specific criteria Office 2010 32bit
Novice
Deleting rows with specific criteria
 
Join Date: Oct 2013
Posts: 8
joflow21 is on a distinguished road
Default


Thank you pecoflyer. How would I write it if I also want to delete rows where the value of column D is 0?
Reply With Quote
  #2  
Old 11-21-2013, 05:09 PM
BobBridges's Avatar
BobBridges BobBridges is offline Deleting rows with specific criteria Windows 7 64bit Deleting rows with specific criteria Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

I'd never used that particular value of SpecialCells; sounds like just the ticket.

Joflow, the number of incoming worksheets may change every time; but since the program is doing the importing, surely it can count them as it happens?

But if the headers are all the same, this should work too:
Code:
Set so = TheSubjectWorksheet
jr = 1
val1 = so.Cells(jr, 1).Value 'column header for col A
Do
  jr = jr + 1
  Loop While so.Cells(jr, 1).Value = val1
Range(so.Cells(2, 1), so.Cells(jr - 1, 1).EntireRow.Delete
(I haven't testing this code; something like it should be right, though.)
Reply With Quote
  #3  
Old 11-22-2013, 12:10 PM
joflow21 joflow21 is offline Deleting rows with specific criteria Windows XP Deleting rows with specific criteria Office 2010 32bit
Novice
Deleting rows with specific criteria
 
Join Date: Oct 2013
Posts: 8
joflow21 is on a distinguished road
Default

Thank you Bob. I did wind up using a different code since the value in column A would be the same in all of the headers. I just used:

Sub DeleteRepeatedHeader()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If Range("A" & i).Value = "PLANID" Then Rows(i).Delete
Next i
End Sub
Reply With Quote
  #4  
Old 11-22-2013, 01:44 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Deleting rows with specific criteria Windows 7 64bit Deleting rows with specific criteria Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,920
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

Quote:
Originally Posted by joflow21 View Post
Thank you pecoflyer. How would I write it if I also want to delete rows where the value of column D is 0?

Again, I'm no VBA man, but as far as I know the fastest way is to use the auto filter from within a macro. There are examples around.
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #5  
Old 11-22-2013, 12:10 PM
joflow21 joflow21 is offline Deleting rows with specific criteria Windows XP Deleting rows with specific criteria Office 2010 32bit
Novice
Deleting rows with specific criteria
 
Join Date: Oct 2013
Posts: 8
joflow21 is on a distinguished road
Default

Thank you.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting rows with specific criteria Mail Merge to create specific number of table rows flackend Mail Merge 4 12-01-2023 02:49 PM
Deleting rows with specific criteria Grouping table rows to prevent individual rows from breaking across pages dennist77 Word 1 10-29-2013 11:39 PM
Print attachment when it arrive in specific folder with specific subject visha_1984 Outlook 1 01-30-2013 10:42 AM
Deleting rows with specific criteria Count rows and add blank rows accordingly Hoochtheseal Word VBA 1 01-29-2013 09:23 PM
Adding columns in specific rows only mhays Excel 5 01-17-2012 09:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft