ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Visible sheets (https://www.excelbanter.com/excel-programming/352000-visible-sheets.html)

Steph[_6_]

Visible sheets
 
Hello. The bwlow snippet of code return each sheet in a workbook. Is there
a way to return on sheets that are visible? Thank you!

For Each sh In bk.Worksheets
ThisWorkbook.Worksheets("Sheet Verify").Cells(cell.Row, j).Value =
sh.Name
j = j + 1



Norman Jones

Visible sheets
 
Hi Steph,

Try something like:

'=============
Public Sub Tester()
Dim SH As Worksheet
Dim j As Long
For Each SH In ActiveWorkbook.Worksheets
If SH.Visible = True Then
j = j + 1
ThisWorkbook.Worksheets("Sheet Verify"). _
Cells(1, j).Value = SH.Name
End If
Next SH

End Sub
'<<=============


---
Regards,
Norman



"Steph" wrote in message
...
Hello. The bwlow snippet of code return each sheet in a workbook. Is
there
a way to return on sheets that are visible? Thank you!

For Each sh In bk.Worksheets
ThisWorkbook.Worksheets("Sheet Verify").Cells(cell.Row, j).Value =
sh.Name
j = j + 1





Dave Peterson

Visible sheets
 
for each sh in bk.worksheets
if sh.visible = xlsheetvisible then
ThisWorkbook.Worksheets("Sheet Verify").Cells(cell.Row, j).Value _
= sh.Name
j = j + 1
end if
next sh

Steph wrote:

Hello. The bwlow snippet of code return each sheet in a workbook. Is there
a way to return on sheets that are visible? Thank you!

For Each sh In bk.Worksheets
ThisWorkbook.Worksheets("Sheet Verify").Cells(cell.Row, j).Value =
sh.Name
j = j + 1


--

Dave Peterson


All times are GMT +1. The time now is 02:20 PM.

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