Thread: macros
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\)[_1146_] Rick Rothstein \(MVP - VB\)[_1146_] is offline
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.