How to run specific macro on selected worksheet?

H

Harshad

I have 54 sheet workbook. The name of the sheets from begining are Main,
Content, solvent, Help, Exp 1, Exp 2, Exp 3,Exp 4,.....,Exp 50.

I have one NNA code, which i want to run on sheets named Exp 1 to Exp 50.

Pls sugest code.
 
S

ShaneDevenshire

Hi,

I suppose I should know what NNA code is but I don't. However, if you are
asking how do you run code against all sheets whose name begins with Exp then
you might use something like this

Sub Test()
Dim I As Integer
For I = 1 To 50
Sheets("Exp " & I).Activate

'Your code here....

Next I
End Sub

If this helps, please click Yes
 
H

Harshad

Dear Shane,

It's excellent. It's working.

Thank you very much. You solved my problem.
Please continue the good work.

Regards, Harshad
 

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