Vba
Vba
Sub demo()
End Sub
2.
Sub demo()
Worksheets(3).Select
Range("A1") = "NIBM"
End Sub
Sub demo()
'Worksheets(4).Select
'Range("A1") = "NIBM"
MsgBox Worksheets.Count
End Sub
Sub demo()
'Worksheets(4).Select
'Range("A1") = "NIBM"
'MsgBox Worksheets.Count
MsgBox Sheets.Count 'counts also the chart sheet along with other ssheets
End Sub
5 Range charancteristics
Sub try()
'Range("c:c") = 100
'Range("imput").Value = 10000
Range("D1:D10").Font.Color = vbRed
Range("D1:D10").Font.Bold = True
End Sub
6 Range Characteristics
Sub try()
'Range("c:c") = 100
'Range("imput").Value = 10000
'Range("D1:D10").Font.Color = vbRed
'Range("D1:D10").Font.Bold = True
'Range("A1:E100").ClearContents
'Cells(1, 1) = 100
Range("A5").Cells(5, 2) = "NIBM" 'from A5 go 5 row and 2 colums below and write NIBM
End Sub
7 Copy Paste
Sub trial()
Range("B1:B20").Copy
Sheets(3).Select
Cells(1, 15).Select
ActiveSheet.Paste
End Sub
8 Paste Special
Sub Macro1()
'
'
Sheets(4).Select
Range("C204:F219").Copy
Sheets("Ratios").Select
Range("K2").Select
:=False, Transpose:=False
End Sub
Sub demo()
End Sub
10 : Loan Schedule
Sub demo()
Dim rg As String
per = Range("B1")
Range("A8:D1000").ClearContents
Range("A7:D7").Copy Range(rg)
End Sub
11 ListBoxWithMacro
Sub trial()
Sheets(2).Select
mon = Range("C1")
Sheets(1).Select
Sheets(2).Select
Range("F1").Select
Selection.PasteSpecial Paste:=xlPasteValues
End Sub
12 Worksheet function
Sub stat()
'MsgBox VBA.Sqr(25)
'MsgBox VBA.UCase("nibm")
'num = WorksheetFunction.Count(Range("B2:M22"))
'MsgBox num
End Sub
Sub stat()
Dim rg As String
Sheets("Summary").Select
yr = Range("E7")
brno = Range("E9")
Sheets(WorksheetFunction.Text(yr, 0)).Select
sm = WorksheetFunction.Sum(Range(rg))
avg = WorksheetFunction.Average(Range(rg))
max = WorksheetFunction.max(Range(rg))
min = WorksheetFunction.min(Range(rg))
Sheets("Summary").Select
Range("I8") = sm
Range("I9") = avg
Range("I10") = max
Range("I11") = min
End Sub
Sub for_demo()
Dim sm As Double
sm = 0
For i = 1 To 5
sm = sm + i
Next i
MsgBox sm
End Sub
Sub for_demo()
Range("A6:D1000").ClearContents
rt = Range("A1")
per = Range("B1")
amt = Range("C1")
For i = 1 To per
Cells(i + 5, 1) = i
If i = 1 Then
End If
Next i
End Sub
Sub func()
Dim sm As Double
sm = 0
Next i
MsgBox num
End Sub
Sub func()
j=1
Cells(j, 1) = i
j=j+1
Next i
End Sub
Sub multiple_for()
For mon = 2 To 13
For br = 2 To 601
Next mon
End Sub
Sub goal_seek()
For i = 3 To 12
s = "H" & i
Next i
End Sub
Sub salary()
For i = 1 To 3
Sheets(i).Select
Range("G2:G51").Copy
Sheets("Final").Select
Cells(2, i + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Next i
End Sub
Sub int_prin()
For i = 2 To 11
rt = Cells(i, 1)
tot = Cells(i, 2) * 12
prin = Cells(i, 3)
paid = Cells(i, 9)
out_int = 0
out_prin = 0
Next j
Cells(i, 7) = out_int
Cells(i, 8) = out_prin
Next i
End Sub
22 Top 5 numbers
Sub ntop()
Sheets(2).Select
Cells.ClearContents
Sheets(1).Select
k=2
For i = 2 To 6
For j = 1 To 5
Sheets(1).Select
Cells(j, i) = top
Next j
Next i
End Sub
23 Assignment q1
Sub bond_cash_flow()
Sheets(2).Select
num = 0
For i = 2 To 11
rem_co = Cells(i, 6)
cou = Cells(i, 2)
freq = Cells(i, 4)
Cells(i, 7) = num
Next i
End Sub
24 Assignment q2
Sub loan_cash()
Range("A7:D2000").ClearContents
amt = Cells(1, 2)
freq = Cells(3, 4)
per = Cells(1, 4) * freq
rt = Cells(3, 2)
For i = 7 To per + 6
Cells(i, 1) = i - 6
If i = 7 Then
Else
End If
Next i
End Sub
25 Assignment q3
Sub goal_seek()
For i = 2 To 12
amt = Cells(i, 2)
Cells(i, 5) = Cells(i, 2)
Cells(i, 2) = amt
Next i
End Subs
26 solver using macro example
Sub solver_demo()
'
'
'
Application.DisplayAlerts = False
Sheets(1).Select
Dim rg As String
For i = 1 To 5
Sheets(1).Select
Range("B14:F14").Copy
amt = Range("H14")
Sheets(2).Select
Cells(i, 1).Select
ActiveSheet.Paste
Cells(i, 6) = amt
Next i
Application.DisplayAlerts = True
End Sub
Sub trades()
For i = 2 To 26
Sheets(1).Select
sec = Cells(i, 1)
For j = 2 To 13
Sheets(j).Select
Sheets(1).Select
Cells(i, j) = num
Next j
Next i
Application.ScreenUpdating = True
End Sub
28 Array example
Sub array_ex()
Dim sm As Double
For i = 1 To 1000
sm = sm + num(i)
Cells(i, 1) = num(i)
Next i
'MsgBox sm
End Sub
Sub corel()
Dim rg As Range
Sheets(1).Select
Set rg = Range("A2:D570")
rg.Font.Bold = True
Sheets(2).Select
Cells.Clear
For i = 1 To 4
For j = 1 To 4
Next j
Next i
End Sub
Sub input_demo()
MsgBox age
End Sub
31 function example
End Function
Sub demo()
Dim fr As Single
End Sub