muhammad susanto
Well-known Member
- Joined
- Jan 8, 2013
- Messages
- 2,077
- Office Version
- 365
- 2021
- Platform
- Windows
hi expert..
this code working well for all sheet included hidden sheets.
i want to the code only work in visible sheets not included hidden sheets
how to modify that code
someone figure out me, thank in advance..
.sst
this code working well for all sheet included hidden sheets.
i want to the code only work in visible sheets not included hidden sheets
VBA Code:
Sub Consolidate_Worksheets()
Dim ws As Worksheet
Dim sh As Worksheet
Dim a As Variant
Dim i As Long
Dim R As Long
Application.ScreenUpdating = False
Set sh = ActiveSheet
sh.Range("A1").CurrentRegion.Offset(1).ClearContents
R = 2
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> ActiveSheet.Name And ws.Name <> "etc.." Then
With ws
a = Array("a1", "a5", "a6", "a7", "a8", "a8", "a9", "a10", "b5", "b6", "b7", "b8", "b9", "b10" _
, "c5", "c6", "c7", "c8", "c9", "c10", "f5", "f6", "f7", "f8", "f9", "f10", "g5", "g6" _
, "g7", "g8", "g9", "g10", "h5", "h6", "h7", "h8", "h9", "h10")
For i = LBound(a) To UBound(a)
a(i) = .Range(a(i)).Value
If i >= 100000 Then a(i) = Val(AlphaNum(CStr(a(i))))
Next i
sh.Range("A" & R).Resize(, UBound(a) + 1).Value = a
R = R + 1
End With
End If
Next ws
Application.ScreenUpdating = True
End Sub
Function AlphaNum(txt As String, Optional numOnly As Boolean = True) As String
With CreateObject("VBScript.RegExp")
.Pattern = IIf(numOnly = True, "\D+", "-?\d+(\.\d+)?")
.Global = True
AlphaNum = .Replace(txt, "")
End With
End Function
someone figure out me, thank in advance..
.sst