Macro to affect all sheets

R

REMB

I want to select all sheets in a workbook, insert a column, and put a formula
in that column. It works fine when doing it manually, but if I try to have a
macro do this, it only affects one sheet. Is there any way to do this?
 
×

מיכ×ל (מיקי) ×בידן

The general principal is shown in the following code.
Pls note: the code places the formula: =2+2 in cell F1 of every sheet.
I'm sure it will b no problem 4 u yo change it 4 your needs.
-----------------------
Sub All_Sheets()
For Each SH In ActiveWorkbook.Sheets
SH.[F1].Formula = "=2+2"
Next
End Sub
 
D

Don Guillett

I know that it doesn't make sense but Excel will NOT accept all sheets in a
macro for this. Use the suggested loop. Fast
 
N

njmikec

REMB;958360 said:
I want to select all sheets in a workbook, insert a column, and put a
formula
in that column. It works fine when doing it manually, but if I try to
have a
macro do this, it only affects one sheet. Is there any way to do this?
Have you tried recording the Macro on Sheet 1 first, then holding down
shift, and hilighting all tabs and running the Macro?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top