View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default need advise on mycode

I am not sure that I am getting your problem, but can you not just use

x.Formula = "=sumif('Jan'!A2:A1000, ""FRUIT"", 'Jan'!F2:F10000)"

--
HTH

Bob

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

wrote in message
oups.com...
Hi

Would like some advice on how to write a macro to do the actions
below:

I will create 12 worksheets for each month containing 2 groups of
items at the starting
of each month.

groups - fruits & veg
eg Jan worksheet will contains fruits & veg sold in this month.
A1 B1 C1
A1 group item name Qty
2 fruits apple 10
3 veg carrot 52

i have a summary page to display the sum for each groups for each
month.

summary pg
A1 B1
1 Jan Feb
2 fruits sum
3 veg sum

I have created a macro to create the a new worksheet for each new
month.
how can i use the code below to work for different month =

sub totalgroup()

set WS2 as the worksheet for jan
set x to be the cell containing fruits sum
x.Formula = "=sumif('WS2'!A2:A1000, ""FRUIT"", 'WS2'!F2:F10000)"

end sub

WS2 will change for different month

How do i change it such that it will work for different month?Do i
pass in
the worksheet name?

Thank you for any suggestions provided.

kiwis