Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Find Method question...

I found this bit of code on the internet.

Copy all the rows that have the value 1000 in column D and paste to
Sheet2:
Find_Range(1000, Columns("D"), xlFormulas, xlWhole).EntireRow.Copy
Range("Sheet2!A1")

This finds the value 1000 in column D. I want to be able to find a
negative value in column D.

Any clue?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find Method question...

If your data is all numeric and is formatted to show negatives using minus
signs, maybe you could look for -.

If both those things aren't true, then I think you'll have to loop through the
cells.

You may be able to reduce the cells to loop through by looking at just the
numeric cells in column D.

If your data is all constants (no formulas):

dim myRng as range
dim myCell as range

set myrng = nothing
on error resume next
set myrng = worksheets("sheet999").range("d:d") _
.cells.specialcells(xlcelltypeconstants, xlnumbers)
on error goto 0

if myrng is nothing then
msgbox "No numbers!
else
for each mycell in myrng.cells
if mycell.value < 0 then
'found it, do what you want
end if
next mycell
end if

(Untested, uncompiled. Watch for typos.)

wrote:

I found this bit of code on the internet.

Copy all the rows that have the value 1000 in column D and paste to
Sheet2:
Find_Range(1000, Columns("D"), xlFormulas, xlWhole).EntireRow.Copy
Range("Sheet2!A1")

This finds the value 1000 in column D. I want to be able to find a
negative value in column D.

Any clue?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Find Method question...

What if they are not all constants (some have formulas)?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find Method question...

You could build a giant range (a union of the constants and formulas) or just
look through all the cells.

dim myRng as range
dim myCell as range

with worksheets("Somesheetnamehere")
'headers in Row 1???
set myrng = .range("d2",.cells(.rows.count,"D).end(xlup))
end with

for each mycell in myrng.cells
if mycell.value < 0 then
'found it, do what you want
end if
next mycell



wrote:

What if they are not all constants (some have formulas)?


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Find Method question...

On Nov 25, 10:12 pm, Dave Peterson wrote:
You could build a giant range (a union of the constants and formulas) or just
look through all the cells.

dim myRng as range
dim myCell as range

with worksheets("Somesheetnamehere")
'headers in Row 1???
set myrng = .range("d2",.cells(.rows.count,"D).end(xlup))
end with

for each mycell in myrng.cells
if mycell.value < 0 then
'found it, do what you want
end if
next mycell


What I meant was, what if the negative numbers I want to find are
formulas? In other words, the formula produces a negative number.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Find Method question...

Actually, this worked perfect! Thanks!!!
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
xls vba find method to find row that contains the current date RCranston Excel Programming 3 March 28th 07 03:59 PM
Question using the excel find method in vba? Jade Excel Programming 2 September 12th 06 03:18 PM
Question on Find method in vba Jade Excel Programming 4 September 12th 06 01:08 AM
Using variables to make a date and using find method to find that. KyWilde Excel Programming 2 April 21st 05 09:43 PM
Find Method question CG Rosén Excel Programming 1 November 30th 03 02:18 PM


All times are GMT +1. The time now is 05:08 AM.

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"