Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-02-2012, 06:01 AM
tomlam tomlam is offline delete row Windows 7 64bit delete row Office 2007
Advanced Beginner
delete row
 
Join Date: Oct 2012
Posts: 33
tomlam is on a distinguished road
Default delete row

Hi All,

I would like to delete more than one row(which columnA cells contain nothing ) in between rows that is as follows.that is allow only one row(like row3 after vba progamme)
in between for spacing or no row in between(like row1 and2) How to write the VBA code
many thanks

ColumnA ColumnB
Row1 Peter Math Mark=100
Row2 John Math Mark=99
Row3
Row4
Row5 tom math mark=68
row6
row7
row8 mary math mark=50

After we use VBA progamme , the result as follows

ColumnA ColumnB
Row1 Peter Math Mark=100
Row2 John Math Mark=99
Row3
Row4 tom math mark=68
row5


row6 mary math mark=50


Thanks
Tomlam

Last edited by tomlam; 10-02-2012 at 06:33 PM.
Reply With Quote
  #2  
Old 10-04-2012, 09:20 PM
macropod's Avatar
macropod macropod is offline delete row Windows 7 64bit delete row Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

What is the vba code you are using?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-04-2012, 09:57 PM
tomlam tomlam is offline delete row Windows 7 64bit delete row Office 2007
Advanced Beginner
delete row
 
Join Date: Oct 2012
Posts: 33
tomlam is on a distinguished road
Default

excel vba code we are using. thanks
Reply With Quote
  #4  
Old 10-04-2012, 10:09 PM
macropod's Avatar
macropod macropod is offline delete row Windows 7 64bit delete row Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Please post the code you are using. Telling me it's Excel vba (which is pretty obvious in an Excel programming forum) doesn't really add much to what you've already posted.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-04-2012, 11:14 PM
tomlam tomlam is offline delete row Windows 7 64bit delete row Office 2007
Advanced Beginner
delete row
 
Join Date: Oct 2012
Posts: 33
tomlam is on a distinguished road
Default

that is part of the excel vba programe,

Code:
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For Z = 2 To lastRow
  If (Cells(Z, ("f"))) = "" Then Cells(Z, ("f")).EntireRow.Clear
Next Z
then so there will some empty row, so we dont how to write to vba as
my request as previous enquiry

Thanks Macropod

Last edited by macropod; 10-04-2012 at 11:50 PM. Reason: Added code tags & formatting
Reply With Quote
  #6  
Old 10-04-2012, 11:52 PM
macropod's Avatar
macropod macropod is offline delete row Windows 7 64bit delete row Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Try:
Code:
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For Z = lastRow to 2 Step -1
  If Cells(Z, 4) = "" Then Cells(Z, 4).EntireRow.Delete
Next Z
The problem with a forward-working For .. Next loop when you're deleting items is that, upon deletion, the next item moves into the deleted item's position and doesn't get tested on the next iteration, because it's no longer at its former location.

PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 10-05-2012, 12:19 AM
tomlam tomlam is offline delete row Windows 7 64bit delete row Office 2007
Advanced Beginner
delete row
 
Join Date: Oct 2012
Posts: 33
tomlam is on a distinguished road
Default

Thanks Paul. My programme is complete. Thank so much for your great help
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete row Delete Space mariadanmark Excel 2 05-17-2012 02:53 AM
delete row cannot delete these lines! userman Word 4 05-02-2012 12:34 AM
Delete option greyed out when trying to delete row 1 tpcervelo Excel 2 11-15-2011 06:48 AM
delete row Cannot delete folders klingenfelter Outlook 10 02-04-2011 01:35 PM
delete email message via blackberry and have it delete on my pop3 and my outlook Iamthestorm Outlook 2 10-28-2010 12:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:38 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