Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Copy Entire Row - Rick Rothstein ?

You gave somebody this code, which works perfectly, however I
would like to delete te "closed" row instead of hiding it. Despite my
efforts I only manage to delete one row at a time. Obviously Im
doing something wrong.
As always - thanks in advance.

Sub findtextcopyandhide()
With Worksheets("sheet15").Range("a1:a22")
Set c = .Find(What:="closed", After:=Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)

If Not c Is Nothing Then
firstAddress = c.Address
On Error Resume Next
Do
With Sheets("sheet6")
lr = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
Rows(c.Row).Copy .Rows(lr)
Rows(c.Row).Hidden = True <----- Delete the row
End With
Set c = .FindNext(c)
Loop While Not c Is Nothing _
And c.Address < firstAddress
End If
End With

--
HJN
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Copy Entire Row - Rick Rothstein ?

When deleting rows it's best to work from the bottom of the range up.

Untested...

Const SHEET_NAME as string = "sheet15"
Const RNG_SRCH as string = "A1:A22"
Const VAL_CLOSED as string="CLOSED"
dim x as long, rngSearch as range, c as Range

set rngSearch = Worksheets(SHEET_NAME).Range(RNG_SRCH)
for x = rngSearch.cells.count to 1 step-1
set c = rngSearch.Cells(x)
if ucase(c.value) = VAL_CLOSED then c.entirerow.delete
next x


Tim





"Hennie Neuhoff" wrote in message
...
You gave somebody this code, which works perfectly, however I
would like to delete te "closed" row instead of hiding it. Despite my
efforts I only manage to delete one row at a time. Obviously I'm
doing something wrong.
As always - thanks in advance.

Sub findtextcopyandhide()
With Worksheets("sheet15").Range("a1:a22")
Set c = .Find(What:="closed", After:=Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)

If Not c Is Nothing Then
firstAddress = c.Address
On Error Resume Next
Do
With Sheets("sheet6")
lr = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
Rows(c.Row).Copy .Rows(lr)
Rows(c.Row).Hidden = True <----- Delete the row
End With
Set c = .FindNext(c)
Loop While Not c Is Nothing _
And c.Address < firstAddress
End If
End With

--
HJN



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
For Rick Rothstein retired bill Excel Programming 1 May 7th 09 05:50 PM
IsNumber (in Rick Rothstein's example) Sam Kuo[_3_] Excel Programming 6 April 28th 08 07:11 AM
Rick Rothstein Gordy99 Excel Programming 0 February 28th 08 07:05 PM
Question for Rick Rothstein Jenny B. Excel Discussion (Misc queries) 0 June 27th 07 07:06 PM
answer to Rick Axel Excel Programming 7 June 25th 07 09:00 PM


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