LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Making a collection of EntireRows for copying and then deletin

Set is used for objects such as workbooks, worksheets or ranges. You do not
need it fir regular variables like integers, strings or booleans...
--
HTH...

Jim Thomlinson


"Bill Case" wrote:

Thanks Jim;

It looks like your suggestion will work. I must misunderstand the use of
the 'Set' command. I will read up on that; it looks important.

Your way sure looks better.

Regards Bill

"Jim Thomlinson" wrote:

This should be close. It looks in Column A of Sheet 1 for X's and if there
are any copies them to cell A2 on sheet 2. It then deletes all of the X rows
found on sheet1. You will need to change the set statements at the beginning
of this code but that should be about it...

Public Sub FindStuff()
Dim wksFrom As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngDestination As Range
Dim strFirstAddress As String

Set rngDestination = Sheets("Sheet2").Range("A2")
Set wksFrom = Sheets("Sheet1")
Set rngToSearch = wksFrom.Range("A:A")
Set rngFound = rngToSearch.Find(What:="X", _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Sorry no X's were found."
Else
Set rngFoundAll = rngFound.EntireRow
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound.EntireRow, rngFoundAll)
Set rngFound = rngToSearch.FindNext(After:=rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.Copy rngDestination
rngFoundAll.Delete
End If
End Sub
--
HTH...

Jim Thomlinson


 
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
Making a cell blank or empty without deleting it Brunner New Users to Excel 1 December 18th 06 10:44 PM
Copying cell values once and then making them static Tsjah Excel Worksheet Functions 5 July 7th 05 08:21 PM
Deleting all buttons in a collection Ken Loomis Excel Programming 5 July 3rd 05 12:04 AM
Help: Making a copying macro from cursor position ? -[::::Shamran::::]- Excel Programming 4 February 27th 05 01:16 PM
Deleting named ranges by looping through range collection agarwaldvk[_11_] Excel Programming 3 August 3rd 04 01:00 AM


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