Avatar billede lars_u Juniormester
15. marts 2009 - 13:02 Der er 5 kommentarer

Langsom makro

hej alle
.kan denne skrives på en anden måde?
.Man skal kunne bruge copy/paste.
Når man gør det flytter man også rundt på
betinget formateringer...
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
  CheckBox2.Value = False
  CheckBox3.Value = False
  CheckBox4.Value = False
  CheckBox5.Value = False
  CheckBox6.Value = False
  CheckBox7.Value = False
  CheckBox8.Value = False
  CheckBox9.Value = False
  CheckBox10.Value = False
  CheckBox11.Value = False
  CheckBox12.Value = False
  CheckBox13.Value = False
  CheckBox14.Value = False
  CheckBox15.Value = False
  CheckBox16.Value = False
  CheckBox17.Value = False
  CheckBox18.Value = False
  CheckBox19.Value = False
  CheckBox20.Value = False
  CheckBox21.Value = False
  CheckBox22.Value = False
  CheckBox23.Value = False
  CheckBox33.Value = False
  CheckBox34.Value = False
  CheckBox35.Value = False
  CheckBox36.Value = False
  CheckBox37.Value = False
  CheckBox38.Value = False
  CheckBox39.Value = False
  CheckBox40.Value = False
  CheckBox41.Value = False
  CheckBox42.Value = False
  CheckBox43.Value = False
  CheckBox44.Value = False
  End If
Password = "xxx"
ActiveSheet.Unprotect Password
        With Range("C4:O26")
      .FormatConditions.Delete
      End With
      With Range("C4")
      .FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=$AI$4=sand"
      .FormatConditions(1).Interior.ColorIndex = 33
        End With
With Range("D4:O4")
      .FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=$AI$4=sand"
      .FormatConditions(1).Interior.ColorIndex = 15
      Password = "xxx"
ActiveSheet.Protect Password
        End With
  End Sub
mvh. Lars
Avatar billede kabbak Professor
15. marts 2009 - 14:30 #1
Private Sub CheckBox1_Click()
Dim I As Integer, Password As String
    If CheckBox1.Value = True Then
        For I = 2 To 5 ' ret  5 til 44
            ActiveSheet.OLEObjects("CheckBox" & I).Object.Value = False
        Next
    End If

  Password = "xxx"
  ActiveSheet.Unprotect Password
    Range("C4:O26").FormatConditions.Delete
    Range("C4").FormatConditions.Add Type:=xlExpression, Formula1:="=$AI$4=sand"
    Range("C4").FormatConditions(1).Interior.ColorIndex = 33

    Range("D4:O4").FormatConditions.Add Type:=xlExpression, Formula1:="=$AI$4=sand"
    Range("D4:O4").FormatConditions(1).Interior.ColorIndex = 15
    ActiveSheet.Protect Password

End Sub
Avatar billede lars_u Juniormester
15. marts 2009 - 15:49 #2
hej kabbak
Jeg får fejl:
http://peecee.dk/upload/view/160112
Lars
Avatar billede kabbak Professor
15. marts 2009 - 16:03 #3
Måske er det op låsningen, der skal ske noget før, prøv.


Private Sub CheckBox1_Click()
Dim I As Integer, Password As String
  Password = "xxx"
  ActiveSheet.Unprotect Password

    If CheckBox1.Value = True Then
        For I = 2 To 5 ' ret  5 til 44
            ActiveSheet.OLEObjects("CheckBox" & I).Object.Value = False
        Next
    End If


    Range("C4:O26").FormatConditions.Delete
    Range("C4").FormatConditions.Add Type:=xlExpression, Formula1:="=$AI$4=sand"
    Range("C4").FormatConditions(1).Interior.ColorIndex = 33

    Range("D4:O4").FormatConditions.Add Type:=xlExpression, Formula1:="=$AI$4=sand"
    Range("D4:O4").FormatConditions(1).Interior.ColorIndex = 15
    ActiveSheet.Protect Password

End Sub
Avatar billede lars_u Juniormester
22. marts 2009 - 13:15 #4
hej igen
Det ændre desvære ikke noget.Men jeg tror det er fordi at jeg har mistet overblikket...
Det ville være meget lettere hvis man i VBA kunne disable al paste på nær paste værdier.
Det skal ikke være muligt at overskrive betinget formateringer, men man skal kunne skrive i cellerne og paste værdier.
mvh.
Lars Fatsvag
Avatar billede lars_u Juniormester
04. april 2009 - 13:56 #5
hej igen
Har fundet denne makro.Eneste "problem":
Efter indtatning i celle skal man trykke dobbelt enter for at komme ud af cellen.
Private Sub Worksheet_Change(ByVal Target As Range)
'retain formatting when a cell is copied over
'Note: works only with with copy/paste, not cut/paste
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub
Mvh. Lars
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Excel kurser for alle niveauer og behov – find det kursus, der passer til dig

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester