Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Delelting previous row

What I am trying to do is, check if Row 5, Column D has "SB" in the cell. If
there is a "SB" in the cell, delete the row above it. I have done a search on
deleting row most of the posting were for deleting blank lines and the such
so they weren't much help to me. I am still trying to learn this stuff as
fast as I can.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delelting previous row

hi,,

Giving an answer that you can develop into more meaaningful code is
difficult given that you would normally do something as simple as this
without resorting to code i.e. you would simply look at d5 and delete
manually if required. However, this does what you want


Sub Stance()
If Cells(5, 4).Value = "SB" Then
Rows(4).EntireRow.Delete
End If
End Sub

Mike

"Novice Lee" wrote:

What I am trying to do is, check if Row 5, Column D has "SB" in the cell. If
there is a "SB" in the cell, delete the row above it. I have done a search on
deleting row most of the posting were for deleting blank lines and the such
so they weren't much help to me. I am still trying to learn this stuff as
fast as I can.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Delelting previous row

I guess I forgot to mention that it would check each cell in column D for a
"SB" throughout the entire sheet that sheet.

"Mike H" wrote:

hi,,

Giving an answer that you can develop into more meaaningful code is
difficult given that you would normally do something as simple as this
without resorting to code i.e. you would simply look at d5 and delete
manually if required. However, this does what you want


Sub Stance()
If Cells(5, 4).Value = "SB" Then
Rows(4).EntireRow.Delete
End If
End Sub

Mike

"Novice Lee" wrote:

What I am trying to do is, check if Row 5, Column D has "SB" in the cell. If
there is a "SB" in the cell, delete the row above it. I have done a search on
deleting row most of the posting were for deleting blank lines and the such
so they weren't much help to me. I am still trying to learn this stuff as
fast as I can.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Delelting previous row

On Aug 14, 3:03*pm, Novice Lee
wrote:
I guess I forgot to mention that it would check each cell in column D for a
"SB" throughout the entire sheet that sheet.

"Mike H" wrote:
hi,,


Giving an answer that you can develop into more meaaningful code is
difficult given that you would normally do something as simple as this
without resorting to code i.e. you would simply look at d5 and delete
manually if required. However, this does what you want


Sub Stance()
If Cells(5, 4).Value = "SB" Then
Rows(4).EntireRow.Delete
End If
End Sub


Mike


"Novice Lee" wrote:


What I am trying to do is, check if Row 5, Column D has "SB" in the cell. If
there is a "SB" in the cell, delete the row above it. I have done a search on
deleting row most of the posting were for deleting blank lines and the such
so they weren't much help to me. I am still trying to learn this stuff as
fast as I can.


Thanks


Revision to my code

Sub DeleteSB()
Dim MyCell As Range
Dim SBRow As Range

Set SBRow = Range("D:D")

For Each MyCell In SBRow
If MyCell.Value = "SB" Then
MyCell.Offset(-1, 0).EntireRow.Delete
End If
Next
End Sub

This will do what you want.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Delelting previous row

Thanks it work perfectly

" wrote:

On Aug 14, 3:03 pm, Novice Lee
wrote:
I guess I forgot to mention that it would check each cell in column D for a
"SB" throughout the entire sheet that sheet.

"Mike H" wrote:
hi,,


Giving an answer that you can develop into more meaaningful code is
difficult given that you would normally do something as simple as this
without resorting to code i.e. you would simply look at d5 and delete
manually if required. However, this does what you want


Sub Stance()
If Cells(5, 4).Value = "SB" Then
Rows(4).EntireRow.Delete
End If
End Sub


Mike


"Novice Lee" wrote:


What I am trying to do is, check if Row 5, Column D has "SB" in the cell. If
there is a "SB" in the cell, delete the row above it. I have done a search on
deleting row most of the posting were for deleting blank lines and the such
so they weren't much help to me. I am still trying to learn this stuff as
fast as I can.


Thanks


Revision to my code

Sub DeleteSB()
Dim MyCell As Range
Dim SBRow As Range

Set SBRow = Range("D:D")

For Each MyCell In SBRow
If MyCell.Value = "SB" Then
MyCell.Offset(-1, 0).EntireRow.Delete
End If
Next
End Sub

This will do what you want.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delelting previous row

Yes you did neglect to mention that. have a look at your other response

"Novice Lee" wrote:

I guess I forgot to mention that it would check each cell in column D for a
"SB" throughout the entire sheet that sheet.

"Mike H" wrote:

hi,,

Giving an answer that you can develop into more meaaningful code is
difficult given that you would normally do something as simple as this
without resorting to code i.e. you would simply look at d5 and delete
manually if required. However, this does what you want


Sub Stance()
If Cells(5, 4).Value = "SB" Then
Rows(4).EntireRow.Delete
End If
End Sub

Mike

"Novice Lee" wrote:

What I am trying to do is, check if Row 5, Column D has "SB" in the cell. If
there is a "SB" in the cell, delete the row above it. I have done a search on
deleting row most of the posting were for deleting blank lines and the such
so they weren't much help to me. I am still trying to learn this stuff as
fast as I can.

Thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Delelting previous row

On Aug 14, 1:45*pm, Novice Lee
wrote:
What I am trying to do is, check if Row 5, Column D has "SB" in the cell. If
there is a "SB" in the cell, delete the row above it. I have done a search on
deleting row most of the posting were for deleting blank lines and the such
so they weren't much help to me. I am still trying to learn this stuff as
fast as I can.

Thanks


Hello, Try this:

Sub Test)
If Cells(5, "D").Value = "SB" Then Cells(5, "D").Offset(-1,
0).EntireRow.Delete
End Sub
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Delelting previous row

On Aug 14, 2:45*pm, Novice Lee
wrote:
What I am trying to do is, check if Row 5, Column D has "SB" in the cell. If
there is a "SB" in the cell, delete the row above it. I have done a search on
deleting row most of the posting were for deleting blank lines and the such
so they weren't much help to me. I am still trying to learn this stuff as
fast as I can.

Thanks


Sub DeleteSB()
Dim MyCell As Range
Dim SBRow As Range

Set SBRow = Range("5:5")

For Each MyCell In SBRow
If MyCell.Value = "SB" Then
MyCell.Offset(-1, 0).EntireRow.Delete
End If
Next
End Sub

This will delete row 4 if Row 5 contains "SB". If you want to delete
the previous row of any range that contains "SB", simply change the
line

SetSBRow = ActiveSheet.UsedRange.Rows
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
3-Color Scale Vlookup for Current Month/Previous/Pre-Previous NeoFax Excel Discussion (Misc queries) 2 January 8th 10 07:04 PM
get value of previous cell villandro Excel Worksheet Functions 3 November 6th 09 01:56 AM
need previous row help [email protected] Excel Programming 6 March 6th 07 10:30 PM
Previous Documents Cindareli7 Excel Discussion (Misc queries) 3 November 1st 06 07:22 PM
previous day tigoda Excel Programming 4 October 17th 06 02:37 PM


All times are GMT +1. The time now is 02:58 PM.

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

About Us

"It's about Microsoft Excel"