Anzeige
Archiv - Navigation
1256to1260
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Makro anpassen

Makro anpassen
Silke
Hallo,
ich habe das Makro im Forum gefunden.
  • 
    Private Sub Rahmen_einfügen()
    'Wenn Zelle in Spalte A gefüllt, dann Rahmen über bedingte Formatierung einfügen
    Dim Wert1 As String
    Dim Wert2 As String
    Wert1 = InputBox("bitte Zelle eingeben, mit der begonnen werden soll", "erster Wert", "A1")
    Wert2 = InputBox("bitte Zelle eingeben, mit der Rahmen enden soll", "zweiter Wert", "N20000")
    Range(Wert1 & ":" & Wert2).Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A1"""""
    With Selection.FormatConditions(1).Borders(xlLeft)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.FormatConditions(1).Borders(xlRight)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.FormatConditions(1).Borders(xlTop)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.FormatConditions(1).Borders(xlBottom)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    Range("a1").Select
    End Sub
    

  • Das Makro passt aber nicht. Beginn soll immer A1 sein und Ende (sowohl Zeile / Spalte) immer die letzte gefüllte Zelle.
    Ich kenne mich damit aber nicht aus. Kann mir jemand schnell helfen?
    Vielen Dank!
    Silke

    6
    Beiträge zum Forumthread
    Beiträge zu diesem Forumthread

    Betreff
    Benutzer
    Anzeige
    AW: Makro anpassen
    05.04.2012 10:22:38
    ChrisL
    Hi Silke
    Sub Rahmen_einfügen()
    Dim rng As Range
    Set rng = ActiveSheet.UsedRange
    rng.FormatConditions.Delete
    rng.FormatConditions.Add Type:=xlExpression, Formula1:="=$A1"""""
    With rng.FormatConditions(1).Borders(xlLeft)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With rng.FormatConditions(1).Borders(xlRight)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With rng.FormatConditions(1).Borders(xlTop)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With rng.FormatConditions(1).Borders(xlBottom)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    End Sub
    

    Gruss
    Chris
    Anzeige
    Rahmen in bed. Formatierung mit For-Schleife
    05.04.2012 10:58:05
    Reinhard
    Hallo Chris,
    weißt du wie man in "Klappt_Nicht" wie in "Klappt" die For-Schleife einsetzen kann?
    (xlLeft=7 usw.)
    Derzeit kommt bei
    .LineStyle = xlContinuous
    Fehler 1004, iws: Eigenschaft konnte nicht festgelegt werden
    Option Explicit
    Sub Klappt()
    Dim N As Byte
    With Worksheets("Tabelle1").UsedRange
    For N = 7 To 10
    With .Borders(N)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    Next N
    End With
    Range("a1").Select
    End Sub
    Sub Klappt_Nicht()
    Dim N As Byte
    With Worksheets("Tabelle1").UsedRange
    .FormatConditions.Delete
    .FormatConditions.Add Type:=xlExpression, Formula1:="=$A1"""""
    For N = 7 To 10
    With .FormatConditions(1).Borders(N)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    Next N
    End With
    Range("a1").Select
    End Sub
    

    Gruß
    Reinhard
    Anzeige
    AW: Rahmen in bed. Formatierung mit For-Schleife
    05.04.2012 11:12:47
    ChrisL
    Hi Reinhard
    Ich vermute:
    For N = 1 To 4
    cu
    Chris
    AW: Rahmen in bed. Formatierung mit For-Schleife
    05.04.2012 11:33:57
    Reinhard
    Hallo Chris,
    deine Vermutungen möchte ich haben :-) Ja, funktioniert. Ich mußte anders A1 selektieren
    sonst wird falsch referenziert.
    Sub Klappt_Jetzt_Auch()
    Dim N As Byte
    With Worksheets("Tabelle1").UsedRange
    .Parent.Range("A1").Select
    .FormatConditions.Delete
    .FormatConditions.Add Type:=xlExpression, Formula1:="=$A1"""""
    For N = 1 To 4
    With .FormatConditions(1).Borders(N)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    Next N
    End With
    End Sub
    

    Gruß
    Reinhard
    Anzeige
    AW: Rahmen in bed. Formatierung mit For-Schleife
    05.04.2012 13:51:11
    Tino
    Hallo,
    oder vielleicht auch so
    
    Private Sub Rahmen_einfügen()
    Dim aktWS As Worksheet, i%, iCalc%
    Set aktWS = ActiveSheet
    With Application
    iCalc = .Calculation
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
    'Tabelle anpassen !!!!!!!!!!!!!!!
    With Sheets("Tabelle1")
    .Select
    .Cells.FormatConditions.Delete
    With .UsedRange
    With .FormatConditions.Add(Type:=xlExpression, _
    Formula1:="=$A" & ActiveCell.Row & """""")
    For i = 1 To 4
    With .Borders(i)
    .LineStyle = xlContinuous
    .TintAndShade = 0
    .Weight = xlThin
    End With
    Next i
    End With
    End With
    End With
    aktWS.Select
    .EnableEvents = True
    .Calculation = iCalc
    .ScreenUpdating = True
    End With
    End Sub
    
    Gruß Tino
    Anzeige
    AW: Rahmen in bed. Formatierung mit For-Schleife
    07.04.2012 14:05:10
    Silke
    Hallo,
    vielen Dank für Eure gemeinschaftliche Hilfe!
    Die Lösung von Reinhard funktioniert prima.
    Silke

    Links zu Excel-Dialogen

    Beliebteste Forumthreads (12 Monate)

    Anzeige

    Beliebteste Forumthreads (12 Monate)

    Anzeige
    Anzeige
    Anzeige