AW: Werte in Spalten einfrieren
12.08.2014 09:29:48
fcs
Hallo Bon,
nachfolgend ein entsprechendes Makro.
Gruß
Franz
Sub Monat_einfrieren()
Dim lastrow As Long
Dim Spalte As Long, lastColumn As Long
Dim strMonat As String
strMonat = Worksheets("Test2").Range("D5")
With Worksheets("Test1")
If MsgBox("Daten für Monat """ & strMonat & """ in Tabelenblatt """ & .Name & """ _
einfrieren?", _
vbQuestion + vbOKCancel, "Monatsdaten einfrieren") = vbCancel Then Exit Sub
lastColumn = .Cells(2, .Columns.Count).End(xlToLeft).Column
Application.ScreenUpdating = False
For Spalte = 2 To lastColumn
If Left(.Cells(2, Spalte), Len(strMonat)) = strMonat Then
lastrow = .Cells(.Rows.Count, Spalte).End(xlUp).Row
If lastrow > 2 Then
With .Range(.Cells(3, Spalte), .Cells(.Rows.Count, Spalte).End(xlUp))
.Value = .Value
End With
End If
End If
Next
Application.ScreenUpdating = True
End With
End Sub