Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2014, 10:05 AM
mbesspiata mbesspiata is offline If Statement in vba to Delete a Line Windows 7 64bit If Statement in vba to Delete a Line Office 2010 64bit
Advanced Beginner
If Statement in vba to Delete a Line
 
Join Date: Mar 2011
Location: Virginia
Posts: 57
mbesspiata is on a distinguished road
Default If Statement in vba to Delete a Line

I run a report weekly that sometimes exports a blank line in the pivot table and therefore the last line of the table in column A has this (blank). I would like to create something in vba to look in column A for a cell that contains (blank) and then delete that line from the sheet.



Is that possible?

Mike
Reply With Quote
  #2  
Old 04-01-2014, 06:11 PM
macropod's Avatar
macropod macropod is offline If Statement in vba to Delete a Line Windows 7 32bit If Statement in vba to Delete a Line Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use a macro like:
Code:
Sub DeleteBlanks()
Dim lRow As Long
With ThisWorkbook.ActiveSheet.UsedRange
  lRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
  .Range("A1:A" & lRow).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-02-2014, 04:07 AM
mbesspiata mbesspiata is offline If Statement in vba to Delete a Line Windows 7 64bit If Statement in vba to Delete a Line Office 2010 64bit
Advanced Beginner
If Statement in vba to Delete a Line
 
Join Date: Mar 2011
Location: Virginia
Posts: 57
mbesspiata is on a distinguished road
Default

Thanks Paul. One thing though, when I put (blank) I meant that is the actual characters showing in that cell. So it's not just a blank cell, it's a cell with the word (blank) (with the parentheses) in it.

Mike
Reply With Quote
  #4  
Old 04-02-2014, 03:11 PM
macropod's Avatar
macropod macropod is offline If Statement in vba to Delete a Line Windows 7 32bit If Statement in vba to Delete a Line Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

OK, try:
Code:
Sub Demo()
Dim iRow As Long
With ActiveSheet.UsedRange
  For iRow = .Cells.SpecialCells(xlCellTypeLastCell).Row To 1 Step -1
    If .Range("A" & iRow).Value = "(blank)" Then
      .Rows(iRow).EntireRow.Delete
    End If
  Next iRow
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-08-2014, 04:32 AM
mbesspiata mbesspiata is offline If Statement in vba to Delete a Line Windows 7 64bit If Statement in vba to Delete a Line Office 2010 64bit
Advanced Beginner
If Statement in vba to Delete a Line
 
Join Date: Mar 2011
Location: Virginia
Posts: 57
mbesspiata is on a distinguished road
Default

Thanks so much for your help. Perfect.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
If Statement in vba to Delete a Line Why cant I delete the black line at the side of my orginisational chart? Gabby1991 Drawing and Graphics 1 01-07-2014 09:14 PM
unable to delete a horizontal line jerryny Word 2 03-31-2013 05:59 PM
If Statement in vba to Delete a Line Search for text then delete line konopca Word VBA 2 06-07-2012 02:44 AM
If Statement in vba to Delete a Line Very Urgent - Not able to delete Line krishnaoptif Drawing and Graphics 11 05-29-2012 11:25 AM
Cannot delete line adkr Office 1 04-07-2010 09:26 PM

Other Forums: Access Forums

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


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