#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 577
Default macros

is it possible to create a macro that can take into account the number of
columns containing data? in a workbook i have a tab for each month of the
year for 2001-2008, and because each month has varying numbers of days in it,
the number of iterations i need to do differs, and the number of columns for
iterations changes back and forth from 6 to 7. im just looking for a
time-saving method instead of manually including or removing the number of
columns to consider.

thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default macros

It is hard to determine it this will work for you given the sketchy
description of your column layout, but this statement will return the last
column number containing data...

Worksheets("Sheet1").Cells(RowNum, Columns.Count).End(xlToLeft).Column

Just assign it to a variable, use it in an If..Then logical expression or
whatever. The RowNum variable in the Cells property call is the row number
to examine... you can use your own variable name, or hard code the row's
number, there instead.

Rick


"scott" wrote in message
...
is it possible to create a macro that can take into account the number of
columns containing data? in a workbook i have a tab for each month of the
year for 2001-2008, and because each month has varying numbers of days in
it,
the number of iterations i need to do differs, and the number of columns
for
iterations changes back and forth from 6 to 7. im just looking for a
time-saving method instead of manually including or removing the number of
columns to consider.

thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 577
Default macros

sorry for the sketchy description, hopefully this is better.

in each worksheet i have the data in column b for each day of a month that
is in column a. column c is the sorted data that is contained in column b.
column d contains the average of every 5 data points in column c; starting in
d5, the average of c1:c5 is calculated...d6 contains the average of c2:c6, d7
contains the average of c3:c7, etc. column e has the aveages of column d
starting at d10, column f starting at f15, etc. because each month has
either 30 or 31 days (february has 28 of course), the number of columns that
i will peform iterations in will differ..can i write a macro on one sheet
that i can use for each sheet in the workbook that takes into account the
number of columns each worksheet has?

"scott" wrote:

is it possible to create a macro that can take into account the number of
columns containing data? in a workbook i have a tab for each month of the
year for 2001-2008, and because each month has varying numbers of days in it,
the number of iterations i need to do differs, and the number of columns for
iterations changes back and forth from 6 to 7. im just looking for a
time-saving method instead of manually including or removing the number of
columns to consider.

thanks in advance.

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
Macros: can you copy macros from one doc to another? Roady Excel Discussion (Misc queries) 1 June 12th 08 05:47 PM
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Macros - copying macros from one computer to another TT Excel Discussion (Misc queries) 18 December 14th 06 03:24 AM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM


All times are GMT +1. The time now is 01:11 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"