View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Kasper Kasper is offline
external usenet poster
 
Posts: 48
Default Select range higher than and lower than

On 23 Okt., 12:50, Kasper wrote:
On 22 Okt., 16:19, "Bernard Liengme"
wrote:





Here is a very simple sub (there are more sophisticated ways)


Sub findthem()
* *Set myrange = Range("A1:A30")
* *mymin = 5999999
* *mymax = 6999999
* *j = 1
* *For Each myvalue In myrange
* * *If myvalue mymin And myvalue < mymax Then
* * * *Cells(j, 7) = myvalue
* * * *j = j + 1
* * *End If
* *Next
End Sub


I have assumed the numbers are in A1:A30; change the first statement as
needed.
I have placed the results in column G starting with G1; change j=1 to some
other value to start lower down and change the 7 in Cells(j,7) to use
another column.
*Depending on your needs, you may want
If myvalue = mymin And myvalue =< mymax Then


best wishes
--
Bernard V Liengme
Microsoft Excel MVPhttp://people.stfx.ca/bliengme
remove caps from email


"Kasper" wrote in message


....


Hi


I need to write a macro that selects numers in a coloumn that are
higherthane.g. 5999999 but lowerthan6999999 and copy them. Any
ideas?


The numbers are sorted according to value, so the lowest number is
first and the highest number is last in the coloumn.


Any help will be appreciated.


//Kasper- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -


Thanks for the answer... I need the macro to select the complete row
for each of the values in the coloumn that is in the selected range
and then make it copy it to another sheet(that part is not too
difficult though)

//Kasper- Skjul tekst i anførselstegn -

- Vis tekst i anførselstegn -


But as I mentioned before, I need to get the macro to select e.g. Row
820 to Row 840(since these rows contain contain "myvalue" in coloumn
D) and then copy Everything in Row 820 to Row 840.
Any further help will be appreciated.

//Kasper