Har du set hvor smart det kan være?

Microsoft Office, Word skabeloner, Excel regnearkSmart Office Word skabelon system

SmartOffice - ForEachWorkSheet

Bruges når noget kode skal afspilles for hvert eneste ark i regnearket. Makroen hopper tilbage til det ark, der var aktiveret ved makro'ens start.



Eksempel 1

Public Sub ForEachWorkSheet()
'Flemming Vadet, August 1999, fv@smartoffice.dk
    Dim Ws As Worksheet
    Dim WsA As Worksheet
    Set WsA = ActiveSheet

    For Each Ws In ActiveWorkbook.Worksheets
        '[din kode til hvert Ark]
    Next Ws
    
    WsA.Select
    Set Ws = Nothing
    Set WsA = Nothing
End Sub


Test 1

Public Sub Test_ForEachWorkSheet()
    Dim Ws As Worksheet
    Dim WsA As Worksheet
    Set WsA = ActiveSheet

    For Each Ws In ActiveWorkbook.Worksheets
        'Indsætter arkets egne navne ind i celle A1 i alle ark
        Ws.Range("A1") = Ws.Name
    Next Ws
    
    WsA.Select
    Set Ws = Nothing
    Set WsA = Nothing
End Sub
   

Smart Office Freeware Smart Data Management
Compare 2 Columns
Excel Super- Subscript
Teachers Excel Tools
         
Smart Office - Word og Excel specialist