Count Open Workbooks

Count Number of Open Workbooks In Excel with Macro.

मैक्रो से एक्सेल में open workbook की संख्या की Count करें।

 

Sub Name_of_Openwork()

For Each Workbook In Workbooks

Next Workbook

End Sub

 

This code will identify all open workbooks.

यह कोड सभी खुली workbook की पहचान करेगा .


Sub Name_of_Openwork()

For Each Workbook In Workbooks

Msgbox workbook.name

Next Workbook

End Sub

Msgbox will display all open workbooks name.

Msgbox सभी खुली workbook ka नाम प्रदर्शित करेगा।


Now I have to count, how many workbooks opened now.

अब मुझे गिनना है, कितनी workbook खुलीं।

 

For that we have to add a new line x=x+1

उसके लिए हमें एक नई लाइन x = x + 1 जोड़ना होगा.

Means when loop will start that time x value will be 0,  after that  x=x+1,

इसका मतलब है कि जब लूप शुरू होगा उस समय x value 0 होगा, उसे के बाद  x = x + 1,
Then Value of x will be 1
तो  उसे के बाद X का मान 1 होगा

For Each Workbook In Workbooks

This code will identify all open workbook, means this loop will run number of time of open workbook.

यह कोड सभी ओपन वर्कबुक की पहचान करेगा, इसका मतलब है कि यह loop उतनी बार चलेगा जितनी workbook open है.

 

First time x value will be 0, after that 1 will be added in x, then value of x will be increase.

 

पहली बार x का value0 होगा, उसके बाद 1 को x में जोड़ा जाएगा, फिर x का value बढ़ता जायेगा.

 

Then finally value of x will be number of open workbook.

Finally below code will be used
अंत में नीचे दिए गए कोड का उपयोग किया जाएगा
Sub Name_of_Openwork_2()
For Each Workbook In Workbooks
x = x + 1
Next Workbook
MsgBox x
End Sub

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *