Idézet: Delila - Dátum: 2011. 03. 01. 07:21
A lenti makrót ahhoz a laphoz kell rendelned, amelyik lapon ezt az automatikus formázást létre akarod hozni. Lapfülön jobb klikk, Kódlap megjelenítése. A VB szerkesztőben jobb oldalon kapott üres lapra másold be.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim uoszlop As Long
If Target = "GTR" Then
With Range(Target.Address)
.Font.ColorIndex = 3
.Font.Size = 12
End With
With Cells(Target.Row, Target.Column - 1)
.Font.ColorIndex = 5
.Font.Size = 10
End With
End If
If Target = "Mici" Then
uoszlop = Range(Target.Address).End(xlToRight).Column
With Range(Cells(Target.Row, 1), Cells(Target.Row, uoszlop))
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
End With
End If
End SubLehet, hogy valamit elszúrtam a két kódsor összevágásával, de nem működik....
Private Sub Worksheet_Change(ByVal Target As Range)
'feltételek (N oszlop, A érték)
If Target.Column = 14 And Target.Value = "A" Then
'a lapvédelem feloldása a makró futásának idejére
ActiveSheet.Unprotect Password:="Lacika"
'az aktuális sor zárolása
Rows(Target.Row).Locked = True
'lapvédelem beállításai
ActiveSheet.Protect Password:="Lacika", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End If
Dim uoszlop As Long
If Target = "GTR" Then
With Range(Target.Address)
.Font.ColorIndex = 3
.Font.Size = 12
End With
With Cells(Target.Row, Target.Column - 1)
.Font.ColorIndex = 5
.Font.Size = 10
End With
End If
If Target = "Mici" Then
uoszlop = Range(Target.Address).End(xlToRight).Column
With Range(Cells(Target.Row, 1), Cells(Target.Row, uoszlop))
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
End With
End If
End Sub
Szerkesztette: illusion 2011. 03. 01. 08:37 -kor

Súgó
A téma zárva.













