Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default need advise on mycode

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default need advise on mycode

Hi

i would like to automate the process, so at the start/end of the
month,
i would get the raw data & create a new worksheet according to the
month with worksheet name as the month
then i would like to run the macro to calculate the sum of qty
according to group
& write back the sum to a summary page.

So if i use Jan instead of a variable, then it will be hard coding it
& i need to write 12
sumif statements.

so i was thinking if i can make it resuable by using a variable

maybe you can provide me suggestion on how to tackle this problem.

Thank you for your reply.

On Apr 17, 4:05 pm, "Bob Phillips" wrote:
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- Hide quoted text -


- Show quoted text -



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
advise pls Hopeless With excel Excel Programming 1 January 22nd 06 04:49 PM
pls advise George Excel Worksheet Functions 2 February 25th 05 08:22 PM
I need some Advise Tom Ogilvy Excel Programming 0 October 16th 04 12:50 AM
Advise VBA No Name Excel Programming 7 December 3rd 03 07:14 PM
VBA Advise RB[_3_] Excel Programming 1 July 15th 03 03:26 AM


All times are GMT +1. The time now is 08:56 PM.

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

About Us

"It's about Microsoft Excel"