Makro virker ikke på hjemmeside
Kan nogen give mig svar på hvorfor følgende makro virker fint når et regneark er gemt på en lokal diskenhed, men ikke når den kører fra hjemmeside.Arket "Optælling" findes på www.sysform.dk på forsiden.
Jeg skal bemærke at jeg lader arket fra hjemmesiden tillade at køre med makroer.
Følgende makro bruges til at generere nye opgaver:
Sub TilfældigFarve()
If [ca1] = "0" Then
Application.ScreenUpdating = False
Range("Ah16:Aq27").Copy Destination:=Range("a11:j22")
Range("Ak12:Az39").Copy Destination:=Range("k12:z39")
[ab12] = 0
[ab13] = 0
[ab14] = 0
[ab15] = 0
Randomize
x = Int(Rnd() * 5 + 1)
For r = 1 To x
For k = 1 To 5
Sheets("Fasit").Cells(r + 11, k + 5).Interior.ColorIndex = Int(Rnd() * 4 + 3)
Next
Next
'--- Slet eller Remark koden herunder hvis du foretrækker at anvende Functionen -------------------
'Sheets("Fasit").Range("AB12:AB15") = ""
For Each c In Sheets("Fasit").Range("F12:J16")
If c.Interior.ColorIndex = 3 Then Sheets("Fasit").Range("AB12") = Sheets("Fasit").Range("AB12") + 1
If c.Interior.ColorIndex = 4 Then Sheets("Fasit").Range("AB13") = Sheets("Fasit").Range("AB13") + 1
If c.Interior.ColorIndex = 5 Then Sheets("Fasit").Range("AB14") = Sheets("Fasit").Range("AB14") + 1
If c.Interior.ColorIndex = 6 Then Sheets("Fasit").Range("AB15") = Sheets("Fasit").Range("AB15") + 1
Next
'------ slet her til -------------------------------------------------------------------------------
Sheets("Fasit").Range("F12:J" & x + 11).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
If x = 1 Then GoTo om
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1").Select
GoTo slut
om:
Range("F13:J13").Select
Selection.Clear
Range("F12:J12").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1").Select
slut:
Sheets("Fasit").Range("F12:J16").Copy Sheets("Fasit").Range("F12")
Sheets("Fasit").Range("AF12").Calculate
Application.ScreenUpdating = True
If r = 2 Then
Range("f13:j13").Select
Selection.Interior.ColorIndex = 36
End If
Range("n13").Select
[ca1] = "1"
End If
End Sub
