Sub HDI()
' HDI Makro
Cells.Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Font
.Name = "Calibri"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection.Font
.Name = "Calibri"
.Size = 10.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection
.VerticalAlignment = xlTop
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Cells.EntireColumn.AutoFit
Range("D12").Select
ActiveSheet.ListObjects("Tabelle_owssvr_1__1").Name = "Tabelle"
ActiveSheet.ListObjects("Tabelle").Unlist
End Sub
' .TintAndShade = 0
' .ThemeFont = xlThemeFontMinor
(kennt mein Excel 2003 nicht) muss du wieder aktivieren.Sub HDI()
' HDI Makro
Dim wks As Worksheet, StatusCalc As Long
Set wks = ActiveSheet
'Makrobremsen aus
With Application
StatusCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
End With
With wks
Application.CutCopyMode = False
' .Cells.Select
' Selection.Copy
' ActiveSheet.Paste
' Application.CutCopyMode = False
With .Cells
.VerticalAlignment = xlTop
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Font
.Name = "Calibri"
.Size = 10.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
' .TintAndShade = 0
' .ThemeFont = xlThemeFontMinor
End With
End With
.ListObjects(1).Name = "Tabelle"
.ListObjects("Tabelle").Unlist
.Cells.EntireColumn.AutoFit
End With
'Makrobremsen zurücksetzen
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = StatusCalc
End With
End Sub
Sub HDI_Variante()
' Nur der Listenbereich wird kopiert.
Dim wks As Worksheet, objListe As ListObject, StatusCalc As Long
Set wks = ActiveSheet
'Makrobremsen aus
With Application
StatusCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
End With
Set objListe = wks.ListObjects(1)
With objListe
With .Range
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.EntireColumn.AutoFit
With .Font
.Name = "Calibri"
.Size = 10.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
' .TintAndShade = 0
' .ThemeFont = xlThemeFontMinor
End With
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
' .TintAndShade = 0
.Weight = xlThin
End With
End With
.Unlist
End With
'Makrobremsen zurücksetzen
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = StatusCalc
End With
End Sub
Sub HDI()
' HDI Makro
Dim wks As Worksheet, StatusCalc As Long
Set wks = ActiveSheet
'Makrobremsen aus
With Application
StatusCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
End With
With wks
Application.CutCopyMode = False
.Cells.Select
Selection.Copy
ActiveSheet.Paste
Application.CutCopyMode = False
With .Cells
.VerticalAlignment = xlTop
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Font
.Name = "Calibri"
.Size = 10.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
End With
.ListObjects(1).Name = "Tabelle"
.ListObjects("Tabelle").Unlist
.Cells.EntireColumn.AutoFit
End With
'Makrobremsen zurücksetzen
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = StatusCalc
End With
End Sub
Sub HDI_Variante()
' Nur der Listenbereich wird kopiert.
Dim wks As Worksheet, objListe As ListObject, StatusCalc As Long
Set wks = ActiveSheet
'Makrobremsen aus
With Application
StatusCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
End With
Set objListe = wks.ListObjects(1)
With objListe
With .Range
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.EntireColumn.AutoFit
With .Font
.Name = "Calibri"
.Size = 10.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End With
.Unlist
End With
'Makrobremsen zurücksetzen
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = StatusCalc
End With
End Sub
Sub HDI_Variante()
' Spalten des Listenbereichs werden formatiert und Tabelle(Listobjekt) in _
in einen Bereich umgewandelt.
Dim wks As Worksheet, objListe As ListObject, StatusCalc As Long
Dim ZeileTitel As Long
Set wks = ActiveSheet
'Makrobremsen aus
With Application
StatusCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
End With
Set objListe = wks.ListObjects(1)
With objListe
With .Range.EntireColumn
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.AutoFit
With .Font
.Name = "Calibri"
.Size = 10.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End With
'Titelzeile der Tabelle(Listobjekt merken)
ZeileTitel = .Range.Row
'Tabelle in Bereich umwandeln
.Unlist
End With
'Zeile mit Titelzeilen des früheren Listobjekts löschen
wks.Rows(ZeileTitel).Delete shift:=xlShiftUp
ResumeFehler:
Fehler:
With Err
Select Case .Number
Case 0 'kein Fehler
Case 9 'Index-Fehler Objekt nicht gefunden
MsgBox "Fehler-Nr.: " & .Number & vbLf & .Description & vbLf & vbLf _
& "Im Blatt gibt es wohl keine Tabelle (Listobject) mehr!"
Resume ResumeFehler:
Case Else
MsgBox "Fehler-Nr.: " & .Number & vbLf & .Description & vbLf _
& "intFehler = " & intFehler
End Select
End With
'Makrobremsen zurücksetzen
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = StatusCalc
End With
End Sub
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlEdgeLeft).Weight=xlThin
Selection.Font.Name = "Calibri"
um nochmal auf den Rahmen zurückzukommen:Selection.BorderAround Weight:=xlThin, Linestyle:=xlContinuous
Außerdem solltest du nicht mit Select arbeiten, sondern immer die Zellbereiche direkt angeben, dh nicht:Sub HDI_Variante()
' Spalten des Listenbereichs werden formatiert und Tabelle(Listobjekt) in _
in einen Bereich umgewandelt.
Dim wks As Worksheet, objListe As ListObject, StatusCalc As Long
Dim ZeileTitel As Long
Set wks = ActiveSheet
'Makrobremsen aus
With Application
StatusCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
End With
Set objListe = wks.ListObjects(1)
With objListe
With .Range.EntireColumn
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.AutoFit
With .Font
.Name = "Calibri"
.Size = 10.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End With
'Titelzeile der Tabelle(Listobjekt merken)
ZeileTitel = .Range.Row
'Tabelle in Bereich umwandeln
.Unlist
End With
'Zeile mit Titelzeilen des früheren Listobjekts löschen
wks.Rows(ZeileTitel).Delete shift:=xlShiftUp
ResumeFehler:
Fehler:
With Err
Select Case .Number
Case 0 'kein Fehler
Case 9 'Index-Fehler Objekt nicht gefunden
MsgBox "Fehler-Nr.: " & .Number & vbLf & .Description & vbLf & vbLf _
& "Im Blatt gibt es wohl keine Tabelle (Listobject) mehr!"
Resume ResumeFehler:
Case Else
MsgBox "Fehler-Nr.: " & .Number & vbLf & .Description & vbLf _
& "intFehler = " & intFehler
End Select
End With
'Makrobremsen zurücksetzen
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = StatusCalc
End With
End Sub
.WrapText = False
Set objListe = wks.ListObjects(1)
With objListe
With .Range.EntireColumn
.HorizontalAlignment = xlGeneral
Sub HDI_Variante()
' Spalten des Listenbereichs werden formatiert und Tabelle(Listobjekt) in _
in einen Bereich umgewandelt.
Dim wks As Worksheet, objListe As ListObject, StatusCalc As Long
Dim ZeileTitel As Long
Set wks = ActiveSheet
'Makrobremsen aus
With Application
StatusCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
End With
Set objListe = wks.ListObjects(1)
With objListe
With .Range
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
With .Font
.Name = "Calibri"
.Size = 10.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End With
'Titelzeile der Tabelle(Listobjekt merken)
ZeileTitel = .Range.Row
'Tabelle in Bereich umwandeln
.Unlist
End With
'Zeile mit Titelzeilen des früheren Listobjekts löschen
wks.Rows(ZeileTitel).Delete shift:=xlShiftUp
ResumeFehler:
Fehler:
With Err
Select Case .Number
Case 0 'kein Fehler
Case 9 'Index-Fehler Objekt nicht gefunden
MsgBox "Fehler-Nr.: " & .Number & vbLf & .Description & vbLf & vbLf _
& "Im Blatt gibt es wohl keine Tabelle (Listobject) mehr!"
Resume ResumeFehler:
Case Else
MsgBox "Fehler-Nr.: " & .Number & vbLf & .Description & vbLf _
& "intFehler = " & intFehler
End Select
End With
'Makrobremsen zurücksetzen
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = StatusCalc
End With
End Sub