ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   I feel so dumb - please help - this is a Range issue (https://www.excelbanter.com/excel-worksheet-functions/144773-i-feel-so-dumb-please-help-range-issue.html)

Cat

I feel so dumb - please help - this is a Range issue
 
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

Cat

I feel so dumb - please help - this is a Range issue
 
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

"Cat" wrote:

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


Gary''s Student

I feel so dumb - please help - this is a Range issue
 
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

--
Gary''s Student - gsnu200726

Cat

I feel so dumb - please help - this is a Range issue
 
Thank you for answering my plea - I'll try that - tomorrow - My head hurts
now :(
Cat

"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200726


Gary''s Student

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


Don't become discouraged.
--
Gary''s Student - gsnu200726


"Cat" wrote:

Thank you for answering my plea - I'll try that - tomorrow - My head hurts
now :(
Cat

"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200726



All times are GMT +1. The time now is 11:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com