ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to run specific macro on selected worksheet? (https://www.excelbanter.com/excel-discussion-misc-queries/208487-how-run-specific-macro-selected-worksheet.html)

Harshad[_2_]

How to run specific macro on selected worksheet?
 
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.

ShaneDevenshire

How to run specific macro on selected worksheet?
 
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
--
Thanks,
Shane Devenshire


"Harshad" wrote:

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.


Harshad[_2_]

How to run specific macro on selected worksheet?
 
Dear Shane,

It's excellent. It's working.

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

Regards, Harshad

"ShaneDevenshire" wrote:

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
--
Thanks,
Shane Devenshire


"Harshad" wrote:

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.



All times are GMT +1. The time now is 03:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com