Code to find specific number and calculate

A

Annette

Hi! How would I write into my code to look in cells in column one for a
specific number and then divide by 25. Here's a sample of the number:

col 1 col 2 col 3
02.3892.067.033 descrip. 2025

I want the macro to see the .067 in the cell, and then in column four,
divide the number found in column three by 25 and display number in column
four.

So what the result displayed: col 4 would be 81

I hope this makes sense.

Thanks for any help provided.

Annette
 
N

Nigel

You could use a formula in column D as follows....

=IF(ISERROR(FIND(".067",A2)),"Not found",C2/25)

The text ".067" could be a reference to another cell of course.
 
B

Bob Phillips

=IF(ISNUMBER(FIND(".067",A1)),C1/25,"")

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
M

Mike H

Or in a macro

Sub stance()
Set myrange = Range("A1:A100")
For Each c In myrange
If InStr(1, c.Value, "067", 1) > 0 Then
On Error Resume Next
c.Offset(0, 3).Value = c.Offset(0, 2).Value / 25
End If
Next
End Sub

Mike
 
A

Annette

Thanks, Mike ... this is exactly what I need, now I should be able to modify
for the other numbers to divide by different amounts other than 25!

This works really well!

Annette
 
M

Mike H

Thanks, Mike ... this is exactly what I need, now I should be able to modify
for the other numbers to divide by different amounts other than 25!

This works really well!

Annette
Your welcome
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top