LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Help with loop sequence

Hi.

I could use some help setting up a loop sequence for my macro(macro as
it is can be seen below).

I need the macro to loop the sequence for a number of times until
there is only empty rows in range B9:B35. Is that possible?
Alternatively is it possible to enter the number of times the loop
should repeat itself in a cell and have the macro read this number?

Any help will be appreciated.

-- Macro--
Sub FindCell()
Sheets("CM").Select
Dim cell As Range
Dim rng As Range
Range("A9:F35").Sort Key1:=Range("B9"), Order1:=xlDescending, Header:=
_
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

myValue = Range("J3").Value
For Each cell In Range("B9:B35")
If cell.Value < myValue Then
cell.Select
ActiveCell.EntireRow.Select
Selection.Cut
Sheets("Dataark").Select
Range("A3").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
ActiveSheet.Paste

Set rng = Cells(Rows.Count, 2).End(xlUp)
rng.Select
ActiveCell.Copy
Sheets("CM").Select
Range("K3").Select
ActiveSheet.Paste
Selection.Font.ColorIndex = 2

Range("J3").Select
ActiveCell.FormulaR1C1 = "=R[1]C[-8]-RC[1]"

Exit Sub
End If
Next
End Sub

-- Macro End--


//Kasper
 
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
sequence cesar Excel Discussion (Misc queries) 3 November 1st 06 03:33 AM
min and max in a sequence bill gras Excel Worksheet Functions 11 May 16th 06 11:33 PM
Tab sequence Cees Excel Discussion (Misc queries) 2 January 26th 06 06:14 PM
Set tab sequence help tamato43 Excel Discussion (Misc queries) 0 August 25th 05 07:11 PM
the first in a sequence Willem Excel Discussion (Misc queries) 2 May 12th 05 02:12 PM


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