Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Kel
 
Posts: n/a
Default dont need anymore these information

Hi all and thanx again for sharing your great knowledge with others,

Im looking to do the following it should be as a macro in VB on a sheet
which is protected and with a password,

if say AND(D1 is less then zero (0) delete contents from entire row,
D2 less then zero delete contents from entire row, and same on D3 and so on,

so the macro will search the entire sheet in column D, if cell in D column
is less then 0 delete contents from entire row.

Thanx again
  #2   Report Post  
bigwheel
 
Posts: n/a
Default

This will remove the entire row when the cell being checked is less than zero
until the cell is found to be empty. Is this what you want or do you just
want the row to be blanked?

Range("D1").Select
Do While Not IsEmpty(ActiveCell)
If ActiveCell < 0 Then
Selection.EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Select
Loop

"Kel" wrote:

Hi all and thanx again for sharing your great knowledge with others,

Im looking to do the following it should be as a macro in VB on a sheet
which is protected and with a password,

if say AND(D1 is less then zero (0) delete contents from entire row,
D2 less then zero delete contents from entire row, and same on D3 and so on,

so the macro will search the entire sheet in column D, if cell in D column
is less then 0 delete contents from entire row.

Thanx again

  #3   Report Post  
JMB
 
Posts: n/a
Default

I think you will have a problem if there are two consecutive negative
numbers. Once the entire row is deleted, Excel will move to the next line
and your code will then move to the next line, causing a row to be skipped.
Maybe find the last row containing data and work from the bottom up.

I usually set a range variable for the rows I want deleted, then delete all
of them at the end of the code (another option)

Sub DeleteNegatives()
Dim x As Object
Dim RangeToDelete As Range

For Each x In Application.Intersect(Columns(4).EntireColumn, _
ActiveSheet.UsedRange)
If x.Value < 0 Then
If RangeToDelete Is Nothing Then
Set RangeToDelete = x
Else: Set RangeToDelete = Union(RangeToDelete, x)
End If
End If
Next x

If Not RangeToDelete Is Nothing Then _
RangeToDelete.EntireRow.Delete

End Sub

"bigwheel" wrote:

This will remove the entire row when the cell being checked is less than zero
until the cell is found to be empty. Is this what you want or do you just
want the row to be blanked?

Range("D1").Select
Do While Not IsEmpty(ActiveCell)
If ActiveCell < 0 Then
Selection.EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Select
Loop

"Kel" wrote:

Hi all and thanx again for sharing your great knowledge with others,

Im looking to do the following it should be as a macro in VB on a sheet
which is protected and with a password,

if say AND(D1 is less then zero (0) delete contents from entire row,
D2 less then zero delete contents from entire row, and same on D3 and so on,

so the macro will search the entire sheet in column D, if cell in D column
is less then 0 delete contents from entire row.

Thanx again

  #4   Report Post  
JMB
 
Posts: n/a
Default

Whatever you go with, you will need code at the beginning to unprotect the
sheet, then code at the end to protect the sheet again (or you could do these
steps yourself before and after running the macro).

ActiveSheet.Unprotect Password:="password"

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, Password := "password"



"Kel" wrote:

Hi all and thanx again for sharing your great knowledge with others,

Im looking to do the following it should be as a macro in VB on a sheet
which is protected and with a password,

if say AND(D1 is less then zero (0) delete contents from entire row,
D2 less then zero delete contents from entire row, and same on D3 and so on,

so the macro will search the entire sheet in column D, if cell in D column
is less then 0 delete contents from entire row.

Thanx again

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
Copying information from multiple worksheets into one ShahAFFS Excel Discussion (Misc queries) 2 May 25th 05 03:21 PM
Update a spreadsheet with new information. a6kim Excel Discussion (Misc queries) 1 May 2nd 05 11:56 AM
Clearing information in certain columns jolly_lolly Excel Discussion (Misc queries) 1 April 22nd 05 02:41 AM
Sharing information between Access and Excel C.M. Warden Excel Discussion (Misc queries) 1 March 16th 05 12:38 PM
Duplicating Cell Information [email protected] Excel Worksheet Functions 1 March 10th 05 12:47 PM


All times are GMT +1. The time now is 03:36 PM.

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"