LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Delete records from result-cell after a find-function call

Which of the hardcoding you're concerned about?
This:
'Selection.Find(What:="2" '
or
'Range("C202:F202").Select'

From your post i'd gather that the latter is your concern. Does it
mean that the Find method you refer to will always be searching for
'2' in a specified range? If it's not the case, then where the
variables (values to search for) are coming from?

Maybe this would get you started (if I've understood correctly your
post, though):

Sub TryFindCell()
Dim myResultRange As Range
Set myResultRange = ActiveSheet.UsedRange.Find(what:="2")

If myResultRange Is Nothing Then
Debug.Print "There is no such value on this sheet"
Else
Debug.Print "Found value in cell: " & myResultRange.Address
End If

End Sub

So, now if successful, the variable myResultRange holds the range
properties of the cell where the first instance of the searched value
("2" in this instance) was found. Check the Immediate window.


On Jul 15, 10:56*am, Pluggie
wrote:
Part of my macro needs to delete records starting from a row which is
determined by a find-function call. Naturally... the resultcell of this
find-function will vary each time.
How do I make sure that the resultcell of the first recorded instance of the
macro is not hardcoded into the macro?

Here is the sample of code I have now (last 7 rows of the code).
This should be modified so that it does what I want.

----------------------------code----------------------------------
* * Columns("A:A").Select
* * Selection.Insert Shift:=xlToRight
* * Range("A2").Select
* * ActiveCell.FormulaR1C1 = "1"
* * Range("A3").Select
* * ActiveCell.FormulaR1C1 = "2"
* * Range("A2:A3").Select
* * Dim LastRow2 As Long
* * LastRow2 = Range("G" & Rows.Count).End(xlUp).Row
* * Selection.AutoFill Destination:=Range("A2:A" & LastRow2)
* * Rows("2:2").Select
* * Range(Selection, Selection.End(xlDown)).Select
* * Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
* * * * OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
* * * * DataOption1:=xlSortNormal
* * Columns("B:B").Select
* * Selection.Find(What:="2", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
* * * * :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
* * * * False, SearchFormat:=False).Activate
* * Range("C202:F202").Select
* * Range(Selection, Selection.End(xlDown)).Select
* * Selection.ClearContents
----------------------------end-of-code-----------------------------

Anybody have the solution?

Regards,

Pluggie.


 
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
Find mulitple records Vlookup type function? KCK Excel Programming 0 March 28th 07 07:58 PM
Find duplicate records and delete Lupe Excel Programming 6 September 6th 06 07:19 PM
Can VLookup function find and list multiple records? Rich - SG Excel Worksheet Functions 11 July 5th 05 07:44 PM
Find records between two dates & check a box for each positive result seals Excel Programming 1 April 16th 04 04:42 AM
Call to custom function appears as typed not as result David Bernheim Excel Programming 8 November 23rd 03 04:29 PM


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