MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Basing Macro Code on Cell Values


Posted by Colin on January 08, 2001 12:39 PM

Is it possible for a macro to look through a series of cells and then base the macro code on the results of those cells?

For example, if in column A the first three cells had values:

'(blank)'
'ActiveWorkbook.SaveAs FileName:="C:\WINDOWS\Desktop\GMP Summary\2001.xls"'
'(blank)'

I would then want the macro to save one file.

However, if in column A, the first three cells had values:

'ActiveWorkbook.SaveAs FileName:="C:\WINDOWS\Desktop\GMP Summary\2000.xls"'
'ActiveWorkbook.SaveAs FileName:="C:\WINDOWS\Desktop\GMP Summary\2001.xls"'
'(blank)'

The macro would then save two files.

Also, does it matter if the cell value is text or a formula result?

Thanks again, in advance for any help.

Colin


Posted by Robert on January 11, 2001 6:48 PM

Why not have only the file name in the cell, loop through the cells and if not empty, use that to save the file to that name.

It is a bit unclear why you would save the same file to different filenames...