Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rem Attribute VBA_ModuleType=VBAModule
- Option VBASupport 1
- '
- ' Ülesanne 1
- '
- ' suvaline number a ja b vahel, a välja arvatud, b sisse arvatud
- ' @param a arvu alampiir
- ' @param b arvu ülempiir
- ' @returns suvaline arv a ja b vahel
- Function Randbetween(a As Integer, b As Integer) As Integer
- ' arvutab suvalise arvu vahemikus
- Randbetween = CInt((b - a + 1) * Rnd()) + a
- End Function
- ' mängi lahutamismängu 100 piires
- ' 10 ringi, toimub läbi inputboxide
- ' mängu lõpuks saad raporti
- ' @returns Null
- Function Arvuta()
- ' deklareeri muutujad
- Dim i, x, y, oigeid As Integer
- Dim vastus As String
- ' defineeri muutujad
- i = 10
- oigeid = 0
- ' tee 10 korda
- Do
- ' leia ülesande jaoks vajalikud arvud
- x = Randbetween(51, 100)
- y = Randbetween(1, 50)
- ' küsi kasutajalt vastus
- vastus = InputBox(x & " - " & y, "Leia vastus!")
- If vastus = "" Then
- ' cancel/tühi vastus lõpetab
- GoTo tulemused
- Else
- ' kontrolli vastuse õigsust, anna tagasisidet
- If CInt(vastus) = x - y Then
- MsgBox ("Vastus on õige!")
- ' loenda õigeid
- oigeid = oigeid + 1
- Else
- MsgBox ("Vastus on vale!")
- End If
- End If
- i = i - 1
- Loop While i > 0
- ' deklareeri label tulemused
- tulemused:
- ' tulemuste käigus väljasta katsete arv, õigete arv, valede arv ja hinne (hinde saame eraldi funktsioonist)
- MsgBox ("Tehti " & i & " katset. Nendest " & oigeid & " õiget vastust ja " & (10 - oigeid) & " valet vastust.")
- Hinda (oigeid)
- End Function
- ' väljasta kasutajale hinne vastavalt õigete arvule
- ' 1..2 -> 1
- ' 3..4 -> 2
- ' ...
- Function Hinda(oigeid)
- Dim hinne As Integer
- ' leiab hinde intelligentsemal meetodil
- hinne = CInt((oigeid + 1) / 2#)
- MsgBox ("Hinne: " & hinne)
- End Function
- ' (Ülesanne 2 on Module2-s)
- '
- ' Ülesanne 3
- '
- ' ringjoone joonistamine
- Function Ringjoon()
- ' deklareeri muutujad
- Dim raadius As Integer, pindala As Integer, ymbermoot As Integer
- Dim Shp As Shape
- ' defineeri muutujad kasutades aritmeetikat
- ' loe andmeid töölehelt ning kirjuta töölehele
- ymbermoot = CInt(Range("C1").Value)
- raadius = ymbermoot / (2 * 3.14159265)
- Range("C2").Value = raadius
- pindala = raadius * raadius * 3.14159265
- Range("C3").Value = pindala
- ' hävita varasemad ringid
- For Each Shp In ActiveSheet.Shapes
- ' ära hävita nuppe (button)
- If Not (Shp.Type = msoFormControl) Then
- Shp.Delete
- End If
- Next Shp
- ' lisa uus ring
- Set ring = ActiveSheet.Shapes.AddShape(msoShapeOval, 100, 100, raadius * 10, raadius * 10)
- End Function
- '
- ' Ülesanne 4
- '
- ' animeeri Garfield posti otsa
- Function Hyppa()
- ' haara viide garfieldi pildile
- Set pilt = ActiveSheet.Shapes("Picture 1")
- ' deklareeri ja defineeri muutujad vastavalt töölehe andmetele
- Dim x As Integer, y As Integer
- x = Range("B1").Value
- y = Range("B2").Value
- ' nihuta pildi asukohta
- pilt.Top = y
- pilt.Left = x
- ' excel 07-10 jaoks vali suvaline cell
- Range("A1").Select
- ' oota 3s
- Application.Wait (Now() + TimeValue("00:00:03"))
- ' kasuta tagasi funktsiooni
- Tagasi
- End Function
- ' aseta pilt algasendisse
- Function Tagasi()
- ' haara viide garfieldi pildile
- Set pilt = ActiveSheet.Shapes("Picture 1")
- ' nihuta pilt
- pilt.Top = 200
- pilt.Left = 20
- End Function
- '
- ' Ülesanne 5
- '
- ' by riina
- Sub Hyple()
- ActiveSheet.Shapes(1).IncrementTop -30
- Application.Wait Now() + TimeValue("00:00:01")
- ActiveSheet.Shapes(1).IncrementLeft 5
- Application.Wait Now() + TimeValue("00:00:01")
- ActiveSheet.Shapes(1).IncrementTop 30
- Application.Wait Now() + TimeValue("00:00:01")
- DoEvents
- End Sub
- ' hüple 10x
- Sub HypleTsyklis()
- ' dekl ja def muutujad
- Dim i As Integer
- i = 10
- ' korda tegevust 10 korda
- Do
- Hyple
- i = i - 1
- Loop While i > 0
- End Sub
- ' hüple kasutaja sisend arvu kordi
- Sub Hyple2()
- ' deklar muutujad
- Dim kordi_temp As String, kordi As Integer
- ' kasutaja sisend
- kordi_temp = InputBox("Mitu korda hüppan", "hüppenöör")
- ' cancel nupu korral proovi uuesti
- If kordi_temp = "" Then
- MsgBox ("Palun sisesta midagi!")
- ' rekursioon
- Hyple2
- Else
- ' parse muutuja täisarvuks
- kordi = CInt(kordi_temp)
- ' hüple vastav arv kordi
- Do
- Hyple
- kordi = kordi - 1
- Loop While kordi > 0
- End If
- End Sub
- ' nihuta tüdruk algusesse
- Sub Algusesse()
- ActiveSheet.Shapes(1).Left = 0
- End Sub
- '
- ' Ülesanne 6 on Module2's lindistatult & muudetult
- '
- Rem Attribute VBA_ModuleType=VBAModule
- Option VBASupport 1
- ' ülesanne 2 makro
- ' teeb selle töötabeli vms ära
- Sub eyyyyy()
- Range("D2").Select
- ActiveCell.FormulaR1C1 = "esmaspäev"
- Range("E2").Select
- ActiveCell.FormulaR1C1 = "teisipäev"
- Range("F2").Select
- ActiveCell.FormulaR1C1 = "kolmapäev"
- Range("G2").Select
- ActiveCell.FormulaR1C1 = "neljapäev"
- Range("H2").Select
- ActiveCell.FormulaR1C1 = "reede"
- Range("I2").Select
- ActiveCell.FormulaR1C1 = "laupäev"
- Range("C3").Select
- ActiveCell.FormulaR1C1 = "8:00"
- Range("C4").Select
- ActiveCell.FormulaR1C1 = "9:00"
- Range("C3:C4").Select
- Selection.AutoFill Destination:=Range("C3:C14"), Type:=xlFillDefault
- Range("C3:C14").Select
- Range("D3:D8").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("E3:E8").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("F3:F8").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("G3:G8").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = True
- End With
- Selection.UnMerge
- Range("H3:H8").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("G3:G8").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("I3:I8").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("D9:D14").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("E9:E14").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("F9:F14").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("G9:G14").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("H9:H14").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("I9:I14").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("A2").Select
- Selection.Copy
- Range("D9:D14").Select
- ActiveSheet.Paste
- Range("F3:F8").Select
- ActiveSheet.Paste
- Range("A3").Select
- Application.CutCopyMode = False
- Selection.Copy
- Range("G9:G14").Select
- ActiveSheet.Paste
- Range("H3:H8").Select
- ActiveSheet.Paste
- Range("A4").Select
- Application.CutCopyMode = False
- Selection.Copy
- Range("D3:D8").Select
- ActiveSheet.Paste
- Range("H9:H14").Select
- ActiveSheet.Paste
- Range("A5").Select
- Application.CutCopyMode = False
- Selection.Copy
- Range("G3:G8").Select
- ActiveSheet.Paste
- Range("F9:F14").Select
- ActiveSheet.Paste
- Range("A6").Select
- Application.CutCopyMode = False
- Selection.Copy
- Range("E9:E14").Select
- Application.CutCopyMode = False
- Selection.Copy
- Range("A5").Select
- Application.CutCopyMode = False
- Selection.Copy
- Range("A6").Select
- Application.CutCopyMode = False
- Selection.Copy
- Range("E9:E14").Select
- ActiveSheet.Paste
- Range("I3:I8").Select
- ActiveSheet.Paste
- Range("A7").Select
- Application.CutCopyMode = False
- Selection.Copy
- Range("E3:E8").Select
- ActiveSheet.Paste
- Range("I9:I14").Select
- ActiveSheet.Paste
- Application.CutCopyMode = False
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent6
- .TintAndShade = -0.499984740745262
- .PatternTintAndShade = 0
- End With
- Range("E3:E8").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent6
- .TintAndShade = -0.499984740745262
- .PatternTintAndShade = 0
- End With
- Range("D3:D8").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .Color = 65535
- .TintAndShade = 0
- .PatternTintAndShade = 0
- End With
- Range("H9:H14").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .Color = 65535
- .TintAndShade = 0
- .PatternTintAndShade = 0
- End With
- Range("I3:I8").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorDark2
- .TintAndShade = -0.499984740745262
- .PatternTintAndShade = 0
- End With
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorDark2
- .TintAndShade = -0.499984740745262
- .PatternTintAndShade = 0
- End With
- Range("E9:E14").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorDark2
- .TintAndShade = -0.499984740745262
- .PatternTintAndShade = 0
- End With
- Range("F3:F8").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent5
- .TintAndShade = -0.249977111117893
- .PatternTintAndShade = 0
- End With
- Range("D9:D14").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent5
- .TintAndShade = -0.249977111117893
- .PatternTintAndShade = 0
- End With
- Range("G3:G8").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .Color = 10498160
- .TintAndShade = 0
- .PatternTintAndShade = 0
- End With
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent6
- .TintAndShade = -0.249977111117893
- .PatternTintAndShade = 0
- End With
- Range("F9:F14").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent6
- .TintAndShade = -0.249977111117893
- .PatternTintAndShade = 0
- End With
- Range("G9:G14").Select
- With Selection.Font
- .Color = -6279056
- .TintAndShade = 0
- End With
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .Color = 10498160
- .TintAndShade = 0
- .PatternTintAndShade = 0
- End With
- With Selection.Font
- .ColorIndex = xlAutomatic
- .TintAndShade = 0
- End With
- Range("H3:H8").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .Color = 10498160
- .TintAndShade = 0
- .PatternTintAndShade = 0
- End With
- Range("D3:I14").Select
- Range("I9").Activate
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlLeft
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlGeneral
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- .Orientation = 90
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- End With
- Selection.Font.Bold = True
- ActiveWorkbook.Save
- 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
- Range("G9:G14").Select
- ActiveWorkbook.Save
- Columns("D:I").Select
- Selection.ColumnWidth = 21.43
- Range("D2:I2").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Range("A1").Select
- End Sub
- Rem Attribute VBA_ModuleType=VBAModule
- Option VBASupport 1
- Sub Värvi(n As Integer)
- Do
- ActiveCell.Rows("1:1").EntireRow.Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent6
- .TintAndShade = -0.249977111117893
- .PatternTintAndShade = 0
- End With
- ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent5
- .TintAndShade = -0.249977111117893
- .PatternTintAndShade = 0
- End With
- ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent4
- .TintAndShade = -0.249977111117893
- .PatternTintAndShade = 0
- End With
- ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
- n = n - 1
- Loop While n > 0
- End Sub
- Sub VärviSisend()
- Dim sisend As String, kordi As Integer
- sisend = InputBox("Mitu korda värvin", "Värvi!")
- If sisend = "" Then
- MsgBox ("Palun sisesta midagi!")
- VärviSisend
- Else
- kordi = CInt(sisend)
- Värvi (kordi)
- End If
- End Sub
- Rem Attribute VBA_ModuleType=VBAModule
- Option VBASupport 1
- ' antud kera raadius, leiab selle kera ruumala
- ' @param r kera raadius
- Function KeraRuumala(r As Double) As Double
- KeraRuumala = (4 / 3#) * 3.1415926 * (r ^ 3)
- End Function
- ' antud kera raadius, leiab selle kera ruumala
- ' @param r kera raadius
- Function KeraPindala(r As Double) As Double
- KeraPindala = 4 * 3.1415926 * (r ^ 2)
- End Function
- ' kontrollib, kas arv on algarv, jagades seda korduvalt
- ' läbi iga täisarvuga 2st selle arvuni
- ' funktsiooni definitsioon
- Function OnAlgarv(arv As Integer) As Boolean
- ' muutuja dekl
- Dim i As Integer
- ' väärtuse andmine
- i = 2
- OnAlgarv = True
- ' alusta tsüklit
- Do
- ' kui arv jagub i-ga
- If arv / i = arv \ i Then
- OnAlgarv = False
- End If
- ' järgmine täisarv
- i = i + 1
- ' tsükkel käib kuni tingimused
- Loop While i < arv And OnAlgarv = True
- ' funktsiooni lõpp
- End Function
- Function PallidToText(pallid As Integer) As String
- Dim d As New Dictionary
- d(0) = "tuulevaikus"
- d(1) = "vaikne tuul"
- d(2) = "kerge tuul"
- d(3) = "nõrk tuul"
- d(4) = "mõõdukas tuul"
- d(5) = "kaunis tugev tuul"
- d(6) = "tugev tuul"
- d(7) = "vali tuul"
- d(8) = "tormine tuul"
- d(9) = "torm"
- d(10) = "tugev torm"
- d(11) = "maru"
- d(12) = "orkaan"
- PallidToText = d(pallid)
- End Function
- Function EnergiaHulk(ainetyyp As String, m As Double, t1 As Double, t2 As Double) As Double
- Dim erisoojus As Double
- erisoojus = AineErisoojus(ainetyyp)
- EnergiaHulk = erisoojus * m * (t2 - t1)
- End Function
- Function AineErisoojus(ainetyyp As String) As Double
- Dim d As New Dictionary
- d("Vesi") = 4.1911
- d("Jää") = 2.093
- d("Piim") = 3.936
- d("Raud") = 0.502
- d("Rasv") = 0.671
- d("Õli") = 1.779
- d("Kumm") = 1.424
- AineErisoojus = d(ainetyyp)
- End Function
- ' leiab fibonacci arve
- ' iga järgmine fibonacci arv on summa eelmisest kahest
- Function fibonacci(n As Integer) As Integer
- ' vigase sisendi korral anna veaväärtus
- If n < 0 Then
- fibonacci = -1
- End If
- ' nullis ja esimene fibonacci arv on 1
- If n = 0 Or n = 1 Then
- fibonacci = 1
- Else
- ' rekurseerides leia arv kui summa eelmisest kahest
- fibonacci = fibonacci(n - 1) + fibonacci(n - 2)
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment