Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default combine worksheet functions to make macro to automate everythi

Sub CountStuff()
Dim v as Variant, tot as Double, rng as Range
Dim cell as Range
v = Array("2005 Archived!K5:K59","2004 Archived!K5:K59")
tot = 0
for i = lbound(v) to ubound(v)
set rng = Range(v)
for each cell in rng
if cell.Offset(0,-10).Value Date - 365 then
tot = tot + cell
end if
Next
Next
msgbox "Total is " & format(tot,"#.0")
End Sub

Untested, so there could be other typos.

--
Regards,
Tom Ogilvy


"mike" wrote in message
...
changed , to & then there is type mismatch on...
for i = lbound(v) to ubound(v)




"Tom Ogilvy" wrote:

Sub CountStuff()
Dim v as Variant, tot as Double, rng as Range
Dim cell as Range
v = ("2005 Archived!K5:K59","2004 Archived!K5:K59")
tot = 0
for i = lbound(v) to ubound(v)
set rng = Range(v)
for each cell in rng
if cell.Offset(0,-10).Value Date - 365 then
tot = tot + cell
end if
Next
Next
msgbox "Total is " & format(tot,"#.0")
End Sub

If you want it as a function, it would be different.

--
Regards,
Tom Ogilvy




"mike" wrote in message
...
hello again

this is a function to look at the date.
Function timeleft()
timeleft = Date - 365
End Function

then this function written into excel not vba
looks at the date and sees if the value in A5 is greater than the date

today,
if it is, then it shows the value in K5, else its 0.

=IF(A5$S$5,K5,0)

then this worksheet function sums the new column, in worksheet a and

b,


=SUM('2005 Archived'!P5:P59)+SUM('2004 Archived'!P5:P49)


and gives the total value from today minus 365 days.

what i would like to do is put this all in a macro.
Any suggestions would be greatly appreciated.

thanks again

mike






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
Automate Combine 2 Spreadsheets into two worksheets Uni Excel Worksheet Functions 5 November 15th 07 12:41 PM
How to merge / combine several worksheets into one new worksheet without VBA / Macro? FOR EXPERTS [email protected] Excel Worksheet Functions 9 August 13th 07 04:19 AM
use a macro to automate excel worksheet password protection Bodyshopman Excel Discussion (Misc queries) 2 July 25th 07 01:21 AM
Macro to Combine 2 columns to make one column without merging JRM Excel Discussion (Misc queries) 1 December 31st 05 08:27 PM
Macro to combine several worksheet formulas Emily Suskovich Excel Programming 3 January 20th 04 07:26 PM


All times are GMT +1. The time now is 03:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"