LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default VBA macro delete row - Help needed

On Sunday, May 19, 2013 8:38:43 PM UTC-7, gemiho wrote:
Hello everyone,



I wonder if you please could help me with a macro; I just started to use

VBA, so my knowledge is equal zero.

I have a workbook with a few sheets. I am trying to write a macro that

after clicking on a cell it deletes the entire row if the cell in column

A does not contain any text; actually I wanted it to do not delete the

row if the cell in column A contains the text “keepThisRow”, but I do

not know how to do it. I was thinking to use a Form button.



BellowI the code I have, but it does not work at all. thank you in

advance for all help



Sub deleteRow_Click()

Dim rng As Range

ActiveSheet.Unprotect Password:="123"

On Error GoTo ErrHandler



Set rng =

Worksheets(ActiveSheet).Range("A2:A500").ActiveCel l.Row.Select 'I want

to select a cell in row I want to delete

If Not rng Is Nothing Then

rng.EntireRow.Delete xlUp

End If

Exit Sub

ErrHandler:



ActiveSheet.Protect Password:="123", DrawingObjects:=True,

Contents:=True, Scenarios:=True _

, AllowFormattingCells:=True,

AllowSorting:=True

End Sub









--

gemiho



Hi gemiho


Option Explicit
Option Compare Text

Sub KeepRow()
Dim c As Range

'Password stuff here

For Each c In Range("A2:A500")
If c.Value < "keep this row" Then c.EntireRow.Delete
Next

'Password stuff here
End Sub

Regards,
Howard
 
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
How to delete commas and spaces when not needed ... S&R way, or macro way? StargateFan Excel Programming 11 June 2nd 09 07:26 PM
Macro needed to identify value and delete row if value below targe Pyrotoy New Users to Excel 3 December 9th 08 11:35 PM
Help needed with find & Delete Les Stout[_2_] Excel Programming 2 December 2nd 06 01:05 AM
Macro needed to delete rows simmerdown Excel Programming 4 March 27th 06 04:00 PM
delete code needed Rick Excel Programming 2 September 21st 04 07:39 PM


All times are GMT +1. The time now is 11:47 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"