Excel, Makro, VBA örnekleri

Makro Örnekleri.

Excel Makro Örnekleri

Sub ASC_Fonksiyonu() ‘Asci Karakter Kodu MsgBox Asc([A1]) MsgBox Asc(“B”) ‘ 66. MsgBox Asc(“b”) ‘ 98. MsgBox Asc(“Bülent”) ‘ 66. End Sub Sub Average_Fonksiyonu() ‘Ortalama MsgBox WorksheetFunction.Average(10, 20, 30) MsgBox WorksheetFunction.Average([A1], [A2], [A3], [A4]) End Sub Sub Choose_Fonksiyonu() ‘Belirli sıradakini seç For i = 1 To 4 sec = VBA.Choose(i, “10″, “20″, “30″, “40″) MsgBox sec Next i End Sub Sub Count_Fonksiyonu() ‘Say MsgBox WorksheetFunction.Count(Range(“A1:A10″)) End Sub Sub CountA_Fonksiyonu() ‘Dolu Say MsgBox WorksheetFunction.CountA(Range(“A1:A10″)) End Sub Sub CountBlank_Fonksiyonu() ‘Boşluk Say MsgBox WorksheetFunction.CountBlank(Range(“A1:A10″)) End Sub Sub CountIf_Fonksiyonu() ‘Belirli değerden mevcut adedi Say MsgBox WorksheetFunction.CountIf(Range(“A1:A10″), 2) ‘Sayılacak değer 2 End Sub Sub Find_Fonksiyonu() ‘Bul (adres) MsgBox Range(“A1:A10″).Find(2, LookIn:=xlValues).Address(0, 0) End Sub Sub MAX_Fonksiyonu() ‘En büyük değer MsgBox WorksheetFunction.Max(Range(“A1:A10″)) End Sub Sub MIN_Fonksiyonu() ‘En küçük değer MsgBox WorksheetFunction.Min(Range(“A1:A10″)) End Sub Sub Rept_Fonksiyonu() ‘Tekrarla MsgBox WorksheetFunction.Rept(“B”, 5) End Sub Sub Replace_Fonksiyonu() ‘Değiştir MsgBox VBA.Replace(“SARAN”, “N”, “R”, 1) End Sub Sub ABS_Fonksiyonu() ‘Pozitif yap MsgBox VBA.Abs(-10) End Sub Sub InStr_Fonksiyonu() ‘Kelime içinde harf arayıp, sırasını bulma, örnek “a” MsgBox VBA.InStr(1, “Osman”, “a”) End Sub Sub InStr2_Fonksiyonu() ‘Cümle içinde kelime arayıp, kelimenin ilk harfinin sırasını bulmak, örnek “sağlık” MsgBox VBA.InStr(1, “Yeni yıl herkese mutluluk ve sağlık getirsin.”, “sağlık”) End Sub Sub InStrRev_Fonksiyonu() ‘Kelime içinde tersten harf arayıp, sırasını bulma, örnek “e” MsgBox VBA.InStrRev(“Yasemin”, “e”, -1) End Sub Sub LCase_Fonksiyonu() ‘Küçük harf yap MsgBox VBA.LCase(“Yasemin”) End Sub Sub UCase_Fonksiyonu() ‘Büyük harf yap MsgBox VBA.UCase(“Sinem”) End Sub Sub Proper_Fonksiyonu() ‘İlk harf büyük, diğerleri küçük olsun. MsgBox WorksheetFunction.Proper(“MEHMET”) End Sub Sub Left_Fonksiyonu() ‘Soldan ilk 5. karakter MsgBox VBA.Left(“bt-tr.net”, 5) End Sub Sub Right_Fonksiyonu() ‘Sağdan ilk 3. karakter MsgBox VBA.Right(“bt-tr.net”, 3) End Sub Sub Mid_Fonksiyonu() ‘8.karakterden başlayıp, 4 karakter göster MsgBox VBA.Mid(“hepsiburada.com”, 8, 4) End Sub Sub Len_Fonksiyonu() ‘Uzunluk MsgBox VBA.Len(“bt-tr.Net”) End Sub Sub LTrim_Fonksiyonu() ‘Soldan boşlukları kaldır MsgBox VBA.LTrim(” bt-tr.net “) End Sub Sub RTrim_Fonksiyonu() ‘Sağdan boşlukları kaldır MsgBox VBA.RTrim(” bt-tr.net “) End Sub Sub Trim_Fonksiyonu() ‘Sağdan ve soldan bütün boşlukları kaldır MsgBox VBA.Trim(” bt-tr.net “) End Sub Sub Switch_Fonksiyonu_ornek() ‘Karşılığını bul BaskentBul = Switch_Fonksiyonu(“Türkiye”) End Sub Function Switch_Fonksiyonu(Başkent As String) BaskentBul = Switch(Başkent = “Türkiye”, “Ankara”, Başkent = “İtalya”, “Roma”, Başkent = “Fransa”, “Paris”) MsgBox BaskentBul End Function Sub Chr_Fonksiyonu() ‘Chr kodları On Error Resume Next For x = 1 To 255 Range(“A” & x) = x Range(“B” & x) = Chr(x) Next MsgBox “Bitti” End Sub

Yeni yorum ekle