“Durch Zellen schleifen” Code-Antworten

Durch Zellen schleifen

Sub ForEachItemInArray()
    Dim arrValue As Variant
    Dim Item As Variant
    arrValue = Array("Item 1", "Item 2", "Item 3")
    
    For Each Item In arrValue
        MsgBox Item
    Next Item
    
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub If_Loop()
Dim Cell as Range
 
  For Each Cell In Range("A2:A6")
    If Cell.Value > 0 Then
      Cell.Offset(0, 1).Value = "Positive"
    ElseIf Cell.Value < 0 Then
      Cell.Offset(0, 1).Value = "Negative"
    Else
      Cell.Offset(0, 1).Value = "Zero"
     End If
  Next Cell
 
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub ForEachCell()
    Dim Cell As Range
    
    For Each Cell In Sheets("Sheet1").Range("A1:A10")
        Cell.Offset(0, 1).value = Cell.value
    Next Cell
    
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub HideAllSheets()
    Dim ws As Worksheet
 
    For Each ws In Sheets
        ws.Visible = xlSheetHidden
    Next ws
    
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub ForEachWorkbooks()
    Dim wb As Workbook
    
    For Each wb In Workbooks
        wb.Close
    Next wb
    
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub ProtectAllSheets()
    Dim ws As Worksheet
 
    For Each ws In Sheets
        ws.Protect Password:="..."
    Next ws
    
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub ForEachCharts()
    Dim cht As ChartObject
    
    For Each cht In Sheets("Sheet1").ChartObjects
        cht.Delete
    Next cht
    
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub ForEachTables()
    Dim tbl As ListObject
    
    For Each tbl In Sheets("Sheet1").ListObjects
        tbl.Delete
    Next tbl
    
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub DeleteAllShapesOnAllWorksheets()
    Dim Sheet As Worksheet
    Dim Shp As Shape
    
 
    For Each ws In Sheets
        For Each Shp In ws.Shapes
            Shp.Delete
        Next Shp
    Next ws
    
End Sub
Yellowed Yak

Durch Zellen schleifen

Sub ForEachNumberInNumbers()
    Dim arrNumber(1 To 3) As Integer
    Dim num As Variant
    
    arrNumber(1) = 10
    arrNumber(2) = 20
    arrNumber(3) = 30
    
    For Each num In arrNumber
        Msgbox Num
    Next num
    
End Sub
Yellowed Yak

Ähnliche Antworten wie “Durch Zellen schleifen”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen