I feel so dumb - please help - this is a Range issue

G

Guest

I've written a macro to do some suttle things - I'm not a pro by any means
but can get by. I have data that is refreshed twice a month and I need to
add several steps to it. For one:

Col A contains Dates
Col B contains Later Dates
Col C needs to subtract Col A from Col B
I can't just copy the code =imsub(A:A,B:B) becasue it all varies
I've tried Nameing the Ranges, I've tried all sorts of stuff until I'm blue
- you would think that it would just hit me over the head what I need to do -
but it's not.

If anyone can save my sanity (I've said the Serenity Prayer one too many
times today) I would so appreciate it.

Thanks
Cat
 
G

Guest

oh - and I AM a knucklehead - it should be Col B subtracts Col A to get the
days 2/5/2007-2/2/2007

Send me to my room
 
G

Guest

How about:

Sub cat()
nq = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To nq
Cells(i, 3).Value = Cells(i, 2).Value - Cells(i, 1).Value
Next
End Sub


with sample results in cols A & B & C:

5/16/2007 5/31/2007 15
4/1/2007 6/3/2007 63
4/11/2007 4/21/2007 10
 

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