In meinem Code "
Sub Bereich" nehme ich verschiedene Bereichsdefinitionen im Worksheet "GLOBAL"vor. Am Ende des _
Codes rufe ich den "
Sub Format" auf.
Dieser sollte mir ebenfalls im Worksheet "GLOBAL"in der Spalte E die Zahlen im Textformat in " _
richtige" Zahlen umwandeln und die übrigen Werte übernehmen.
Der Code Bereiche wird ausgeführt, wenn ich die Tabelle "GLOBAL" verlasse.
Sub Worksheet_Deactivate()
Application.StatusBar = ""
Call Bereiche
End Sub
Nun habe ich eine weitere Tabelle mit Namen "Bedingungen" in das Workbook eingefügt. Wenn ich _
nun im Workbook "GLOBAL" bin und die neue Tabelle anwähle, wird der "
Sub Format" in der Tabelle "Bedingungen" ausgeführt,
If IsNumeric(Cells(i, lngSpa)) Then
Cells(i, lngSpa) = Val(Cells(i, lngSpa)) 'Umwandeln Text(als Zahl) in Zahl
Else
Cells(i, lngSpa) = Cells(i, lngSpa)
End If
im Ergebnis habe ich in der Spalte E viele Nullen. Was ist bei meinem Code falsch, dass sich _
dieser nicht nur auf die Tabelle "GLOBAL" beschränkt?
Danke für eine Rückmeldung.
Peter
Sub Bereiche()
Dim lngSpa As Long, lngAnf As Long, lngEnd As Long, i As Long
Dim Bereich As Range
lngAnf = 1
lngEnd = Sheets("GLOBAL").Cells(65536, 5).End(xlUp).Row 'ermittelt letzten Eintrag in _
Spalte E (Pfad)
Set Bereich = Worksheets("Global").Range("Q" & lngAnf, "Q" & lngEnd) 'Kategorie der Werte
Names.Add _
Name:="xKat_rechts", _
RefersTo:=Bereich, Visible:=True
With Range("xWert")
.Formula = "=RC[-5]+RC[-1]"
.Value = .Value
End With
Call Formate
Application.StatusBar = ""
End
Sub
Sub Formate()
Dim lngSpa As Long, lngAnf As Long, lngEnd As Long, i As Long
Dim Bereich As Range
With Sheets("GLOBAL")
lngAnf = 1
lngEnd = Sheets("GLOBAL").Cells(65536, 5).End(xlUp).Row 'ermittelt letzten Eintrag in _
Spalte E (Pfad)
lngSpa = 5 'Spalte E
For i = 1 To lngEnd
Application.StatusBar = "Zeile " & i & " von " & lngEnd & " in Arbeit (Umwandlung Text- in _
Zahlenformat)"
If IsNumeric(Cells(i, lngSpa)) Then
Cells(i, lngSpa) = Val(Cells(i, lngSpa)) 'Umwandeln Text(als Zahl) in Zahl
Else
Cells(i, lngSpa) = Cells(i, lngSpa)
End If
Next
End With
End Sub