Beruflich Dokumente
Kultur Dokumente
1.pir adl sayfay kopyalayarak 10 adet oaltr ve .pir ekler 1.Satr 1.Stunu se
10 Sn sreli mesaj
4 ilem program(basit)
4. Stunda (Satrda) lem Yaplrsa Makro Otomatik alr 4. Stunda ilem yaplrsa macro otomatik alsn
A ile b'yi karlatr, ayn olanlar c'ye, farkl olanlar d'ye yaz
A stunu Auto_Copy
A stununda verilere gre sayfa ekler ve d stununa kadar olan verileri de yazar
A Stunundaki Dolu Satrlarn Altna Bo Satr Eklemek A stunundaki en byk say iin
A stunundan g stununa (g hari) kadar olan hesaplamalar ak , dier stunlar butona basnca hesaplasn
A:a200 hcrelerndek verlerden lstbox a sadece dolu hcreler alir. (Bo hcreler gzkmez)
A1 1 ise b1 mart
A1 den itibaren ne kadar sayfa varsa yazar A1 den itibaren veri olan hcreye kadar seer
A1 den sra numaras verir veya aktif satr numarasn versin(klavye-fare se)
A1 devaml a2 de toplanacak
A1 e her veri giriinde b1,c1 srasyla hep yan kolona artarak yazar A1 e kullanc adn yazdrma
A1 e sadece rakam girer (yaz girince 0 yapar) ve devaml a1 de toplar A1 e tarihi gir b1 de kanc hafta olduunu bulsun
A1 e yazlan (i) harfinin 90 derece yatk olmas A1 hcre ismiyle farkl kaydetme
A1 hcresi dolu ise d1 gizle, bo ise gster A1 Hcresi Sfrdan Bykse Makro alr
A1 hcresinde saat
A1 i 1 artrma
A1,b1,c1,d1 e yaz yaz kolonlar se ve sil (bekletmeli silme) A1:a10 , c1:c10 u karlatrr girilen rakamlar farkl ise uyar verir
A1:a5 verileri ile birlikte ait olunan ay ve yl isimli yeni sayfa ekler
A1:an1000 arasindak text le bulunan satirdak dolu hcreler lstboxa atmak styorum A1:b10 hcrelerine ad tanmlar
A1:d20 hcreler arasindak arka plan reng kirmizi olan hcreler toplar
A1:d4 se b2 yi active et
A1=1, c1=3, b stunu ise gizli olsun. Sayfa2 ye a1=1, b1=3 olur
A1-a5 arasnn ilk harflerini byk harfe evirir A1'de lem Yaplrsa A2'ye Deitirilme Tarihi ve Saatini Yazar
A1'den a3000 e kadar olan hcrelerde eer herhangi bir veri varsa krmz yapar ve satr tamamen sayfa 3 'e gnder
A3 e ne yazarsan b7 de ayns
Aklama silme
Alta f8 tuu ila makro altrma Alta istediin makronu alsn Alta istediiniz makro otomatik altrma
Alta istenilen sayfay gizleme, kaydetme iptali Alta karlama ismini yaz hello .... Desin
Alta msgbox
Alta Selamlama-2
Aiklamayi kapar
Ad Soyad BasHarfe Gore Kod Olusturma Ad tanmla penceresi Ad tanimli hcrelern ayri olarak sem
Ad ve soyad karlatrarak kayt yapan kodlar Adlandrlm Bir Alana Gitmek (Goto)
A balantnzn ad
Aktif alma Kitabndan belli alma sayfalarn silme2 Aktif alma kitabnn adn aktif hcreye yazdrr
Aktif alma Kitabnn Adn Aktif Hcreye Yazdrmak Aktif alma kitabnn kaydedilmesi
Aktif alma sayfasnda kullanlan alann resmini *.jpg olarak kaydetmek isterseniz
Aktif hcre renklensin Aktif hcre veya seilen hcrelere ad tanmlar Aktif hcre veya seilen hcrelere ad tanmlar "my range2"
Aktif hcredeki metni harflere (stunlara ayrr) Aktif hcreden 7 satr aasn ve 7 satr yukarsn seer Aktif hcreden aasn seer
Aktif hcreden aaya doru sayfalara kpr atlr Aktif Hcreden Belirli Uzaklktaki Hcreye Deer Atamak
Aktif hcreden itibaren b1 deki saydan balayarak 1er say artrarak 10 say yazar toplar
Aktif hcreden itibaren istediin sayda satr ekler Aktif hcreden saa doru seer
Aktif hcreden saa, sola, yukar, aa son hcreye gitme Aktif hcreden sola doru seer Aktif hcreden yukarsn seer
Aktif Hcrenin Bulunduu Satr Renklendirmek Aktif hcrenin bulunduu satr seer Aktif hcrenin bulunduu stunu (kolonu) seer
Aktif hcrenin numerik veya yaz olduunu kontrol etme Aktif Hcrenin nndeki Deerleri J1:P1 Aralna Yazdrmak
Aktif hcreye aklama ekleme ve o aklamann yaz tipi ve puntosunu ayarlama Aktif hcreye baka sayfadaki seili alan (sadece ilk hcreyi) kopyalar
Aktif hcreye bugnn tarihini ekler Aktif hcreye alma kitabnn ve aktif sayfann adn yazdrr
Aktif hcreye ift tkla alttoplam eklesin Aktif hcreye ift tklamayla tarih ekleme
Aktif hcreye yaz A stununda veriyi bulsun ve b stundaki karln alp yazsn
Aktif hcreyi seince yaknlatrp uzaklatrma (c2 hcresi) Aktif kitabn email penceresi Aktif kolonu seer
Aktif satrdan itibaren tek tek alt satr seer Aktif satrn hepsini seer
Aktif satrn herhangi bir stununda bir satr bile dolu olsa silmez(Satrda boluklar aldrma)
Aktif satrn herhangi bir stununda bir satr bile dolu olsa silmez(Satrda boluklar aldrma) 2
Aktif sayfa ve hcreden itibaren tm sayfalarn isimlerini yazar ve sayfalara link ekler
Aktif sayfada belli hcrelere girilen saylarn bana ift sfr ekler
Aktif sayfada st bilgi "my report" yazar "a1 den alr" (14 punto)
Aktif sayfada veri girilen hcrelere veri girildii tarih ve saati aklama olarak ekler
Aktif sayfada yaz yaz tarih ve saat,dakika,saniyesi ile aklama ekler ve aklamalar siler
Aktif sayfadan modldeki makroyu altrma Aktif sayfann adn aktif hcreye yazdrr
Aktif sayfann ismi sayfa1 ise dosya kapanmasn Aktif sayfann ismini renme
Aktif sayfay kopyala ve yeni bir alma kitab a ve smini "yenisayfa" ver ve kopyalanan yaptr:
Aktif sayfay kopyalar email ile yollar Aktif sayfay uyarsz silmeve uyary eski haline getirme
Aktif Stun
Aktif Stun-II
Alarml saat
Alt klasrler
Anamenu.Xls aik delse der workbook ailmasin Anasayfa isimli sayfamzn arkasna 2 sayfa ekler Anasayfa isimli sayfann nne bir sayfa ekler
Api
Applcaton.Ontme
Ara-bul komutu
Arama ve bulma
Arkadalar textbox`a grdm yaziyi enter tuuna basarak satirbai yapiyorum. Ancak her enter`dan sonra gryorum k hcre ersnde [] kare olu
Aa yukar kaydrma
Aadan yukar doru teker teker sildirme Aaidak lnkte yer alan panzehr sml proseduru br module yerletrp, alitir.
Autofill
Ay bulma fonksiyonu
Aylar sayfa olarak ekler ayn gnlerini de yazar ve aktif ay ve gne gider
Ayn anda 2 tane form Ayn alma kitabnda "Kedi5" adl sayfadan nce sayfann kopyasn alr
Ayn satr iinde bulunan hem "ali" hemde "veli" olanlar saymak
Ayn satr iinde bulunan hem "ali" hemde "veli" olanlar saymak2 Ayn sayfa ile alma
B deki sayfalara aktif sayfadaki verileri aktarr B kolonunda 2.Satr ve 21.Satrlar arasna tklaynca form a
Bask nizlemeyi kapatnca userforma dnme Bask ve Bask nizleme Basknizlemeyi kapatnca userforma dnme 2
Baka alima ktabindak userformu amak Baka kitaptaki bir sayfadan hcreyi silme
Balat atrma
Balksz Form
Balksz userform
Balksz userform
Bekletme komutu
Bekletmeli mesaj
Belirtilen ay bittiinde yeni aya gemeden nce, aadaki eski aya ait sayfalar otomatik olarak silecek bir makro
Belli Stunlarda alrken Uyar Vermek Belli tarihlerde uyar mesaj alma
Bilgisayar ismi
Bilgisayarnzdaki src isimlerini renmek iin Bir Alan Kopyalamak seili alan (sadece ilk hcreyi) aktif hcreye kopyalar
Bir dizin altna sanki bir klasr oluturuyormuuz gibi bir dizin oluturuyorma
Bir klasr veya bir dizin ile alt dizinlerindeki dosyalar listelemek
Bir Prosedr Komut Butonundaki Klik Olay ile Yrtme Srecindeki Bir Forma Katmak
Birden fazla isimlileri harcamalaryla birlikte tek isim altnda toplatma Birden fazla sayfa ile almak iin sayfalar bir dizi eklinde belirtilebilir
Bo alan gsterme
Bo satr ekleme
Bo satr silme
Bo satr silme2
Bo satrlar gizlemek
Bo Satrlar Gizlemek
Bo satrlar silme
Bo Satrlar Silmek
Bo satirlari slmek
Bo Stunlar Gizlemek
Boluk aldrma
Boluklar aldrma
Bu ayn gnlerini saa doru yazma, alt hcreye gnn yazma ve haftasonlarn renklendirme Bugn yln kanc haftas (formlle)
Bul makrosu
Bul makrosu
Bul ve lstele
Bul ve renklendir
Bul-deitir-sil-kaydet makrosu
Bulma Deitirme
Bul-renklendir(hcre aralkl)
Bul-sil-deitir-kaydet kodlar
Bul-sil-deitir-kaydet kodlar2
Buton ekle-kaldr
Buton resimleri
Butonlarn gizlenmesi
C klasrnde .Ini dosyas oluturur, aktif ve ak excel dosya saysn iine yazar
C10 100 ise mesaj ver C5 le c15 arasindak bo hcreler saymak ve d1 e yazdirmak styorum C5:c20 arasndaki sra numaralar arasndaki boluklar alr
Calsma sayfasnn yedegn alma Can't find project or library hatas iin
Cd ap kapatma
Cd ama kapama
Cd ama kapama 2
Checkbox u iaretlettirme
Chr ne demektir
Combobox kullanm
ComboBox vlookup
Comboboxa el ile veri girii yasak 1 Comboboxa el ile veri girii yasak 2
Comboboxta ay yl
Comboboxta siralama
Comboboxtaki sraya gre sayfadan seme 'veriler A stununda Comboboxtaki veriyi mesaj olarak versin
Commandbar ekleme
alma Kitab Ak m?
alma Kitabn Kapatma Alma kitabn kaydet alma Kitabn Kaydetmek Alma kitabn paylatr penceresi alma Kitabn Postalamak (e-mail)
Alma kitabn uyarsz kapatma alma Kitabnn Bir Sayfasndaki Bir Hcreye Deer Atamak
alma kitabnn sayfalarn kitap olarak kaydetme alma kitabnn tmn yazdrma alma Kitabnn ve Sayfann Ad
alma kitabnn yedeini alp kaydeder (bulunulan dizine)--- bana yedek yazar
Alima ktabi freleme Alima ktabimi ,sayfam nde yer alan br butonla kapamak
Alima ktabinda sheet1 sml sayfa modulunun name zelln mysh olarak detrr
Ift tklamayla aktif sayfa harici sayfalar gizleyip gsterme Ift tklamayla aktif sayfaya koruma koyma Ift tklamayla hcreye saat ve tarihli aklama ekleme
Ift_kaytlari_arala
K makrosu
K yordam
Ft kayit engelleme.
Znrlk bulma
Znrlk bulma2
znrlk bulma3
znrlk bulma4
Znrlk renme
D2 hcresinde veri dorulamal alr liste olsun alr listenin otomatik genilemesi daralmas
Dataform ama
Decimal kontrol
Deiik kopyalama
Demo yapmak
Dger ktaptak makroyu alitirmak Dier alma kitabndaki modlden makro altrma
Dikdrtgen silme
Disket etiketlendirme
Disket formatlama
Disket formatlama2
Diskete yedekleme
Dolayl makro
Dolayl makro
Dosya Ad
Dosya al
Dosya arama
Dosya arama 2
Dosya isimleri
Dosya isimleri
Dosya listeleme
Dosya says
Dosya says
Dosya tama
Dosya Var m?
Dosya yedekleme
Dosya, grnm, dzen mensn gizle gster Dosya, men ubuunu gizle
Dosyalar Silmek
Dosyamz silme
Dosyay Gnn Tarihi ile Kaydetmek (varsa farkl kaydeder) Dosyay Hardiskin C:\ Blmne Farkl Adla Kaydetmek
Dosyay kapama
Dosyay kim at
Dosyayi km ati
Dng
Drtgen veya resim silme Dtpicker le gncel tarih Dtpicker tarih deerini hcreye alma
Deyara makro rnei Dzen seenekleri penceresi E1:E15 Hcrelerinin Toplamn A1'e Yazmak E1:e15 'i toplayp a1'e yazar
Eer a1 hcresi 1 ise mesaj kutusu alsn ve excelpazar yazsn Eer a1 hcresi sfrdan bykse macro alsn Eer a1 hcresinde ilem yaplrsa a2 hcresine deitirilme tarihi ve saatini yazar
Eer aktif hcre deeri 1 den byk ise aktif hcrenin altna bo satr ekler
Eer aktif hcre numerik ise ve 500 den bykse kaln yapar
Eer aktif hcrede deer varsa onu a17'ye yazar Eer forml 7 tane ve daha fazlas
Eer klasr yoksa klasr oluturmak yoksa iini boaltp silmek ve yeniden oluturma
Eer klasr yoksa klasr oluturmak yoksa iini boaltp silmek ve yeniden oluturma2
Eer sayfa bo ise alt bilgiye tarihi ekler deilse ekleyer ve yazdrr
Eliptik Form
En alttak bo hcre
En son aktf hcrenin bulunduu stunu syler En son aktif hcreye gider
En son dolu hcrenin bulunduu kolon numarasn verir En son girilen verinin satr numarasn syler (a stununda)
E zamanli olmayan verler otomatk slen kod Etiket aralklar ekleme penceresi Etkin ilem sayfasnn geniliini belirle Etkinletir penceresi
Excel crack
Excel fontlar
Excel fontlar 2
Excel Logosunu Baka Icon ile Deitirmek Excel multiuser ( oklu kullanac ) amak
Excel yardmcsna mesaj yazdrma Excel'de "veya" Excelde brletrlm hcreler makro le ayirma
Excelde herhang br hcrenn ndeyken sa klk yaptiimda "yazdir" komutu iksin styorum
Exceli kapatma ilemi Exceli simge durumuna getirin Excel tamamen kapatma Excel tamamen kapatmak
Excel-outlook
Faz hesabi
Fontu Kaln, talic ve Alt izili Yapmak Fontun Bykln ve Adn Deitirmek
Form airir
Form penceres
Formu kapar
Formun Kapat Butonuna Tklaynca Mesaj Kutusuyla Uyar Verir Formun Kapat Butonunu Pasif Yapmak (arpya Basnca Kapanmaz)
Forml evirici
Forml oaltma
Forml oaltma
Forml oaltma
Forml oaltma dolu satra gre Forml oaltma dolu satra gre (formlle) Forml ubuunu kaldrma
Formle Kesin Bavuru areti ($) Koymak Formlle ba harfi byk kk renme
Formllerin gizlenmesi
Geici klasrler
Grlen ver rakam diinda br ey olursa kullaniciyi uyararak tekrar rakam stesn
Greceli Toplama
Gz Krpan Hcre
Gncelletirme el ile
Gncelletirme otomatik
Hangi butona basldn bildirir (commandbutton) Hangi hcreye gitmek istiyorsan gider scroll yaparak Hangi hcreye yazarsan yaz a1 kaydetsin
Hareketsiz inputbox
Hareketsiz userform
Harf deiimi
Hatrlatma Program
Herhang br form zerndek metn kutusuna grlecek karakter sayisini nasil sinirlandirablrm
Herhangi bir hcreye tklaynca o hcreden saa doru kayarak o aydaki gnlerin numaralarn yazar ve haftasonlarn renklendirir
Herhangi bir hcreye tklaynca o hcreden saa doru kayarak o aydaki gnlerin numaralarn yazma Herhangi bir tarihten sonraki ilk pazartesiyi bulma
Hesaplama seenekleri penceresi Hesaplama seenekleri penceresi Hizalama penceresi Hoparlrden beep sesi karmak Htm uzantl dosyay ama
Hcre a1 deki yaz boyutu ve karekterini sadece yazcya gnderirken arial-italik ve 14 punto yapar
Hcre Aklamalarnn Font Boyutunu Deitirmek Hcre alan kesme, seili alan kesme Hcre alan seme
Hcre ismi ile tarihli ve tarihsiz kitap kaydetme Hcre kopyalama Hcre kopyalama Hcre koruma penceresi
Hcre seme,tanmlama
Hcre Semek
Hcrede saat
Hcrede yazl sayfa var m yok mu bulur Hcredeki aklamay textbox'a alma
Hcredeki deeri birer artrarak yazdrma Hcredeki deerlerin yaz tipi, fontu kalnlk
Hcredeki Saylar Ayran Fonksiyon (Saym) Hcredeki saynn son rakamn 0 (sfr) yapar
Hcredeki sayy alt veya st karaktere ve normale evirir. H2o, co2 Hcredeki sayy bir st binlie tamamlar
Hcredeki veri mesaj kutusunda 2 Hcredeki verinin dier sayfada altbilgi olarak gzkmesi
Hcrelerde font, renk yaz tipi deitirme Hcrelerde yuvarlama forml 1 Hcrelerde yuvarlama forml 2 Hcrelerde yuvarlama forml 3
Hcrenin bulunduu satr ve stunu sra ile mesajla bildirme Hcrenin ktsn alma
Hcrenin deerlerine gre hcreler renklerle dolar Hcrenin Dolgu ve Font Rengini Deitirmek
Hcrenin ii krmz ,yazlar ise beyaz renkte olsun.Ve italk ve bold olsun
Hcrenin zemin renginin saysal kodu Hcresi belli aktif kolonu seer
Hcresi belli aktif satr seer Hcresi belli aktif satr seer
Hcreye deer yaznca toplama, baka hcreye yazma Hcreye forml atama
Hcreye forml girme, kitaba link Hcreye forml girmek Hcreye Forml Yazdrmak
Hcreye gelindiinde makro altr Hcreye grdm sayiya gre ekln ennn byyp klmesn styorum.
Hcreye silinecek veri araln yaz silsin (sayfa1de a2,b2ye yaz,sayfa1 ve sayfa2den siler)
Hcreye tklaynca otomatik olarak stunun istenilen genilikte almas 2 Hcreye tklaynca userform alsn
Hcreyi gster virglden sonra rakam eklesin Hcreyi metin biiminde biimlendirmek:
I1:i13 hcrelerinde yazl yazl olan veriler 0'a eit deilse 0 yapar evirir
If mant
If, else
Input Box
IP numarasn bulma
Ki saat arasndaki fark dakika formatnda yazmak ki stun arasndaki fark makroyla alma
K tarh arasini sz ve
Lk satra yaztm tarihe bakarak tek bir hareket ile o aya ait alma gnlerini aaya doru dier hcrelere amak. Yani aradaki tatil gnlerini otomatik Mlecn bo hcrey atlamasi
Mle textbox4'te iken textbox6'ya veya textbox7'ye tklansa bile imle textbox5'e gider
Nputbox'la bulma
Stenilen sayfa isminden bakasn eklemez Stenilen sayfadaki istenilen hcreye gitme stenilen sayfalar haricinde gizleme
Lemci hz
Lemciyi uyutma
Kapali durumdak c:\test.Xls dosyasi ailacak ve ne c:\userform1.Frm lave edldkten sonra kaydedlerek kapatilacaktir
Kapan-k makrosu
Kapanta Selamlama
Kapani mesaji
Kayan label
Kayit engeleneblr m?
Kdv hesaplatma
Kelime lemek
Kelime Saymak
Kitab ama-kopyalama-kapama
Kitab yedekleme
Kitap ismi ile klasr oluturur her sayfay ayr ayr olarak kaydet Kitap ka kere alm
Klasr ama
Klasr alma
Klasr arama
Klasr bilgisi
Klasr oluturma
Klasr rar'lama
Klasr silme
Klasr silme
Kod yazarak showmodal durumunu ayarlamak. Kod yazarken Koda forml adres yolunu hcreden vermek
Kodlarnzn balangcnda
Kolon saysn yaz kolon adn harf olarak versin (ktf) Komutlar zelletir penceresi
Kopyala yapitir
Kopyalama ve yaptrma
Kopyala-yaptr
Kopyala-yaptr' engelleme
Kk dosya gster
Kprleri silmek iin Kritere uyanlar c stununda (c2den itibaren) bulup tm satrlar ile birlikte siler(kriter combobox)
Kurulari hesaplama
Kk Harfe evirme
Ksuratl bir parasal tutarn ytl ve ykr ksmlarn ayr hcrelere yazdrma
Label de dikey yaz Label de tarih ve saat yazdrma Label lerde ortalama alma
Label tretme
Label1 ve label2 de rakamlar var.Ben label1 ve label2 dek rakamlarin ortalamasini label3 te almak styorum Label'a istenilen sayfa ve hcreden deer almak Labelde tarih format Label'de tarih ve saat
Link koleksiyon
Lisans program
Listbox A dakileri listeler a ya gre b dekini textboxta listele command butonla sil
Listbox zellikleri
Lstbox1.Rowsource sorunu
Listbox1'de deiken
Listboxta listeleme
Listboxtaki adrese ift tklamayla gitme Listboxtaki adrese ift tklamayla gitme2
Listboxtaki hcrenin bulunduu satr ift tklamayla seer gider ve form kapanr Listboxtaki kolonun tarih format
Listboxtakilerin yeni kitaba kayd Lstbox'tan combobox'a ver almak Lstbox'tan textbox'a aktarilan deer ayni bmde ik
Makro le gzledmz sheet amak n yazacaimiz makraya fre sormasini salaya blrmyz Makro ile hcre birletirme
Makro ile tarih karma cevap gn olarak Makro istediim tarihten sonra almasn
Makro'da kenarlik ?
Makrolar Gizlemek
Makronun otomatk olarak aclmas ve calsmas Makronun sadece bulunulan dosyada almas
Makroyu makro iinden armak iin Makroyu makro iinden armak iin 2
Maskeleme kodu
Men ekleme
Men ekleme
Men Eklemek
Mesaj kutusu ile sayfa yazdrma adedi gir (sayfa bo bile olsa yazdrr)
Mesaj rnekleri
Metin Birletirme
Midi alma
Midi alma
Mini email
Modl gizleme
Modl silme
Msgbox ikaz
Mutlak Toplama
Mkemmel men ekleme, dosya mensnde yazdr, bask nizle, sayfa yaps kalr
Mkemmel sa fareye mensn siler ve yazdr, bask nizle, sayfa yapsn ekler
Mkerrer kayt
Not defterini veya dier uygulamalar ama Notepad ile txt dosyas atrma
Otomatik sz atrma
Nzleme makrosu
nizlemesiz yazdrma
rnek Dosyasnda sonradan oluturlan dosyalar siler2 Zel altbilgi sayfa1 de sol alt kede kitap ismi zel gider indirimi makrosu
Para format
Pc kapatma kodlar
Performans testi
Pivot table yenileme Pivot tables veri yineleme Pivot tablo bilgilerinin gncellenmesinin ak olduunu bildirir Pivot tablo bilgilerinin gncellenmesinin kapal olduunu bildirir
Program kapar
Raporlamadak sorun
Rastgele seme
References kontrol
Renk saydrma hangi renkten ka tane var buldurma Renk seenekleri penceresi
Renkleri listeleme
Renkleri Listelemek
Resim ekmek (printscreen) Resim dialog box penceresi Resim ekleme penceresi
Saat format
Sadece Dosya Ad
Sadece yazl alandan aa doru yazdrma alan seilir, tek hcre bile olsa
Sa fareye men
Sa fareye mensne ekleme Sa klik yapinca 3 tane ok ikiyor bunu silemiyorum Sa ok yn tuu ile textbox atlama
Saniyeyi Dakikann Kesri Olarak Gstermek Satr aralndaki son dolu satr tesbiti Satr Ba (Carriage Return)
Satr Eklemek
Satr yksekliini ayarlatma Satr, stun isimleri hcreler dahil hereyi seer
Satiri temizleme
Satirlari semek
Save as
Saya
Sayfa adlarinin (sekme adi) lstelenmes Sayfa aktif olunca mesaj verme
Sayfa aktif olunca sol stbilgi olarak tarihi ekleme Sayfa aktifleince makro altrma
Sayfa alfabetik sralama gizli sayfalar da sralar Trke karakter sorunu olmaz
Sayfa alfabetik sralama gizli sayfalar da sralar Trke karakter sorunu olmaz 2
Sayfa oaltma
Sayfa ekleme
Sayfa Eklemek
Sayfa Haritas
Sayfa isimlerini byk harfe evirme Sayfa isimlerini comboboxa aktarma Sayfa isimlerini listelemek 1
Sayfa kopyalama
Sayfa kopyalama
Sayfa seimi Sayfa sekmelerinden drdnc sradaki sayfann adn "Kedi2" olarak deitirir
Sayfa sralama
Sayfa sralama
Sayfa sralama
Sayfa ifreleme
Sayfa1 a stununda sral olmayan isimleri ayn anda sayfa2 a stununda a-z ye sralar
Sayfa1 a1:a100 arasinda dolgu reng sari olan hcre varsa o satirin a:an araliini sayfa2 ye nasil kopyalariz
Sayfada renklendirilmesini istediiniz sayy msgboxa yaznz Sayfada resim (image) silme
Sayfada sabitlik
Sayfada, hcrede ift tklamayla dier sayfaya gitme Sayfada, hcrede tek tklamayla dier sayfaya gitme
Sayfadaki butonlarn zerine gitme Sayfadaki butonun almasn engeller Sayfadaki commandbuttonun baslmasn nleme
Sayfadan adres alp stun genilii ayarlama Sayfadan sayfaya geerken hangi sayfann aktif olduunu mesajla bildirir Sayfadan sayfaya gei
Sayfadan var se sayfaad n sep sayfa zernde leme devam edecek yok se eer sayfaad altinda yen alima sayfasi aacak
Sayfalar Gizlemek
Sayfalar koruma
Sayfalardaki verileri seilen tarih aralnda rapor sayfasna listeyen kodlar aadadr.
Sayfalarn index numaralar mesajla, grafik sayfas ekleme Sayfalarn men olarak listelenmesi
Sayfann adn ,footernada sayfa numarasn yazar.1Of 5 gibi Sayfann en stne gider
Sayfann kopyasn alma (adn siz belirleyin) Sayfann sa alt kesine alma kitabnn adn alt bilgi olarak yazdrr Sayfann Sa Altna Dosyann Adn Altbilgi Olarak Yazmak
Sayfay aktive edip aktif hcreye say girin Sayfay belirtmek Sayfay bir deikene atamak
Sayfay kopyalar ve dn tarihli bir sayfa oluturup bilgileri onun ierisine atar
Sayfayi gzle
Say tutma
Say yaz sonuna ",00" koysun stun geniliini ayarlasn, sola yaslasn
Say yuvarla 3
Say yuvarla 4
Saylar Yuvarlamak
Sayinin karekk
Se birletir ortala Seilen alann 2 sayfa olarak yazdrlmas Seilen alann bask nizlemesi
Seili Arala Alan Ad Vermek Seili Arala Alan Ad Vermek2 Seili Hcrelerdeki Biimleri Silmek
Sesli saat
Sral inputbox
Sral inputbox2
Sral ve hcre geniliinde textbox oluturma Srasyla, b,c,d stunlarna gre sralama yapar. Sil penceresi
Siralama alttak ayni numarayi setmde sel numaranin blglernn textboxa alinmasini styorum
Syahla yazili .. Lari iktida grnmemes n beyaz renkl olmasini styorum Sol stteki Microsoft Excel Yazsn Deitirme (balk deitirme)
Son yazilan sayfanin slnmes nde iki butonuna aaidak kodu yazin.
Splash Screen-II
Statusbarda Yaz
Stil penceresi
Sub dosyabul()
Sreli userform
Sreli userform 1
Sreli userform 2
Stunda arama
Stunu se verili hcreden itibaren sesin Stunun sonuna kadar yandaki iki stunun farkini al
Szl aktarma
effaf Form
ifre ama
T.C. Merkez Bankas Gncel Dviz Kurlarn alma Tab ile textbox ieriini seme Tab ile textbox ieriini seme 2
Tablo boaltr
Tarih ilemleri 1
Tarih ilemleri 2
Tarihe gre kitap ama makrosu (belirlenen tarih gemise kitab amaz)
Tarihi tam gir o tarihten sonraki ve o yl ierisindeki haftalar sayfa olarak eklesin
Tarihli kopya
Tarihten gn karma
Tek hcrede yer alan "ad soyad" bilgisini ayr hcrelere alma
Tersten yazdrma
Textbox da alt+enter ve rakam format / bo hucrey bul Textbox format Textbox her seldnde er slnsn Textbox her seildiinde ieriinin silinmesi
Textbox nesnesi tab tuuyla veya mausla seildiinde yani aktif olduunda renk deitirme
Textbox ta 2 karakterden fazla yaz yazlrsa dier textbox ta mesaj verir Textbox ta binlik ayrac TextBox ta Veri Giriinin Kstlanmas
Textbox ta virgul kullanmasin nokta ile giris yapsin ve noktadan once ve sonra 2 rakam girilsin.
Textbox1'e tarih, textbox2'ye ay girdiinizde sayfada bunun kesiimi olan deeri label'a yazar
Textbox2 textbox1 den bykse mesaj ver 1 Textbox2 textbox1 den bykse mesaj ver 2
Textboxa alfabetik, backspace ve spacebar a izin verir Textboxa ift tklama ile form almas
Textboxa numerik ve backspace e izin verir Textboxa rakam gir sonucu labelde gr
Textboxa sadece rakam girme-karakter snrl-bo geemez Textboxa sadece rakam ve virgl Textboxa sadece rakam ve virgl
Textboxlarda yazanlar tek textboxta alt alta birletirmek Textboxlar hcreye aktarrken arada boluk brakmak
Textboxlarn bo geilmemesi
Textboxlarn bo geilmemesi
Textboxlarla toplama Textboxlarla toplama 2 Textboxta baa 0 sfr eklemek Textboxta binlik ayrac 1 Textboxta binlik ayrac 2
Textboxt'a formatlanan sayi hcrede ayni formatta gzk Textboxta girite otomatik byk harf
Textboxta girite otomatik byk harf 4 (trke karakter sorunu iin) Textboxta kuru Textbox'ta kuru 1 Textbox'ta kuru 2
Textbox'ta metn k yana yaslama ve tab zell Textboxta ondalkl saylar toplama
Textboxta seslileri sayma Textbox'ta tam sayi rne Textboxta tarih format
Textboxta toplama Textboxta veri snrlamas (max karakter) Textboxta virglden sonra 2 haneden fazla veya eksik veri giriini engelleme
Textboxtak verye gre szme lem Textboxtaki yaznn mesaj olarak bildirilmesi Textboxtan karken msgbox
Timer rnek
Tl ve ytl
Toolbar oluturma
Toplama
Treevew Treeview a eklediimiz bir veriyi seerek bunu ift tklamayla aktif hcreye yazdr Tua aktarlr gelen kutucuktaki deeri Tua aktarilir gelen kutucuktak Tularn ascii deerleri ve vba karlklar Tularn keycode lar
Tm klasr kopyalanyor
Tm makrolarn listesi
Tm oppitobuttonlar sfrlar
Tm resimleri silmek
Tm sayfalarda a1:a5, b6:b10,c1:c5, d4:d10 hcrelerinde veri var ise 0 yapar Tm sayfalarda resim (image) silme
Tm sayfalar seme
Tm sayfalar seme 2
Tm srcleri gsterir
Userform 2) userforma alt simge durumunu kltme ve ekran kapla butonu ekleme
Userform 4) belirli bir sre ekranda bekleyen ve daha sonra kapan user form.
Userform 5) sreli userform-2 Userform 6) userformun bandaki kapat butonunu pasif yapar (arpya basnca userform kapanmaz
Userform bekletmeli al
Userform bekletmeli al 2
Userform sa altta
Userform sa stte
Userformda hareketl gf
Userform'da iskonto
Userformda saat
Userformda takvim
Userformdan hcreye
Userformdan userforma
Userformu daraltma
Userformu kilitlemek 1
Userformu kilitlemek 2
Userformu kilitlemek 3
Userform'un al saysn snrlamak (demo yapmak) Userformun bandaki kapat butonunu pasif yapar (arpya basnca userform kapanmaz)
Userformun baindak kapat butonunu pasf yapar (arpiya basinca userform kapanmaz) Userformun code blmne yapitir,textbox'lari oaltablrsn
Userformun st sadaki kapat butonunu gizler Userformun zernde 3 adet text box var ve textbox1 deermz 2. Ve 3.Nn toplmi olsun styoruz
Userform'un yer.
Userformunuza ekleyecenz br adet combobox'a aylari yazar Userformunuzdadak texbox'a yazdiiniz verler ayni anda excel alima sayfanizdak a2 hcresne yazdirilir Userformunuzu yazdrmak
Userformunuzu yazdirmak
Userformunuzun bal '+' eklinde Userformunuzun baln kodlarla istediinizi ekilde ayarlayabilirsiniz
Uyarc Form
VB kodlari ile bir excel dosyasi aciyorum fakat bu Excel dosyasindaki makroyu altrma VB kodlari ile bir excel dosyasi aciyorum fakat bu Excel dosyasindaki makroyu altrma2
Vba daki sray takip ederek sayfa isimlerini otomatik sralar Vba kodlarn grme makrosu Vba kodunu grmek iin butonla
Ver aktarma...
Veri deitirir
Ver detrr
Veri kaydrr
Ver kaydirir
Veri siler
Ver sler
Verileri kaydeder
Verler kaydeder
Wav aldrma
Wav alma
Windowsu kapatma
Wmi anakart
Wmi bilgi
Wmi bios
Wmi mouse
Wmi sistem
Wmi windows
Word de fontlar
Workbook_addininstall
Yanp snme
Ya hesaplama
Yazdirma alani bell ama sadece dolu olan hcrelern n nasil yazdirablrm. Yazdirma alani sep yazdirmak.
Yaz Efekti
Yazi anmasyonu
Yeni ara ubuu ekleme Yeni belge ama penceresi Yeni belge ama penceresi
Yeni kitap aar Yeni kitap oluturma kitabn ismiyle balayan ve birer artan kitap oluturur
Yl ekleme
Yldzl efektler
Yol Var m?
Yzde hesaplama
Zamanlamal userform 2
'Make cell range Background color, flash x times, x fast, in x color, 'when Ctrl-a is pressed. Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed 'Make this cell range background flash! Set myCell = Range("A1:M8") Application.DisplayStatusBar = True Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! " 'Make cell background flash to this color! 'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30, 'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11, 'Gray-50% 16, Gray-25% 15, Bright Cyan 8. newColor = 11 'Make the cell range flash fast: 0.01 to slow: 0.99 fSpeed = 0.2 'Make cell flash, this many times! Do Until x = 2 'Run loop! DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = xlNone Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub Worksheets("pir").Name = "pirsa" Option Explicit Sub Auto_Open() Dim sht As Worksheet For Each sht In Worksheets sht.Activate ActiveWindow.DisplayZeros = False Next sht End Sub Sub Auto_Close() Dim sht As Worksheet For Each sht In Worksheets sht.Activate ActiveWindow.DisplayZeros = True Next sht End Sub Sub BaskaBirYntem() Dim byt As Byte For byt = 1 To Worksheets.Count Worksheets(byt).Activate ActiveWindow.DisplayZeros = False Next byt End Sub Sub LeereSpalteAus() Dim i% For i = 1 To 26 If IsEmpty(Cells(Rows.Count, i).End(xlUp)) Then Columns(i).Hidden = True End If Next i End Sub
Sub SATIREKLE() For i = 2 To 8 If Cells(i, 1) <> Cells(i + 1, 1) Then Rows(i + 1).EntireRow.Insert End If Next i End Sub sizin yaptnzdan esinlenerek yle bir ey yaptm. O da sadece 1. satrla 2. satr arasna 7 tane satr ekledi. Yani dngde ilk if'in saland yere. Sub Modul_Loeschen() Dim Ini As Integer For Ini = 2 To 10 Sheets("1.pir").Copy After:=Sheets(Worksheets.Count) ActiveSheet.Name = Ini & ".pir" Next Ini With Application.VBE.ActiveVBProject .vbComponents.Remove .vbComponents("Modul1") End With End Sub Sub sec() Cells(1, 1).Select End Sub Sub birincisayfaharicsil() Application.DisplayAlerts = False While Worksheets.Count > 1 Sheets(2).Delete Wend Application.DisplayAlerts = True End Sub Sub xlVeryHidden_All_Sheets() On Error Resume Next Dim sh As Worksheet For Each sh In Worksheets sh.Visible = xlVeryHidden Next End Sub Sub FirstSheet() Sheets(1).Select End Sub ThisWorkbook a Private Sub Workbook_Open() Dim WshShell Dim intText As Integer Set WshShell = CreateObject("WScript.Shell") intText = WshShell.Popup("Diese ''MsgBox'' wird nach 10 sec geschlossen", _ 10, "''MsgBox'' fr 10 sec ()2003 KMB", vbSystemModal) End Sub Sub BenutzterBereich() Dim WsTabelle As Worksheet On Error Resume Next For Each WsTabelle In Worksheets With WsTabelle .Rows(.UsedRange.SpecialCells(xlCellTypeLastCell).Row + 1 & ":65536").EntireRow.Hidden = _ Not .Rows(.UsedRange.SpecialCells(xlCellTypeLastCell).Row + 1 & ":65536").EntireRow.Hidden .Range(.Cells(1, .UsedRange.SpecialCells(xlCellTypeLastCell).Column + 1), .Cells(65536, 256)).EntireColumn.Hidden = _ Not .Range(.Cells(1, .UsedRange.SpecialCells(xlCellTypeLastCell).Column + 1), .Cells(65536, 256)).EntireColumn.Hidden End With Next WsTabelle End Sub Sub Auto_Open() Toolbars("100 Button Faces").Visible = True Toolbars("Custom Toolfaces").Visible = True End Sub Sub Auto_Close() Toolbars("100 Button Faces").Delete Toolbars("Custom Toolfaces").Delete End Sub
Sub SAYFA_EKLE() Application.ScreenUpdating = False Say = Worksheets.Count For X = Say To Say + 14 Sheets("ANASAYFA").Select Sheets("ANASAYFA").Copy After:=Sheets(Worksheets.Count) ActiveSheet.Shapes("Button 1").Delete ActiveSheet.Name = Format(X, "0000") ActiveSheet.[AA1].Select Selection.NumberFormat = "@" With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With ActiveSheet.[AA1] = ActiveSheet.Name Next Sheets("ANASAYFA").Select Application.ScreenUpdating = True End Sub Private Sub UserForm_Initialize() ListBox1.RowSource = "A1:A" & Cells(65536, 1).End(xlUp).Row ListBox1.ListStyle = fmListStyleOption ListBox1.MultiSelect = fmMultiSelectMulti End Sub ' Private Sub CommandButton1_Click() ListBox2.Clear For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then ListBox2.AddItem ListBox1.List(i) End If Next End Sub Private Sub UserForm_Initialize() ListBox1.ColumnCount = 6 ListBox2.ColumnCount = 6 ListBox1.ListStyle = fmListStyleOption ListBox1.MultiSelect = fmMultiSelectMulti ListBox1.RowSource = "A1:F" & Cells(65536, 1).End(xlUp).Row End Sub ' Private Sub CommandButton1_Click() Dim MyArray() ListBox2.Clear For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then For j = 0 To 5 ReDim Preserve MyArray(5, xx) MyArray(j, xx) = ListBox1.List(i, j) Next xx = xx + 1 End If Next ListBox2.List() = WorksheetFunction.Transpose(MyArray) End Sub
A ve B stunu karlatrlr. B'de olup A'da olmayanlar A stunu altna eklenir. Sub ikisutunukarsilastir() Dim Cell As Range, Plage As Range, I As Long Set Plage = Range("A1", [A1].End(xlDown)) I = Plage.Count Application.ScreenUpdating = False For Each Cell In Range("B1", [B1].End(xlDown)) If Plage.Find(Cell, Plage(1), xlValues, xlWhole) _ Is Nothing Then I=I+1 Cells(I, 1) = Cell End If Next Cell End Sub Sub BosSatirEkle() Dim Line As Integer Range("A2").Select Line = 1 Recommence: Line = Line + 2 Rows(Line).Select Selection.Insert Shift:=xlDown If Line < ActiveSheet.UsedRange.Rows.Count Then GoTo Recommence End If End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal _ Target As Range, Cancel As Boolean) 'D.McRitchie, 2004-09-21, nsert more rows up ' until 15, no deletions of rows If Target.Column <> 2 Then Exit Sub If Not IsNumeric(Target) Then Exit Sub Cancel = True Dim i As Long, curv As Long, tov As Long curv = Target.Value tov = InputBox("supply new total rows", _ "Rows input", curv + 1) If tov < curv Then Exit Sub For i = curv + 1 To tov Cells(Target.Row + i - 1, 1).EntireRow.Insert Cells(Target.Row + i - 1, 3) = i Cells(Target.Row, 2) = i Next i End Sub Sub Makro1() With ActiveCell.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With ActiveCell.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With End Sub Sub auto_open() Static sayac As Integer Do If sayac = 3 Then ThisWorkbook.Close False Else If InputBox("ifreyi girin") = "1" Then GoTo devam Else sayac = sayac + 1 End If End If Loop devam: End Sub
Sub timerMsg() Dim alertTime MsgBox "The alarm will go off in 3 seconds!" alertTime = Now + TimeValue("00:00:03") Application.OnTime alertTime, "msg" End Sub Sub msg() MsgBox "Three Seconds is up!" End Sub D:\Belgelerim aldm.Siz yolu deitirebilrsiniz.Kodlar modle yaptrn.Daha sonra Butona FileList makrosunu atayn.Kod: Sub FileList() Dim FileNamesList As Variant, i As Integer FileNamesList = CreateFileList("*.xls", True) Range("A:B").ClearContents For i = 1 To UBound(FileNamesList) Cells(i + 1, 1) = FileNamesList(i) Cells(i + 1, 2) = FileSize(Dir(FileNamesList(i))) Next Columns("A:B").AutoFit End Sub Function CreateFileList(FileFilter As String, IncludeSubFolder As Boolean) As Variant Dim FileList() As String, FileCount As Long CreateFileList = "" Erase FileList With Application.FileSearch .NewSearch .LookIn = "D:\Belgelerim\" .Filename = FileFilter .SearchSubFolders = IncludeSubFolder If .Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending) = 0 Then Exit Function ReDim FileList(.FoundFiles.Count) For FileCount = 1 To .FoundFiles.Count FileList(FileCount) = .FoundFiles(FileCount) Next End With CreateFileList = FileList Erase FileList End Function Function FileSize(filespec) Dim fs, f, f1, fc Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder("D:\Belgelerim\") Set fc = f.Files For Each f1 In fc If f1.Name = filespec Then FileSize = f1.Size / 1024 & " Kb" Next End Function
Dosyalar Geldikten Sonra u makro ile Dosyalarn adlarn ayrarak stediin dosyay fonksiyonlarla Bulabilirsin..Tabi bu yntem tam istediiniz deil ama y Sub ayr() Columns("A:A").Select Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _ Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _ :="\", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)) ActiveWindow.ScrollColumn = 2 End Sub Private Sub Command1_Click() Dim say1, say2, sonu As Double say1 = Val(Text1.Text) say2 = Val(Text2.Text) If Option1 = True Then sonu = say1 + say2 If Option2 = True Then sonu = say1 - say2 If Option3 = True Then sonu = say1 * say2 If Option4 = True Then sonu = say1 / say2 Text3.Text = Str(sonu) End Sub
Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Row = 4 Then MsgBox "Akndan Selamlar" End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column = 4 Then MsgBox "Selam" '4. stunda ilem yaplrsa makro alr. If Target.Row = 4 Then MsgBox "Selam" '4. satrda ilem yaplrsa makro alr. End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column = 4 Then MsgBox "Akn'dan Selamlar" End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim c As Range Set c = Target If (c.Row >= 4 And c.Row < 120 And c.Value = "Y") Then c.Value = Cells(1, c.Column).Value End If End Sub Sub auto_open() Application.OnTime Now + TimeValue("00:05:00"), "Kayt" End Sub Sub Kayt() ActiveWorkbook.Save MsgBox "Kitap Kaydedildi" Call auto_open End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column <> 6 Then Exit Sub Select Case Target.Value Case "a" A_Makrosu Case "b" B_Makrosu Case "c" C_Makrosu End Select End GetTxtData2() Sub Sub 'Raider Dim MyFile As String MyFile = "C:\Test.txt" j=0 Set NewSh = Worksheets.Add j=j+1 NewSh.Name = "TextSheet-" & j Open MyFile For Input As #1 Do While Not EOF(1) i=i+1 Line Input #1, InputData Cells(i, 1) = InputData If i > 65535 Then Set NewSh = Worksheets.Add j=j+1 NewSh.Name = "TextSheet-" & j i=0 End If Loop Close #1 Set NewSh = Nothing End Sub Aadaki kodu sayfann kod sayfasna kopyalayn. A1 hcresine yazdnz say renk indexi olarak kabul edilmitir. visual basic kodu: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address <> "$A$1" Or IsNumeric(Target) = False Then Exit Sub Target.Interior.ColorIndex = Target End Sub
Sub aktar() Set verisayfasi = Sheets(1) Select Case Range("a1").Value Case "A" Set sayfam = Sheets(1) Case "B" Set sayfam = Sheets(2) Case "C" Set sayfam = Sheets(3) Case "D" Set sayfam = Sheets(4) End Select ensonhucre = sayfam.Range("A65000").End(xlUp).Row 'son hucreye A sutunundan baktm For i = 1 To 5 sayfam.Cells(ensonhucre, i) = verisayfasi.Cells(2, i) Next End Sub Sub bul() For a = 2 To Cells(65536, 1).End(xlUp).Row If WorksheetFunction.CountIf(Columns(1), Cells(a, 2).Value) = 0 Then e = WorksheetFunction.CountA([d2:d65536]) + 1 Cells(e + 1, 4) = Cells(a, 2).Value End If If WorksheetFunction.CountIf(Columns(2 Sub AutoCopy() Dim LookupRange As Range, cell As Range, Found As Boolean Dim DestRange As Range Set LookupSheet = Sheet2 Set DestSheet = Sheet3 n = ActiveCell.Value Set LookupRange = Intersect(LookupSheet.Columns("A"), LookupSheet.UsedRange) Set DestRange = DestSheet.Range("A65536").End(xlUp).Offset(1, 0) Found = False If n <> "" Then For Each cell In LookupRange If cell.Value = n Then delrange = cell.Address cell.EntireRow.Cut DestRange Found = True Exit For End If Next cell End If If Not Found Then msg = "The code does not exist on " & LookupSheet.Name & "." MsgBox msg, vbOKOnly, "AutoCopy" Else LookupSheet.Range(delrange).EntireRow.Delete DestSheet.Select Range("A65536").End(xlUp).EntireRow.Select End If End Sub Option Explicit
Private Sub Worksheet_Calculate() ' Target value: Const lVal As Long = 100 Dim rCell As Range ' Put the cell you want to look at here ' Cell must be a formula!! Set rCell = Range("C1") ' ================================================================= ' If the target cells value equals the specified target value, If rCell.Value = lVal Then ' then deliver a message MsgBox "Target value of " & lVal & " has been achieved", 64, "Target Met!" End If ' Explicitly clear memory Set rCell = Nothing End Sub
Private Sub Worksheet_Change(ByVal Target As Range) On Error Resume Next If Intersect(Target, [A:A]) Is Nothing Then Exit Sub If Target = "" Then Exit Sub If Target = "pir" Then Call Test End Sub Sub Test() MsgBox "Tebrikler..!", vbInformation End Sub Option Explicit Sub Leerzeilenlschen() Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete End Sub Sub AutoBreak() Set Urange = ActiveSheet.UsedRange Set ColA = Range("A:A") Set Arange = Intersect(ColA, Urange) Set Brange = Arange.Offset(1, 0).Resize(Arange.Rows.Count - 1) Cells.PageBreak = xlNone For Each cell In Brange If cell.Value <> cell.Offset(1, 0).Value Then cell.Offset(1, 0).EntireRow.PageBreak = xlPageBreakManual End If Next End Sub Sub Doppelte_lschen() Range("A:A").Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _ xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _ xlTopToBottom Range("A1").Select nr = ActiveCell zellende = Range("A" & Rows.Count).End(xlUp).Row Do ActiveCell.Offset(1, 0).Range("A1").Select If ActiveCell = nr Then Selection.EntireRow.Delete ActiveCell.Offset(-1, 0).Range("A1").Select End If nr = ActiveCell Loop Until ActiveCell = Range("A" & zellende + 1) End Sub Sub AutoBreak() Set Urange = ActiveSheet.UsedRange Set ColA = Range("A:A") Set Arange = Intersect(ColA, Urange) Set Brange = Arange.Offset(1, 0).Resize(Arange.Rows.Count - 1) Cells.PageBreak = xlNone For Each cell In Brange If cell.Value <> cell.Offset(1, 0).Value Then cell.Offset(1, 0).EntireRow.PageBreak = xlPageBreakManual End If Next Sub AutoBreak() Set Urange = ActiveSheet.UsedRange Set ColA = Range("A:A") Set Arange = Intersect(ColA, Urange) Set Brange = Arange.Offset(1, 0).Resize(Arange.Rows.Count - 1) Cells.PageBreak = xlNone For Each cell In Brange If cell.Value <> cell.Offset(1, 0).Value Then cell.Offset(1, 0).EntireRow.PageBreak = xlPageBreakManual End If Next End Sub
Sub SetzeSeiten() Dim rngBereich As Range Dim rngZelle As Range Application.ScreenUpdating = False On Error GoTo Ende Set rngBereich = Range("A1:A" & Range("A2").End(xlDown).Row) Cells.PageBreak = xlNone For Each rngZelle In rngBereich If rngZelle <> rngZelle.Offset(1, 0) Then rngZelle.Offset(1, 0).PageBreak = xlPageBreakManual Next rngZelle Ende: Application.ScreenUpdating = True End Sub Sub bossatirsil() For a = 1 To Sheets.Count sat = Sheets(a).Cells.SpecialCells(xlCellTypeLastCell).Row sut = Sheets(a).Cells.SpecialCells(xlCellTypeLastCell).Column For b = sat To 1 Step -1 If WorksheetFunction.CountA(Sheets(a).Rows(b)) = 0 Then Sheets(a).Rows(b).Delete Next For c = sut To 1 Step -1 If WorksheetFunction.CountA(Sheets(a).Columns(c)) = 0 Then Sheets(a).Columns(c).Delete Next Next End Sub Sub Leerzeilenlschen() Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete End Sub Sub bugunu_bul() Dim lr As Long Dim i As Integer lr = Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To lr If Cells(i, 1).Value = Date Then Cells(i, 1).Select End End If Next i End Sub Sub LetztenWertKopieren() Dim intCol As Integer intCol = 1 '1 steht fr Spalte A Cells(Rows.Count, intCol).End(xlUp).Copy _ Range("B1") End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) rowoffset = 0 Intersect(ActiveCell.EntireRow, Columns("A")).Value = ActiveCell.Row + rowoffset End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) rowoffset = 0 Intersect(ActiveCell.EntireRow, Columns("A")).Value = ActiveCell.Row + rowoffset End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, [A:A]) Is Nothing Then Exit Sub On Error GoTo hata If CDate(Target.Value) > Date Then MsgBox "Girdiiniz Tarih Bu Gnk Tarihten Byk..!!", vbCritical, "TARH" Target.Select End If hata: End Sub
Sub aktar() On Error Resume Next Application.DisplayAlerts = False ActiveSheet.Move before:=Sheets(1) Application.DisplayAlerts = True ActiveSheet.Copy after:=Sheets(Worksheets.Count) ActiveSheet.Shapes("Button 1").Select Selection.Cut ActiveSheet.Shapes("Button 2").Select Selection.Cut basla: If [A2] = "" Then Exit Sub Set sayfa = ActiveSheet Columns("A:D").EntireColumn.AutoFit sayfa.Name = [A2] Set sec = [A2].CurrentRegion.Columns(1).ColumnDifferences([A2]) Set sec = Intersect(sec.EntireRow, [A:D]) If sec.Address = "" Then Exit Sub Worksheets.Add after:=Sheets(Worksheets.Count) Set sonsayfa = Sheets(Worksheets.Count) sayfa.Select For Each alan In sec.Areas alan.Copy sat = sonsayfa.[a65536].End(3).Row + 1 sonsayfa.Cells(sat, 1).Insert shift:=xlDown alan.Delete shift:=xlUp Next Set sec = Nothing sonsayfa.Select GoTo basla End Sub Listeleme D2'den itibaren yaplr. Sub Test_Et() Dim UstHucre As Range, AltHucre As Range, _ KaynakHucre As Range, HedefHucre As Range Dim x As Integer, i As Integer, numofRows As Integer Set UstHucre = Range("A2") Set AltHucre = Range("A65536").End(xlUp) ' kaynak hcrenin bo olup olmadn test et. If UstHucre.Row > AltHucre.Row Then End Set KaynakHucre = Range(UstHucre, AltHucre) Set HedefHucre = Range("D2") SatirSayisi = KaynakHucre.Rows.Count x=1 For i = 1 To SatirSayisi If Application.IsNumber(KaynakHucre(i)) Then If KaynakHucre(i) > 5 Then HedefHucre(x) = KaynakHucre(i) x=x+1 End If End If Next End Sub
Sub aktar() Dim isim, deger As Variant Dim rng As Range Dim i, z As Integer i=2 z=1 Do If Cells(i, 1).Value = "" Then GoTo bitti If Range([A1], [A10000]).Find(What:=Cells(i, 1).Value, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows).Row < i Then GoTo devam2 ReDim isim(z) ReDim deger(z) isim(z) = Cells.Find(What:=Cells(i, 1).Value, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows).Value deger(z) = Cells(i, 1).Offset(0, 1).Value hcr = i Do On Error Resume Next Set rng = Range(Cells(hcr, 1), [A10000]).FindNext If rng.Row = hcr Then GoTo devam hcr = rng.Row deger(z) = deger(z) + rng.Offset(0, 1).Value Loop devam: Sheets(2).Cells(z, 1).Value = isim(z) Sheets(2).Cells(z, 2).Value = deger(z) z=z+1 devam2: i=i+1 Loop bitti: End Sub Sub Benzersiz1() Columns("A:A").Select Range("A:A").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Columns("C:C"), Unique:=True Range("C11").Select End Sub Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim i As Integer For i = 1 To 300 '1 satr ile 300. satr aras If IsEmpty(Cells(i, 1)) Then '1. Satr 1. Stun yani A1 hcresi Rows(i).Hidden = True End If Next i Application.ScreenUpdating = True End Sub Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim i As Integer For i = 1 To 300 '1 satr ile 300. satr aras If IsEmpty(Cells(i, 1)) Then '1. Satr 1. Stun yani A1 hcresi Rows(i).Hidden = True End If Next i Application.ScreenUpdating = True Sub DegiskenToplam() Range("A1").End(xlDown).Offset(1, 0).Select Satir = -(ActiveCell.Row) + 1 ActiveCell.FormulaR1C1 = "=SUM(R[" & Satir & "]C:R[-1]C)" End Sub 'Bu rnek te ayn ilemi yapar ancak deere kesin iareti ($) ekler. Sub ToplamdaDegiskenAdres() Range("A1").End(xlDown).Offset(1, 0).Value = _ "=SUM(A1:" & Range("A1").End(xlDown).Address & ")" End Sub Sub SutunToplami() Toplam = Application.Sum(Range("A1").EntireColumn) MsgBox Toplam End Sub
Aklama:A stunundaki dolu hcreleri bulur ve yazdrma alan iine alr Kod: Sub setPrintArea() Dim rng As Range Set rng = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) stcell = "A1": lcell = rng.Address ActiveSheet.PageSetup.PrintArea = stcell & ":" & lcell End Sub Sub setPrintArea() Dim rng As Range Set rng = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) stcell = "A1": lcell = rng.Address ActiveSheet.PageSetup.PrintArea = stcell & ":" & lcell End Sub Sub ZeileEinfuegen() Dim Zeile As Integer Zeile = 2 Application.ScreenUpdating = False Do Until Range("a" & Zeile).Value = "" Rows(Zeile & ":" & Zeile).Select Selection.Insert Shift:=xlDown Zeile = Zeile + 2 Loop Range("A1").Select Application.ScreenUpdating = True End Sub Private Sub UserForm_Initialize() TextBox1.Value = WorksheetFunction.Max(Range("A:A")) End Sub Sub enbuyuk() Dim intCol As Integer intCol = 1 '1 steht fr Spalte A Cells(Rows.Count, intCol).End(xlUp).Copy _ Range("B1") End aktar() Sub Sub On Error Resume Next Application.DisplayAlerts = False ActiveSheet.Move before:=Sheets(1) Application.DisplayAlerts = True ActiveSheet.Copy after:=Sheets(Worksheets.Count) ActiveSheet.Shapes("Button 1").Select Selection.Cut ActiveSheet.Shapes("Button 2").Select Selection.Cut basla: If [A2] = "" Then Exit Sub Set sayfa = ActiveSheet Columns("A:D").EntireColumn.AutoFit sayfa.Name = [A2] Set sec = [A2].CurrentRegion.Columns(1).ColumnDifferences([A2]) Set sec = Intersect(sec.EntireRow, [A:D]) If sec.Address = "" Then Exit Sub Worksheets.Add after:=Sheets(Worksheets.Count) Set sonsayfa = Sheets(Worksheets.Count) sayfa.Select For Each alan In sec.Areas alan.Copy sat = sonsayfa.[a65536].End(3).Row + 1 sonsayfa.Cells(sat, 1).Insert shift:=xlDown alan.Delete shift:=xlUp Next Set sec = Nothing sonsayfa.Select GoTo basla End Sub
Sub ekle1yazC() Dim MaValeur, compteur For compteur = 1 To 15 Range("A" & compteur).Select MaValeur = ActiveCell.Value Range("C" & compteur).Select ActiveCell.Value = MaValeur + 1 Next End Sub Private Sub ComboBox1_Change() Dim I As Long For I = 1 To 3 Me.Controls("TextBox" & I) = Range("A" & ComboBox1.ListIndex + 1).Offset(, I) Next I End Sub Sub topla100yazB() Dim MaValeur, nbcell For nbcell = 1 To 10 Range("A" & nbcell).Select MaValeur = ActiveCell.Value Range("B" & nbcell).Select ActiveCell.Value = MaValeur + 100 Next End Sub Sub benzersiz() Columns("A:A").Select Range("A:A").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Columns("C:C"), Unique:=True Range("C11").Select End Sub Sub sz() On Error Resume Next Sayfa1.Range("a1:a1500").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sayfa1.Range( _ "h1"), Unique:=True End Sub WorksheetFunction.CountA(Columns("A")) Sub Auto_Open() Application.Calculation = xlCalculationManual 'hesaplamay el ile yapar Application.OnKey "{F9}", "sec_hesapla" 'F9 tuuna basnca sec_hesapla makrosunu altrr End Sub Sub Auto_Close() Application.Calculation = xlCalculationAutomatic 'kta otomatik hesaplama yapar. End Sub Sub sec_hesapla() Dim sec 'sec sabiti sec = Range("A1:A9").Select 'sec sabitinin aral tanmlanr ve seilir (A1:A9 arasnda formllerin olduunu varsayorum) Selection.Calculate 'seili olan aralk F9 tuuna baslnca hesaplanr End Sub Sub ZeilenFrben() Dim Zeile As Range, ZeilenNr As Integer For Each Zeile In Selection.Columns ZeilenNr = ZeilenNr + 1 If ZeilenNr Mod 2 = 0 Then Zeile.Interior.ColorIndex = 6 Else Zeile.Interior.ColorIndex = xlAutomatic End If Zeile.Borders.Weight = xlThin Next End Sub Dim say As Integer Dim i As Integer say = WorksheetFunction.CountA(Range("A2:A65000")) For i = 1 To say Cells(i + 1, 1) = i Next i Sub sirala() For x = 2 To [b65536].End(3).Row Cells(x, 1).Value = x - 1 Next End Sub
For C = [c65536].End(3).Row To 1 Step -1 If Cells(C, "c")=cells(C,"a") Then Rows(C).Delete Next Sub abtoplaCyaz() Dim i As Integer On Error GoTo 10 For i = 1 To 50 If Cells(i, 1).Value <> Empty And Cells(i, 2).Value <> Empty And _ IsNumeric(Cells(i, 1).Value) And IsNumeric(Cells(i, 2).Value) Then Cells(i, 3).FormulaR1C1 = WorksheetFunction.Sum(Val(Cells(i, 1).Value) + Val(Cells(i, 2).Value)) Else 10 MsgBox "Geersiz deer bulundu, ltfen kontrol ediniz ", vbExclamation, "H A T A !!! " Exit Sub End If Next i End Sub Dim bul As String Private Sub CommandButton1_Click() On Error GoTo 10 bul = InputBox("LTFEN ARANACAK UBE KODUNU YADA SMN GRNZ!!!!!!") bassat = Range("A4:C65536").Find(bul).Row For a = bassat To 65536 sonsat = Range("A" & a, "C65536").Find(bul).Row Next a 10 If sonsat = 0 Then MsgBox ("ARADIINIZ VER BULUNAMADI") Exit Sub End If Range("A" & bassat, "C" & sonsat).Select End Sub Private Sub Worksheet_Change(ByVal Target As Range) Dim Bul As Range, ilkadres, i Application.ScreenUpdating = False If Target.Address = "$H$1" Then Sayfa1.[I1:I65536].ClearContents Set Bul = Sayfa1.[A:A].Find(Target, LookAt:=xlWhole) If Not Bul Is Nothing Then ilkadres = Bul.Address i=1 Do i=i+1 Target(i - 1, 2) = Bul(1, 4) Set Bul = Sayfa1.[A:A].FindNext(Bul) Loop Until ilkadres = Bul.Address End If End If End Sub AIKLAMA: A:A stunundaki dolu satrlarn altna bo satr ekler Kod: Sub ZeileEinfuegen() Dim Zeile As Integer Zeile = 2 Application.ScreenUpdating = False Do Until Range("a" & Zeile).Value = "" Rows(Zeile & ":" & Zeile).Select Selection.Insert Shift:=xlDown Zeile = Zeile + 2 Loop Range("A1").Select Application.ScreenUpdating = True End Sub
Private Sub UserForm_Initialize() Dim myrange As Range Dim myrange As Range Set myrange = Range("A1:A200") For Each c In myrange If c.Value = ListBox1.Value Then TextBox1.Value = ListBox1.Value & c.Value.Offset(1, 0).Value End If Next End Sub Private Sub UserForm_Initialize() Dim myrange As Range Dim myrange As Range Set myrange = Range("A1:A200") For Each c In myrange If c.Value = ListBox1.Value Then TextBox1.Value = ListBox1.Value & c.Value.Offset(1, 0).Value End If Next End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If [a1].Value = 0 Then Rows("10:20").EntireRow.Hidden = True Else Rows("10:20").EntireRow.Hidden = False End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If [a1].Value = 0 Then Rows("10:20").EntireRow.Hidden = True Else Rows("10:20").EntireRow.Hidden = False End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If [a1].Value = 0 Then Rows("10:20").EntireRow.Hidden = True Else Rows("10:20").EntireRow.Hidden = False End If End Sub sayfann kod ksmna Private Sub Worksheet_Change(ByVal Target As Range) If Range("a1") = 1 Then Range("b1") = "Mart" End If End Sub Sub testNbCaractere() CellTest = Range("a1").Value If Len(CellTest) > 10 Then MsgBox "Pas plus de 10 caractres", vbOKOnly, "Erreur de caractres" Exit Sub End If End Sub
Sub Zeichen_auslesen() Range("B1").Select ActiveCell.FormulaR1C1 = "=CHAR(ROW(RC))" Range("A1").Select ActiveCell.FormulaR1C1 = "=CODE(RC[1])" Range("A1:B1").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .ShrinkToFit = False .MergeCells = False End With With Selection.Font .Name = "Arial" .Size = 12 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With Selection.Font.Bold = True Selection.AutoFill Destination:=Range("A1:B255"), Type:=xlFillDefault Range("A1").Select End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$A$1" And IsEmpty(Target) = True Then Target = "10" End Sub Sayfa1'de A1 hcresinde "Sayfa2" yazsn. Aadaki kodu kullann. Worksheets(Range("A1").Value).Select Eer Value'yu eklemezseniz kod almayabilir. Value yerine Text' de yazabilirsiniz. Eer bu kodu baka sayfadan altracaksanz yani Sayfa1'de deilken altracaksanz aadaki kodu kullanmalsnz. Worksheets(Worksheets("Sayfa1").Range("A1").Text).Select Byle durumlarda genelde kodun ksa ve anlalabilir olmas iin sayfalara set atamasn yapmanz tavsiye ederim. Sub SayfaAc() Set s1 = Worksheets("Sayfa1") Worksheets(s1.Range("A1").Text).Select End Sub Range("A1").AutoFilter Field:=1, Criteria1:=">2", Operator:=xlAnd, Criteria2:="<8" Sub SelonCas() Nombre = ActiveCell.Value Select Case Nombre Case 1 To 5 Range("A1").Value = 0 Case 6, 7, 8, 9, 10 Range("A1").Value = 1 Case Else Range("A1").Value = 1000 End Select End Sub Sub SplitOrnegi() Dim Hucre As Range Dim SaydirilanKarakterDegeri As String SaydirilanKarakterDegeri = [A1].Value For Each Hucre In Range("B1:B100") HucredekileriSay = UBound(Split(Hucre, SaydirilanKarakterDegeri)) SaydiklariniTopla = SaydiklariniTopla + HucredekileriSay Next Hucre MsgBox "lem Yaptnz Alanda Toplam " & SaydiklariniTopla & " Adet " & SaydirilanKarakterDegeri & " Var." End Sub
Sub Excel_Serienmail_via_Outlook_Senden() Dim OutApp As Object, Mail As Object Dim i As Integer Dim Nachricht For i = 1 To 10 'Variablen mssen bei jeder Schleife neu initalisiert werden Set OutApp = CreateObject("Outlook.Application") Set Nachricht = OutApp.CreateItem(0) With Nachricht .To = Cells(i, 1)'Adresse .Subject = Cells(i, 2) 'Betreffzeile .Body = Cells(i, 3) 'Sendetext 'Hier wird die Mail gleich in den Postausgang gelegt 'und die Sicherheitsabfrage muss jedesmall besttigt werden '.Send 'Hier wird die Mail "angezeigt" 'aber gleich versendet,... OHNE Sicherheitsabrage .Display SendKeys "%s",True End With 'Variablen zurcksetzen sonst geht es nicht Set OutApp = Nothing 'CreateObject("Outlook.Application") Set Nachricht = Nothing 'OutApp.CreateItem(0) Application.Wait (Now + TimeValue("0:00:05")) Next i End Sub =A1 yaz A1 deki forml yazsn Function formul_al(hucre) If Left(hucre.Formula, 1) = "=" Then _ formul_al = Right(hucre.Formula, Len(hucre.Formula) - 1) Else _ formul_al = "" End Function Sub Speichern() test = Application.GetSaveAsFilename([a1]) If test = False Then Exit Sub ActiveWorkbook.SaveAs test End Sub Sub Test2() If Not Sheets("Sayfa1").Range("A1") = Empty Then For i = 1 To Worksheets.Count If Sheets(i).Name = Sheets("Sayfa1").Range("A1") Then MsgBox "Bu isimli bir sayfa mevcut..... !" Exit Sub End If Next Set NewSh = Worksheets.Add(After:=Sheets(Sheets.Count)) NewSh.Name = Sheets("Sayfa1").Range("A1") End If Set NewSh = Nothing End Sub Sub Test() Set NewSh = Worksheets.Add(After:=Sheets(Sheets.Count)) NewSh.Name = Sheets("Sayfa1").Range("A1") Set NewSh = Nothing End Sub
Sub List_Alphab() Dim i As Integer, j As Integer Dim Entree As String Dim Cel As Range Set Cel = Range("A1") 'Pour chaque enregistrement For i = 0 To Cel.End(xlDown).Row - 1 'Rcupre la valeur Entree = Cel.Offset(i) With UserForm1 'Pour chaque valeur de la listBox For j = 0 To .ListBox1.ListCount - 1 'Si la valeur de la listbox est > la valeur entrer 'on rcupre l'index j et on sort de la boucle If .ListBox1.List(j) > Entree Then Exit For End If Next j 'ajout de la valeur son emplacement spcifi par l'index j .ListBox1.AddItem Entree, j End With Next i UserForm1.Show End Sub Sub Cons_Voy() Dim i As Integer Dim Chaine As String Dim Caract As String * 1 Dim Conson As String, Voyel As String Chaine = Range("A1") For i = 1 To Len(Chaine) Caract = Mid(Chaine, i, 1) Select Case LCase(Caract) Case "a", "e", "i", "o", "u", "y" Voyel = Voyel & Caract Case Else Conson = Conson + Caract End Select Next i Range("A2") = Conson Range("A3") = Voyel End Sub Sub Blattname() i=1 For Each Blatt In Sheets Range("A" & i) = Blatt.Name i=i+1 Next End Sub Sub SelectActiveArea() Range(Range("A1"), ActiveCell.SpecialCells(xlLastCell)).Select End Sub Sub ValMaxi() Dim i As Integer i=1 Do While Range("A1").Offset(i) <> "" Rows(i + 1).Insert i=i+2 Loop End Sub Sub Test2() If Not Sheets("Sayfa1").Range("A1") = Empty Then For i = 1 To Worksheets.Count If Sheets(i).Name = Sheets("Sayfa1").Range("A1") Then MsgBox "Bu isimli bir sayfa mevcut..... !" Exit Sub End If Next Set NewSh = Worksheets.Add(After:=Sheets(Sheets.Count)) NewSh.Name = Sheets("Sayfa1").Range("A1") End If Set NewSh = Nothing End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) rowoffset = 0 Intersect(ActiveCell.EntireRow, Columns("A")).Value = ActiveCell.Row + rowoffset End Sub Private Sub Worksheet_Change(ByVal Target As Range) Static kod If Target.Address = "$A$1" Then Range("A2").Value = kod + Target End If kod = Target.Value End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("a1")) Is Nothing Then "MAKROCODE" End If End Sub Sub RecupValeur() Dim Val1 'Dim Resultat As Integer (pour un rsultat en entier) Val1 = Sheets("Feuil1").[a1].Value Resultat = Val1 * 10 Sheets("Feuil1").[a2].Value = (Resultat) MsgBox "Opration effectue." & Chr(13) & Chr(13) _ & "Rsultat :" & CStr(Resultat) End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$A$1" Then Set actcell = [C1] Do While actcell <> "" Set actcell = actcell.Offset(0, 1) Loop actcell.Value = Target.Value End If End Sub Sub Username() Range("A1").Value = Environ("USERNAME") End Sub Sub HyperlinkEmail() Range("A1").Select ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="mailto:mahmut_bayram38@hotmail.com" End Sub Sub HyperlinkAktive() Range("A1").Select Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True End Sub Sub Vorschlagwert_in_InputBox() Dim vorschlag As String vorschlag = InputBox("Geben Sie bitte einen Namen ein", "Name", Range("A1").Value) If vorschlag = "" Then Exit Sub Range("A1").Value = vorschlag End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double With Target If .Address(False, False) = "A1" Then If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End If End With End Sub B1 e aadaki forml gir =NSAT((A1-HAFTANINGN(A1;2)-TARH(YIL(A1+4-HAFTANINGN(A1;2));1;-10))/7)
Private Sub Worksheet_Change(ByVal Target As Excel.Range) Application.EnableEvents = False If Target.AddressLocal = "$A$1" Then Target = Target / 100 End If Application.EnableEvents = True End Sub Private Sub Worksheet_Change(ByVal Target As Range) If (Target = Range("A1")) Then Worksheets("Tabelle1").PageSetup.LeftHeader = Range("A1") End If End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) With Target If .Address(False, False) = "A1" Then If IsNumeric(.Value) Then Application.EnableEvents = False Range("B1").Value = Range("B1").Value + .Value Application.EnableEvents = True End If End If End With End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Not Application.Intersect(Target, Range("A1")) Is Nothing Then Target.Orientation = 0 If Target = "I" Then Target.Orientation = 90 End If End If End Sub Sub saveas() ActiveWorkbook.SaveAs Filename:="C:\" & ActiveSheet.Range("A1") End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If Sheets("Sayfa1").Range("A1") = "" Then MsgBox ("Kaydetme ilemi devam edemiyor!" & vbNewLine & _ "A1 hcresini bo brakamazsnz."), , "pir" Cancel = True End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Columns("A:A") <> "" Then Columns("D:D").EntireColumn.Hidden = True Else Columns("D:D").EntireColumn.Hidden = False End If End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Range("A1") >= 1 Then MsgBox "Selam" End Sub Dim stopit As Boolean 'on top of module! Sub startclock() 'assign start button stopit = False clock End Sub Sub clock() If stopit = True Then Exit Sub ActiveWorkbook.Worksheets(1).Cells(1, 1).Value = _ Format(Now, "hh:mm:ss") Application.OnTime (Now + TimeSerial(0, 0, 1)), "clock" End Sub Sub stopclock() 'assign stop button stopit = True End Sub
Sub muzik_cal() If Range("A1").Value > 5 Then ExecuteExcel4Macro ("SOUND.PLAY(, ""C:\Windows\Media\Tada.wav"")") End If End Sub Sub Enreg_Fichier() Dim NomFichier As String NomFichier = Range("A1") ActiveWorkbook.SaveAs "c:\excel\" & NomFichier End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$A$1" And Target.Value = 1 Then Dim sayfa As Worksheet Dim nek As String Dim sonek As Integer Set Sayfam = Worksheets.Add nek = "Sayfam" SonEkim = 1 On Error Resume Next Sayfam.Name = nek & sonek If Err.Number <> 0 Then nek = sonek + 1 Sayfam.Name = nek & sonek End If End If End Sub Application.Sheets("Sayfa Ad").ScrollArea = "A1" Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not IsNumeric(Range("A1")) Or Range("A1") = "" Then Range("A1").ClearContents Range("A1").Select MsgBox "Sie mssen Zelle A1 numerisch fllen !" End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address <> "$A$1" Then Exit Sub If UCase(Range("A1")) = UCase("x") Then Call ersteFarbe Else Call Ende End If End Sub 'thisworkbooka Private Sub Workbook_BeforeClose(Cancel As Boolean) Call Ende End Sub 'modle Public ET As Variant Sub ersteFarbe() ThisWorkbook.Worksheets("Tabelle1").Range("A1").Interior.ColorIndex = 36 ET = Now + TimeValue("00:00:01") Application.OnTime ET, "zweiteFarbe" End Sub Sub zweiteFarbe() ThisWorkbook.Worksheets("Tabelle1").Range("A1").Interior.ColorIndex = 37 ET = Now + TimeValue("00:00:01") Application.OnTime ET, "ersteFarbe" End Sub Sub Ende() On Error Resume Next Application.OnTime EarliestTime:=ET, Procedure:="ErsteFarbe", Schedule:=False Application.OnTime EarliestTime:=ET, Procedure:="zweiteFarbe", Schedule:=False ET = "" Range("A1").Interior.ColorIndex = xlNone End Sub
Sayn imdatsaral sorularnz sorarken uygulama rneinizi aynen verin.Tamam kelimesinden baka anlam ,Kod: MsgBox "Sipari Tarihini Giriniz..."
kodundan baka anlam karyoruz.Burda rahat olun ekinecek birey yok.Amacmz,amacnzdr.renmek,retmek..Bakn.Ben size yle bir rnek ha Sipari Tarihini girerek kullanc TextBox1'e:CommandButtona u kodlar yazn.Kod: Private Sub CommandButton1_Click() Range("A1").Select ActiveCell.Formula = TextBox2 End Sub Dosyay yollyorum..Hereyin bir ilk var dimi.. Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$A$1" Or Target.Address = "$A$3" Then If Range("A1").Value < Range("A3").Value Then Macro1 End If End If End Sub Sub Macro1() MsgBox "Selam" End Sub Sub Count() mycount = Range("a1") + 1 Range("a1") = mycount End Sub Sub Workbook_Open() With Worksheets(1).Range("A1") .Value = .Value + 1 End With End Sub Sub FeuilViaLst() Dim Mycell As Range, Mysheet As Worksheet, MyName$ For Each Mycell In Selection 'liste de noms MyName = Mycell.Value If MyName <> "" Then On Error Resume Next Set Mysheet = Sheets(MyName) On Error GoTo 0 If Mysheet Is Nothing Then Sheets.Add.Name = MyName End If Next Mycell End Sub Sub ListeFeuilles() Application.ScreenUpdating = False Application.DisplayAlerts = False Set ArrFeuil = Sheets("Sayfa1") ArrFeuil.Cells(1, 1).Value = "Tableau des feuilles" For i = 2 To ActiveWorkbook.Sheets.Count ArrFeuil.Cells(i, 1).Value = Sheets(i).Name Next i Application.DisplayAlerts = True Alerte = True Application.ScreenUpdating = True End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) For a = [a65536].End(3).Row To 1 Step -1 If WorksheetFunction.CountIf(Range("a1:a" & a), Cells(a, "a")) > 1 Then Rows(a).ClearContents Next End Sub Sub birlestir() For a=1 To cells(65536,1).end(xlup).row cells(a,3)=cells(a,1) & " " & cells(a,2) Next End Sub
Private Sub Worksheet_Change(ByVal Target As Range) If Target <> [A1] Then Exit Sub If [A1] = "" Then Exit Sub Range("D1:D65536").Font.Bold = False With Worksheets(1).Range("D1:D65536") Set c = .Find([A1].Value, LookIn:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do c.Font.Bold = True Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> firstAddress End If End With End Sub Private Sub Worksheet_Change(ByVal Target As Range) Dim aranan Dim uzunluk Dim basla If Target <> [A1] Then Exit Sub If [A1] = "" Then Exit Sub Range("D1:D65536").Font.Color = vbBlack uzunluk = Len(Range("A1")) For Each aranan In Range("D1:D1000") If aranan Like "*" & [A1].Value & "*" Then basla = InStr(1, aranan, Range("A1")) aranan.Characters(Start:=basla, Length:=uzunluk).Font.ColorIndex = 3 End If Next End Sub Private Sub Worksheet_Calculate() If Range("A1").Value < Range("A3").Value Then Call Macro1 End If End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$A$1" Or Target.Address = "$A$3" Then If Range("A1").Value < Range("A3").Value Then Call Macro2 Else End If End If End Sub Sub Macro1() MsgBox " bu 1.makrodur" End Sub Sub Macro2() MsgBox " bu 2.makrodur" End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error Resume Next For Each TmpRng In Target TmpVal = TmpRng.Validation.Type If TmpVal > 0 Then If Application.CutCopyMode = 1 Then MsgBox "You cannot paste into validated cells." Application.CutCopyMode = False Exit Sub End If End If Next End Sub Private Sub Worksheet_Change(ByVal Target As Range) If [a10].Value <> [c10].Value Then MsgBox ("Girdiiniz rakamlar farkl") End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) On Error Resume Next Set myRange = Intersect(Range("A1:A10"), Target) If Not myRange Is Nothing Then UserForm1.Show End If End Sub Sub rast() Dim rastgele As Integer ilk: rastgele = Int(Rnd() * 11) If rastgele <= 0 Or rastgele > 11 Then GoTo ilk Cells(rastgele, 1).Select End Sub Sub buyukler_kalin() Cells(Rows.Count, "A").End(xlUp).Select For Each rgRow In Range("a1:a10").Rows If rgRow.Cells(1).Value > 10 Then rgRow.Font.Bold = True Else rgRow.Font.Bold = False End If Next rgRow End Sub Sub degistir() Dim CurCell As Range For Each CurCell In Range("A1:A10") If CurCell.Value = 10 Then CurCell.Value = 21 Next End Sub Sub BackgroundColors() For Each cell In Range("a1:a10") If Not IsError(cell.Value) Then With cell.Interior Select Case cell.Value Case Is = Empty .ColorIndex = 10 Case Is = "?" .ColorIndex = 6 Case Else .ColorIndex = 0 'xlAutomatic End Select End With Else cell.Interior.ColorIndex = xlAutomatic End If Next cell End Sub Sub BackgroundColors() For Each cell In Range("A1:A10") If Not IsError(cell.Value) Then With cell.Interior Select Case cell.Value Case Is = Empty .ColorIndex = 10 Case Is = "?" .ColorIndex = 6 Case Else .ColorIndex = 0 ' xlAutomatic End Select End With Else cell.Interior.ColorIndex = xlAutomatic End If Next cell End Sub
Aklama: a1:a10 Hcreleri arasndaki bo hcreleri yeile boyar Kod: Sub BackgroundColors() For Each cell In Range("a1:a10") If Not IsError(cell.Value) Then With cell.Interior Select Case cell.Value Case Is = Empty .ColorIndex = 10 Case Is = "?" .ColorIndex = 6 Case Else .ColorIndex = 0 'xlAutomatic End Select End With Else cell.Interior.ColorIndex = xlAutomatic End If Next cell End Sub Sub SommePositive() For Each Cell In Range("A1:A10") If Cell.Value > 0 Then total = total + Cell End If Next MsgBox "Total des valeurs positives " & total Range("A11") = total End Sub Option Explicit Sub Macro2() Dim buf As Variant Dim i As Long 'Get values as an array buf = Range("A1:A10000").Value 'loop through the array and add a string to each element For i = LBound(buf, 1) To UBound(buf, 1) buf(i, 1) = buf(i, 1) & " - modified" Next 'Put the array back into the worksheet Range("A1:A10000").Value = buf End Sub Sub hucresec() Application.ScreenUpdating = False Dim r1 As Range, r2 As Range, rAll As Range Set r1 = Range("A1", "A3") Set r2 = Range("C3", "C8") Set rAll = Union(r1, r2) rAll.Select End Sub
Private Sub ComboBox1_Change() ComboBox2 = "" If ComboBox1 = "1 A Snf" Then ComboBox2.RowSource = "1!b2:b40" ElseIf ComboBox1 = "1 B Snf" Then ComboBox2.RowSource = "1!d2:d40" ElseIf ComboBox1 = "1 C Snf" Then ComboBox2.RowSource = "1!f2:f40" End If End Sub Private Sub UserForm_Initialize() ComboBox1.MatchEntry = fmMatchEntryComplete ComboBox2.MatchEntry = fmMatchEntryComplete ComboBox1.AddItem "1 A Snf" ComboBox1.AddItem "1 B Snf" ComboBox1.AddItem "1 C Snf" End Sub Option Explicit Private Sub Worksheet_Calculate() ' Target value: Const lVal As Long = 100 Dim rCell As Range ' Put the cell you want to look at here ' Cell must be a formula!! Set rCell = Range("C1") ' If the target cells value rises above the specified target value, If rCell.Value > lVal Then ' then deliver a message MsgBox "Target value is above " & lVal, 16, "Too High!" ' And step backwards Application.Undo End If ' Explicitly clear memory Set rCell = Nothing End Sub Option Explicit Private Sub Worksheet_Calculate() ' Target value: Const lVal As Long = 100 Dim rCell As Range ' Put the cell you want to look at here ' Cell must be a formula!! Set rCell = Range("C1") ' If the target cells value equals the specified target value, If rCell.Value = lVal Then ' then deliver a message MsgBox "Target value of " & lVal & " has been achieved", 64, "Target Met!" End If ' Explicitly clear memory Set rCell = Nothing End Sub Option Explicit Private Sub Worksheet_Calculate() ' Target value: Const lVal As Long = 100 Dim rCell As Range ' Put the cell you want to look at here ' Cell must be a formula!! Set rCell = Range("C1") ' If the target cells value drops below the specified target value, If rCell.Value < lVal Then ' then deliver a message MsgBox "Target value is below " & lVal, 16, "Target too Low!" ' And step backwards Application.Undo End If ' Explicitly clear memory Set rCell = Nothing End Sub
Sub Add_Sheet() Dim wSht As Worksheet Dim shtName As String shtName = Format(Now, "mmmm_yyyy") For Each wSht In Worksheets If wSht.Name = shtName Then MsgBox "Sheet already exists...Make necessary " & _ "corrections and try again." Exit Sub End If Next wSht Sheets.Add.Name = shtName Sheets(shtName).Move After:=Sheets(Sheets.Count) Sheets("Mahmut").Range("A1:A5").Copy _ Sheets(shtName).Range("A1") End Sub Private Sub CommandButton1_Click() Dim i As Integer ListBox1.Clear For i = 1 To 50 If StrConv(Cells(i, 1), vbUpperCase) = StrConv(TextBox1, vbUpperCase) Then ListBox1.AddItem Cells(i, 1).Text & " - " & Cells(i, 1).Address(False, False) End If Next i End Sub Private Sub CommandButton2_Click() Dim i As Integer Dim say As Integer ListBox1.Clear Set isim = Range("A1:A50").Find(TextBox1) If Not isim Is Nothing Then ilk = isim.Address Do ListBox1.AddItem isim & " - " & isim.Address(False, False) Set isim = Range("A1:A50").FindNext(isim) Loop While Not isim Is Nothing And isim.Address <> ilk End If End Sub
'Joe Was 'Make cell range font flash, x times, x fast, in x color, 'when Ctrl-z is pressed. Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed 'Make this cell range font flash! Set myCell = Range("A1:AF12") Application.DisplayStatusBar = True Application.StatusBar = "... u an flash yaz gsterisi var ltfen biraz bekleyin...! " 'Make cell font flash to this color! 'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30, 'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11, 'Gray-50% 16, Gray-25% 15, Bright Cyan 8. newColor = 3 'Make the cell range flash fast: 0.01 to slow: 0.99 fSpeed = 0.3 'Make cell flash, this many times! Do Until x = 15 'Run loop! DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = xlAutomatic Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub Sub reSetFlash() 'Re-set cell range color if edit break on color, Ctrl-r to re-set! ActiveCell.Select Selection.Interior.ColorIndex = xlNone End Sub
'Joe Was 'Make cell range font flash, x times, x fast, in x color, 'when Ctrl-z is pressed. Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed 'Make this cell range font flash! Set myCell = Range("A1:AF12") Application.DisplayStatusBar = True Application.StatusBar = "Fla yaz gsterisi var ltfen biraz bekleyin!" newColor = 3 'Make the cell range flash fast: 0.01 to slow: 0.99 fSpeed = 0.3 'Make cell flash, this many times! Do Until x = 15 'Run loop! DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = xlAutomatic Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub Sub reSetFlash() 'Re-set cell range color if edit break on color, Ctrl-r to re-set! ActiveCell.Select Selection.Interior.ColorIndex = xlNone End Sub
Kod: Sub FlashFont() 'Joe Was 'Make cell range font flash, x times, x fast, in x color, 'when Ctrl-z is pressed. Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed 'Make this cell range font flash! Set myCell = Range("A1:AF12") Application.DisplayStatusBar = True Application.StatusBar = "... u an flash yaz gsterisi var ltfen biraz bekleyin...! " 'Make cell font flash to this color! 'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30, 'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11, 'Gray-50% 16, Gray-25% 15, Bright Cyan 8. newColor = 3 'Make the cell range flash fast: 0.01 to slow: 0.99 fSpeed = 0.3 'Make cell flash, this many times! Do Until x = 15 'Run loop! DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = xlAutomatic Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub Sub reSetFlash() 'Re-set cell range color if edit break on color, Ctrl-r to re-set! ActiveCell.Select Selection.Interior.ColorIndex = xlNone End Sub
dorudan listbox'a yerletirmek bazen kafa kartrabiliyor onun yerine aadaki gibi diziye yerletirirseniz daha rahat alrsnz.stediinizi yanl anlam Private Sub CommandButton1_Click() Dim satirda(100, 40) If Not TextBox1 = Empty Then Say = WorksheetFunction.CountA(Sheets("sayfa1").Range("l2:aj15000")) Set bulHucre = Sheets("sayfa1").Range("l2:aj" & Say).Find(TextBox1.Text, lookat:=xlPart) If bulHucre Is Nothing Then Exit Sub ilkAdres = bulHucre.Address ilksat = bulHucre.Row i=0 Do While Not IsEmpty(bulHucre) i=i+1 For t = 1 To 40 satirda(i, t) = Cells(ilksat, t) Next t Set bulHucre = Sheets("sayfa1").Range("l2:aj" & Say).FindNext(bulHucre) If bulHucre.Address = ilkAdres Then Exit Do ilkAdres = bulHucre.Address ilksat = bulHucre.Row Loop End If ListBox1.List = satirda() Set bulHucre = Nothing End Sub Sub AddName1() ActiveSheet.Names.Add Name:="MyRange1", RefersTo:="=$A$1:$B$10" End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Row < 6 And Target.Column < 3 Then UserForm1.Show End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Set MyIsect = Application.Intersect(Target, Range("A1:B5")) If Not MyIsect Is Nothing Then UserForm1.Show End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("A1:C11")) Is Nothing Then Application.EnableEvents = False Cells(Target.Row, 5).Value = Date Application.EnableEvents = True End If End Sub
Dim sourceRange As Range Dim destrange As Range If Selection.Cells.Count > 1 Then Exit Sub Set sourceRange = Sheets("Sayfa1").Range("A1:C10") Set destrange = ActiveCell sourceRange.Copy destrange End Sub Sub CopyToActiveCellValues() Dim sourceRange As Range Dim destrange As Range If Selection.Cells.Count > 1 Then Exit Sub Set sourceRange = Sheets("Sayfa1").Range("A1:C10") With sourceRange Set destrange = ActiveCell.Resize _ (.Rows.Count, .Columns.Count) End With destrange.Value = sourceRange.Value End Sub Function LastRow(sh As Worksheet) On Error Resume Next LastRow = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row On Error GoTo 0 End Function Function Lastcol(sh As Worksheet) On Error Resume Next Lastcol = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Column On Error GoTo 0 End Function Sub ikiylecarp() Dim Tabl Dim I As Integer, J As Integer Tabl = Range("A1:C100").Value For I = 1 To 100 For J = 1 To 3 Tabl(I, J) = Tabl(I, J) * 2 Next J Next I Application.ScreenUpdating = False Range("A1:C100").Value = Tabl End Sub
Range1, ParamArray Range2()) As Double Dim objCell As Range ' Best to use this even if it does ' slow Excel down somewhat. Application.Volatile ' Initialise. SumIfColours = 0 ' Process first argument. ' Restrict the range to stop the loop looking ' at huge swathes of empty cells. For Each objCell In Intersect(Range1, _ Range1.Parent.UsedRange) If Application.IsNumber(objCell.Value) And _ objCell.Interior.ColorIndex = cellTextColour Then _ SumIfColours = SumIfColours + objCell.Value Next objCell ' Process additional arguments (if any) If UBound(Range2) <> 0 Then For intArgument = 1 To UBound(Range2) For Each objCell In Intersect(Range2(intArgument), _ Range2(intArgument).Parent.UsedRange) If Application.IsNumber(objCell.Value) And _ objCell.Interior.ColorIndex = cellTextColour Then _ SumIfColours = SumIfColours + objCell.Value Next objCell Next intArgument End If End Function D21 veya A1:D20 hcreleri dnda bir hcreye aadaki frml yazn. =SumIfColours(3;$A$1:$D$20)
Kod: Function SumIfColours(cellTextColour As Integer, _ Range1, ParamArray Range2()) As Double Dim objCell As Range ' Best to use this even if it does ' slow Excel down somewhat. Application.Volatile ' Initialise. SumIfColours = 0 ' Process first argument. ' Restrict the range to stop the loop looking ' at huge swathes of empty cells. For Each objCell In Intersect(Range1, _ Range1.Parent.UsedRange) If Application.IsNumber(objCell.Value) And _ objCell.Interior.ColorIndex = cellTextColour Then _ SumIfColours = SumIfColours + objCell.Value Next objCell ' Process additional arguments (if any) If UBound(Range2) <> 0 Then For intArgument = 1 To UBound(Range2) For Each objCell In Intersect(Range2(intArgument), _ Range2(intArgument).Parent.UsedRange) If Application.IsNumber(objCell.Value) And _ objCell.Interior.ColorIndex = cellTextColour Then _ SumIfColours = SumIfColours + objCell.Value Next objCell Next intArgument End If End Function D21 veya A1:D20 hcreleri dnda bir hcreye aadaki frml yazn. =SumIfColours(3;$A$1:$D$20) Sub MakeActive() Worksheets("Sheet1").Activate Range("A1:D4").Select Range("B2").Activate End Sub Sub FillAll() Worksheets("Sheet2").Range("A1:H1") _ .Borders(xlBottom).LineStyle = xlDouble Worksheets.FillAcrossSheets (Worksheets("Sheet2") _ .Range("A1:H1")) End Sub Sub gizle() Columns("K:IV").Hidden = True Rows("45:65536").Hidden = True End Sub Sub gster() Columns("K:IV").Hidden = False Rows("45:65536").Hidden = False End Sub
'Make cell range Background color, flash x times, x fast, in x color, 'when Ctrl-a is pressed. Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed 'Make this cell range background flash! Set myCell = Range("A1:M8") Application.DisplayStatusBar = True Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! " 'Make cell background flash to this color! 'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30, 'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11, 'Gray-50% 16, Gray-25% 15, Bright Cyan 8. newColor = 11 'Make the cell range flash fast: 0.01 to slow: 0.99 fSpeed = 0.2 'Make cell flash, this many times! Do Until x = 2 'Run loop! DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = xlNone Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub
'Make cell range Background color, flash x times, x fast, in x color, 'when Ctrl-a is pressed. Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed 'Make this cell range background flash! Set myCell = Range("A1:M8") Application.DisplayStatusBar = True Application.StatusBar = "Select Cell to Stop & Edit or Wait for Flashing to Stop!" 'Make cell background flash to this color! 'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30, 'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11, 'Gray-50% 16, Gray-25% 15, Bright Cyan 8. newColor = 11 'Make the cell range flash fast: 0.01 to slow: 0.99 fSpeed = 0.2 'Make cell flash, this many times! Do Until x = 2 'Run loop! DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = xlNone Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub sayfann kod blmne yaptrn Option Explicit Public CellCheck As Boolean Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Range("A1") = "1" And CellCheck = False Then Call StartBlink CellCheck = True ElseIf Range("A1") <> "1" And CellCheck = True Then Call StopBlink CellCheck = False End If End Sub 'modle yaptrn Option Explicit Public RunWhen As Double Sub StartBlink() If Range("A1").Interior.ColorIndex = 3 Then Range("A1").Interior.ColorIndex = 6 Else Range("A1").Interior.ColorIndex = 3 End If RunWhen = Now + TimeSerial(0, 0, 1) Application.OnTime RunWhen, "StartBlink", , True End Sub Sub StopBlink() Range("A1").Interior.ColorIndex = xlAutomatic Application.OnTime RunWhen, "StartBlink", , False End Sub Sub sichtbare_kopieren() Range("A1").CurrentRegion _ .SpecialCells(xlCellTypeVisible).Copy _ Worksheets("Tabelle2").Range("A1") End Sub
Sub ResetTest2() For Each n In Range("A16:G28") If IsNumeric(n) Then n.Value = 0 End If Next n End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim Schnittpunkt As Range Set Schnittpunkt = Application.Intersect(Target, Me.Range("A1:A20")) If Schnittpunkt Is Nothing Then Exit Sub Else MsgBox "A1-A20 arasna veri girildi" End If End Sub Sub ilkharfler_buyuk() For i = 1 To 5 Range("A" & i).Select t = ActiveCell s = Len(t) u = UCase(Left(t, 1)) & Right(t, s - 1) Range("A" & i) = u Next i End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target = Cells(1, 1) Then Cells(2, 1) = Now End Sub 'alternatif MD() veya Bugn veya Time Range("1:3000").Interior.ColorIndex = xlNone For x = 1 To 3000 If Cells(x, 1).Value <> Empty Then Rows(x).Interior.ColorIndex = 3 End If Next x End Sub Sub DENE_2() For x = 1 To 3000 If Cells(x, 1).Value <> Empty Then Rows(x).Cut Sheets("Sayfa3").Select son = [a65536].End(3).Row + 1 Cells(son, 1).Select ActiveSheet.Paste Sheets("Sayfa1").Select End If Next x End Sub Sub DENE_3() For x = 1 To 3000 yeniden: If Cells(x, 1).Value <> Empty Then Rows(x).Cut Sheets("Sayfa3").Select son = [a65536].End(3).Row + 1 Cells(son, 1).Select ActiveSheet.Paste Sheets("Sayfa1").Select Rows(x).Delete GoTo yeniden End If Next x End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 1 And Not Target = "" Then Cells(Target.Row, Target.Column + 2) = Cells(Target.Row, Target.Column) + Cells(Target.Row, Target.Column + 1) End If End Sub
On Error Resume Next If Target = Range("A1") Then Date_Validation End Sub ' Input the following code in standard module Sub Date_Validation() Dim dteDate As Date Dim strDate As String With Range("A1") ' Memo original date dteDate = CDate(.Text) ' Create date string strDate = Format(dteDate, "m\/d\/yy") With .Validation ' Delete old settings .Delete ' Set new data validation .Add _ Type:=xlValidateDate, _ AlertStyle:=xlValidAlertStop, _ Operator:=xlGreaterEqual, _ Formula1:=strDate .IgnoreBlank = False .InCellDropdown = True .InputTitle = "" .ErrorTitle = "Invalid Date Entry" .InputMessage = "" .ErrorMessage = _ "Date is older than the previous date (" & _ dteDate & ")." .ShowInput = True .ShowError = True End With End With End Sub
Sub datum_splitten() z=2 Do While Cells(z, 1) <> "" Cells(z, 2).NumberFormat = "@" Cells(z, 2) = Left(Cells(z, 1), 2) Cells(z, 3).NumberFormat = "@" Cells(z, 3) = Mid(Cells(z, 1), 4, 2) Cells(z, 4).NumberFormat = "@" Cells(z, 4) = Right(Cells(z, 1), 2) z=z+1 Loop End Sub Sub NomOnglet() Dim Name As String Name = Range("A2") Application.ScreenUpdating = False ActiveSheet.Name = (Name) End Sub Sub SommeProduit() Cells(1, "A").Select NbLignes = Cells(Range("A:A").Count, _ ActiveCell.Column).End(xlUp).Row NbLignes = Cells(16, 1).End(xlUp).Row TotalIntermediaire = 0 For Lgn = 2 To NbLignes If Not Rows(NbLignes).Hidden Then TotalIntermediaire = TotalIntermediaire + _ Cells(Lgn, "A") * Cells(Lgn, "B") End If Next Lgn MsgBox TotalIntermediaire End Sub
Sub satsut() Range("A3").Offset(2, 2) = 5 End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim rMonitor As Range Dim rTarget As Range Set rMonitor = Range("A3") Set rTarget = Range("B7") If Not Intersect(Target, rMonitor) Is Nothing Then rMonitor.Copy rTarget End If Set rMonitor = Nothing Set rTarget = Nothing End Sub Sub PrintRpt3() With Worksheets("Sayfa1").PageSetup .CenterHorizontally = True .PrintArea = "$A$3:$F$15" .PrintTitleRows = ("$A$1:$A$2") .Orientation = xlPortrait .FitToPagesWide = 1 .FitToPagesTall = 1 End With Worksheets("Sayfa1").PrintOut End Sub Sub PrintRpt3() With Worksheets("Sayfa1").PageSetup .CenterHorizontally = True .PrintArea = "$A$3:$F$15" .PrintTitleRows = ("$A$1:$A$2") .Orientation = xlPortrait .FitToPagesWide = 1 .FitToPagesTall = 1 End With Worksheets("Sayfa1").PrintOut End Sub Sub Auto_Open() If Range("a5") <> 2 Then UserForm1.Show ActiveWorkbook.Save Else ActiveWorkbook.Save ActiveWorkbook.Close End If End Sub Declare Function ShellAbout Lib "shell32.dll" _ Alias "ShellAboutA" (ByVal hWnd As Long, _ ByVal szApp As String, ByVal szOtherStuff As String, _ ByVal hIcon As Long) As Long Declare Function GetActiveWindow Lib "user32" () As Long Sub AboutWindow() Dim MyhWnd As Long Dim MyAbout As Long Dim MyCap As String, MyMsg As String If Right(ThisWorkbook.Name, 4) = ".xls" Then MyCap = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) Else MyCap = ThisWorkbook.Name End If MyMsg = ThisWorkbook.Name & " programna hogeldiniz!" MyhWnd = GetActiveWindow() MyAbout = ShellAbout(MyhWnd, MyCap, vbCrLf & MyMsg, 0) End Sub Sub Dialog_28() Application.Dialogs(xlDialogFindFile).Show End Sub
Sub kitapkapat() Workbooks("deneme.xls").Close End Sub Workbooks.Close Sub aciklama_ekler() Dim Aklama_Ekleme As Comment Dim strText As String strText = Application.InputBox("Eklenecek olan mesaj aaya yaznz.", _ "Aklama_Ekleme", "Aklama Ekler", , , , 2) If Application.ExecuteExcel4Macro("Get.Cell(46)") = True Then ActiveCell.Comment.Delete End If ActiveCell.AddComment Set Aklama_Ekleme = ActiveCell.Comment With Aklama_Ekleme .Text Text:=strText With .Shape.TextFrame.Characters.Font .Name = "Arial" .Size = 10 .Bold = False End With End With End Sub Private Sub CommandButton1_Click() Unload UserForm1 End Sub Private Sub CommandButton1_Click() Load UserForm1 UserForm1.Show End Sub Sub aciklama_sil() If Application.ExecuteExcel4Macro("Get.Cell(46)") = True Then ActiveCell.Comment.Delete End If End Sub Sub aciklama_sil() If Not ActiveCell.Comment Is Nothing Then ActiveCell.Comment.Delete End If End Sub Sub auto_comment() Dim commentrange As Range Application.DisplayCommentIndicator = xlCommentAndIndicator For Each commentrange In ActiveSheet.Cells.SpecialCells(1) commentrange.Comment.Shape.Select True Selection.AutoSize = True 'Selection.ShapeRange.Width = 150 'Selection.ShapeRange.Height = 100 Next Application.DisplayCommentIndicator = xlCommentIndicatorOnly End Sub Sub Kommentar_Font() Dim Cell As Range For Each Cell In Cells.SpecialCells(xlCellTypeComments) With Cell.Comment.Shape.TextFrame.Characters.Font .Size = 10 .Bold = True End With Next End Sub
Option Explicit Const ImgFileFormat = "Image Files (*.bmp;*.gif;*.tif;*.jpg;*.jpeg)," & _ "*bmp;*gif;*.tif;*.jpg;*.jpeg" Sub AddPicturesToComments() Dim HasCom Dim Pict As String Dim Ans As Integer Set HasCom = ActiveCell.Comment If Not HasCom Is Nothing Then ActiveCell.Comment.Delete Set HasCom = Nothing GetPict: Pict = Application.GetOpenFilename(ImgFileFormat) 'Note you can load in, almost any file format If Pict = "False" Then End Ans = MsgBox("Open : " & Pict, vbYesNo + vbExclamation, "Use this Picture?") If Ans = vbNo Then GoTo GetPict With ActiveCell .AddComment .Comment.Visible = False .Comment.Shape.Fill.Transparency = 0# .Comment.Shape.Fill.UserPicture Pict End With End Sub Sub auto_open() Application.WindowState = xlMaximized ActiveWindow.WindowState = xlMaximized Application.MoveAfterReturn = False With ThisWorkbook.Worksheets("Buch") .Range("J2").Value = Month(Date) .Range("K2").Value = Year(Date) .OnEntry = "Fahrtenbuch" End With End Sub Private Sub Workbook_Open() ThisWorkbook.Worksheets("Sayfa1").Activate End Sub Sub Auto_Open() Sheets("Bir").Select ActiveWindow.WindowState = xlMaximized Range("C2").Select ActiveWindow.DisplayWorkbookTabs = False ActiveWindow.WindowState = xlMaximized Application.CommandBars("Full Screen").Visible = False Application.CommandBars("Formatting").Visible = False Application.CommandBars("Standard").Visible = False ActiveCell.Select 'mesaj ver yazdr makrosunu kullanarak ilan Application.Caption = "mahmut_bayram@mynet.com" ActiveWindow.Caption = "0505-778 47 69" End Sub Sub Auto_Open() ActiveSheet.OnEntry = "Action" End Sub Sub Auto_Close() ActiveSheet.OnEntry = "" End Sub
Option Explicit Private Sub Workbook_Open() Dim StDatei As String Dim StPhad As String StDatei = ThisWorkbook.Name ' Dateiname StPhad = ThisWorkbook.Path ' Phad ' berprfen ob Sicherheitskopie schon vorhanden ' nur notwendig falls Datei in der selben Minute nochmal geffnet wird ' von Berti Koern Dim Fso As Object Set Fso = CreateObject("Scripting.FileSystemObject") If Fso.FileExists(StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei) Then Kill StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei End If ActiveWorkbook.SaveCopyAs FileName:=StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei End Sub Option Explicit Private Sub Workbook_Open() ActiveWindow.WindowState = xlMinimized UsfIntro.Show End Sub 'eski haline gelmesi Private Sub Workbook_BeforeClose(Cancel As Boolean) ActiveWindow.WindowState = xlNormal End Sub Option Explicit Private Sub Workbook_Open() On Error Resume Next With Application.CommandBars("TestCB") .Position = msoBarFloating .Left = 200 .Top = 200 .Visible = True End With End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.CommandBars("TestCB").Delete End Sub Private Sub Workbook_Activate() On Error Resume Next Application.CommandBars("TestCB").Visible = True End Sub Private Sub Workbook_Deactivate() On Error Resume Next Application.CommandBars("TestCB").Visible = False End Sub
Private Sub Workbook_Open() Const sAPPLICATION As String = "Excel" Const sSECTION As String = "Invoice" Const sKEY As String = "Invoice_key" Const nDEFAULT As Long = 1& Dim nNumber As Long With ThisWorkbook.Sheets("Sayfa1") With .Range("B1") If IsEmpty(.Value) Then .Value = Date .NumberFormat = "dd mmm yyyy" End If End With With .Range("B2") If IsEmpty(.Value) Then nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT) .NumberFormat = "@" .Value = Format(nNumber, "0000") SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1& End If End With End With End Sub Sub Auto_Open() Application.OnKey "%{F8}", "makro" End Sub Sub makro() MsgBox "Merhaba!" MsgBox ActiveCell.Address End Sub sub auto_open() call <istediin makronun adn yaz> end sub sub auto_open() call calisacakmakroadi ' almasn istediiniz makronun ad ... end sub Sub SayfaHucreSec() Sheets("Sayfa1").Select Selection.Range("A1").Select End Sub
Dim InI As Integer Dim ByS As Boolean Private Sub Workbook_BeforeClose(Cancel As Boolean) ' Sheets("Sayfa1").Visible = xlVeryHidden aus Dim Mldg As Byte ' ActiveWorkbook.Unprotect ("Passwort") If ActiveWorkbook.Saved Then Worksheets("Sayfa1").Visible = True For InI = Worksheets.Count To 1 Step -1 If Worksheets(InI).Name <> "Sayfa1" Then Worksheets(InI).Visible = xlVeryHidden Next InI ByS = True ThisWorkbook.Save Else If ByS = True Then Exit Sub Mldg = MsgBox(" Sollen die Vernderungen gespeichertg werden ??", _ vbYesNo + vbQuestion, "Speicher abfrage ?", "", 0) If Mldg = 6 Then Worksheets("Sayfa1").Visible = True For InI = Worksheets.Count To 1 Step -1 If Worksheets(InI).Name <> "Sayfa1" Then Worksheets(InI).Visible = xlVeryHidden Next InI ByS = True ThisWorkbook.Save Else ByS = True ThisWorkbook.Close False End If End If ' ActiveWorkbook.Protect ("Passwort") End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If ByS = False Then Cancel = True MsgBox "Datei kann nur beim schlieen gespeichert werden" End If End Sub Private Sub Workbook_Open() ' ActiveWorkbook.Unprotect ("Passwort") For InI = Worksheets.Count To 1 Step -1 Worksheets(InI).Visible = True Next InI Worksheets("Sayfa1").Visible = False ActiveWorkbook.Saved = True ' ActiveWorkbook.Protect ("Passwort") End Sub Private Sub Workbook_Open() MsgBox "Hallo " & InputBox("Bitte Namen eingeben:") & "!" End Sub Sub Auto_Open() ActiveWorkbook.OnSave = "MacroX" End Sub Sub MacroX() With ActiveSheet.pagesetup .LeftFooter = "&8" + ActiveWorkbook.Path End With End Sub Programnz atnzda size merhaba demesini istemezmisiniz ite kodlar Sub Auto_Open() Msgbox "Hello" End Sub
alma sayfas aldnda makronun otomatik olarak almas iin Auto_Open veya Workbook_Open metodlar kullanlr. lk metot modlde, ikinci metot Sub Auto_Open() ' Modlde Msgbox "Hello" End Sub Private Sub Workbook_Open() ' alma sayfasnda Msgbox "Hello" End Sub Sub auto_open() Call calisacakmakroadi ' almas istenen makronun ad End sub Sub auto_open() MsgBox ("Toplam ") & ThisWorkbook.Worksheets.Count & (" adet sayfa bulunmaktadr."), vbOKOnly, "pir" End Sub Sub Auto_Open() Application.Visible = False Worksheets("Sayfa1").Visible = True Worksheets("Sayfa2").Visible = True End Sub Sub Auto_Close() Application.Visible = False Worksheets("Sayfa1").Visible = False Worksheets("Sayfa2").Visible = False ActiveWorkbook.Save End Sub Alta gnn saatine gre selamlama yapar. Sub auto_open() Select Case Hour(Time) Case Is < 9 Call Routine9h Case Is < 15 Call Routine15h Case Is < 20 Call Routine20h End Select End Sub Sub Routine9h() MsgBox "Gnaydn" & Chr(10) & "Saat 09:00" End Sub Sub Routine15h() MsgBox "Tnaydn" & Chr(10) & "Saat 15:00" End Sub Sub Routine20h() MsgBox "yi Akamlar" & Chr(10) & "Saat 20:00" End Sub Private Sub Workbook_Open() ActiveSheet.Protect userinterfaceonly:=True ActiveSheet.EnableAutoFilter = True End Sub Private Sub CommandButton1_Click() On Error GoTo 10 Windows("kaytlar.xls").Activate MsgBox ("BU DOSYA ZATEN AIKTIR") Exit Sub 10 Workbooks.Open Filename:="C:\Belgelerim\kaytlar.xls" End Sub Kodu aadaki gibi dzenleyin. Kitap3 yerine kapatacanz kitabn adn yazn. "Application.Quit " komutu tm exceli kapatan bir komuttur. Alnt: Private Sub CommandButton2_Click() Unload Me ActiveWorkbook.Save Windows("Kitap3").Close End Sub
A1 hcresine yazdrmak iin; Sub dizin() [A1] = ActiveWorkbook.Path End Sub For Each w In Application.Workbooks w.Save Next w Application.Quit AIKLAMA FORMUNUN ADRES. Private Sub CommandButton11_Click() Load UserForm1 UserForm1.Show End Sub AIKLAMA FORMUNU KAPAR. Private Sub CommandButton1_Click() Unload UserForm1 End Sub sub auto_open() call <istediin makronun adn yaz> end sub sub auto_open() call calisacakmakroadi ' almasn istediiniz makronun ad ... end sub Sub auto_open() UserForm1.Show End Sub Application.Visible = True Sheets("Sayfa1").Select UserForm1.Hide End Sub Sub Dialog_17() Application.Dialogs(xlDialogCreateNames).Show End Sub kullanl =kodbul(B4) & A4 Function KodBul(giris As String) As String coz = Split(giris, " ") For Each elem In coz KodBul = KodBul & Left(elem, 1) Next End Function Sub Dialog_20() Application.Dialogs(xlDialogDefineName).Show End Sub Range("A1:newrij,b1:sprij").Select
Sub
Private Sub CommandButton1_Click() 'bo geilemeyeceini belirten yordam If TextBox1.Text = Empty Then MsgBox ("Ad ksmn bo gemeyiniz"), vbOKOnly, "Uyar!!!": Exit Sub Else End If If TextBox2.Text = Empty Then MsgBox ("Soyad yazmak mecburidir"), , "Uyar!!!": Exit Sub Else End If 'kayt kodlar pir = False sonsatir = Cells(65536, 1).End(xlUp).Row For x = 2 To sonsatir If Cells(x, 1) & Cells(x, 2) = TextBox1 & TextBox2 Then pir = True sira = x Exit For End If Next x If pir = False Then Cells(sonsatir + 1, 1) = TextBox1 Cells(sonsatir + 1, 2) = TextBox2 MsgBox (sonsatir + 1 & ". sraya kayd yapld.") Else MsgBox ("Bu kayt daha nce girilmi..." & sira & ". satir") End If End Sub Application.Goto Reference:="Sales" ' Range("Sales").Select Sub Update_Names() ' Define the range that holds the names for your workbook. Set MyNameRange = Sheets("WB_Names").Range("B:B").SpecialCells(xlConstants) n = MyNameRange.Count - 1 Set MyNameRange = MyNameRange.Offset(1, 0).Resize(n, 1) ' Delete all the current names in the workbook. For Each WBname In ActiveWorkbook.Names WBname.Delete Next ' Recreate all the names in the workbook. For Each WBname In MyNameRange NewName = WBname.Text NewRef = WBname.Offset(0, 1).Text ActiveWorkbook.Names.Add Name:=NewName, RefersTo:=NewRef Next ' Display message to acknowledge completion. MsgBox "Workbook names have been updated." End Sub Sub AfficheLigneColonne() [A:IV].Select Selection.EntireRow.Hidden = False Selection.EntireColumn.Hidden = False Cells(1, 1).Select End Sub Declare Function nom_ordi Lib "kernel32" Alias "GetComputerNameA" (ByVal lbbuffer As String, nsize As Long) As Long Sub nom_de_l_ordinateur() Dim ag As String ag = Space(50) Call nom_ordi(ag, 51) MsgBox Left(ag, InStr(1, ag, Chr(0)) - 1) End Sub Dim WscNetwork As Object Set WscNetwork = CreateObject("WScript.Network") If UCase(WscNetwork.UserName) = UCase("x32") Then Sheets("Sayfa1").Select Else MsgBox "olmaz", , "dikkat" Application.Quit End If Set WscNetwork = Nothing
Sub A_Paylam_smini_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") s = d.ShareName MsgBox s End Sub lan zerindeki bir makinedeki bir excel kitabnn iindeki makroyu kendi makinenizden altrmak Application.Run "\\makineadi\klasoradi\kitapadi.xls!makroadi" 'eer kitaplar ayn makine zerinde ise Application.Run "c:\klasoradi\kitapadi.xls!makroadi"
Dim wbResults As Workbook Dim wbCodeBook As Workbook Application. ScreenUpdating = False Application.DisplayAlerts = False Application.EnableEvents = False On Error Resume Next Set wbCodeBook = ThisWorkbook With Application.FileSearch .NewSearch 'Change path to suit .LookIn = "C:\test\" .FileType = msoFileTypeExcelWorkbooks '.Filename = " Book*.xls" If .Execute > 0 Then 'Workbooks in folder For lCount = 1 To .FoundFiles.Count 'Loop through all. 'Open Workbook x and Set a Workbook variable to it Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0) ' CleanGroups Macro ' Find and delete Administrator, Power Users, and Users groups ' Range("B3").Select ActiveCell.FormulaR1C1 = "Administrators" Cells.Replace What:="Administrators", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Cells.Replace What:="Power Users", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Cells.Replace What:="Users", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Cells.Replace What:="NT AUTHORITY\LOCAL SERVICE", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Cells.Replace What:="NT AUTHORITY\NETWORK SERVICE", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Cells.Replace What:=",", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Cells.Replace What:="?", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("B1:C1").Select Range(Selection, Selection.End(xlDown)).Select ' ' ' Range(Selection, Selection.End(xlUp)).Select Selection.AutoFilter Selection.AutoFilter Field:=1, Criteria1:="=" Selection.AutoFilter Field:=2, Criteria1:="=" Rows("3:3").Select Range(Selection, Selection.End(xlDown)).Select Selection.Delete Shift:=xlUp Selection.Delete Shift:=xlUp wbResults.Close SaveChanges:=True Next lCount End If End With On Error Goto 0 Application.ScreenUpdating = True Application.DisplayAlerts = True Application.EnableEvents = True End Sub
Workbooks.Open Filename:="\\Hakan\c\Belgelerim\HRACAT KAYITLI.xls" Sub DisplayToolBarNumber() Dim i As Integer i=0 For i = 1 To Application.Toolbars.Count MsgBox Toolbars(i).Name, , "Toolbar " & _ i & " of " & Application.Toolbars.Count Next i End Sub Sub CloseAllButActive() 'based on Tom Ogilvy's postings Dim wkbk As Workbook For Each wkbk In Application.Workbooks If wkbk.Name <> ActiveWorkbook.Name Then If Windows(wkbk.Name).Visible = True Then 'MsgBox wkbk.Name & " " & Window Private Function SheetExists(sname) As Boolean ' Aktif alma kitabnda belirtilen sayfa varsa TRUE dndrr Dim x As Object On Error Resume Next Set x = ActiveWorkbook.Sheets(sname) If Err = 0 Then SheetExists = True _ Else SheetExists = False End Function 'sadece koru01, 2,3,4,5 bu kitapta kalr Set s1 = Sheets("koru01"): Set s2 = Sheets("koru02") Set s3 = Sheets("koru03"): Set s2 = Sheets("koru04") Set s2 = Sheets("koru05") cs_kr1 = "koru01": cs_kr2 = "koru02": cs_kr3 = "koru03": cs_kr4 = "koru04": cs_kr5 = "koru05" '--------------------'rnek Dosyasnda sonradan oluturlan dosyalar siler 'korunacak dosyalar baa ta Sheets("koru01").Move Before:=Sheets(1) Sheets("koru02").Move Before:=Sheets(2) Sheets("koru03").Move Before:=Sheets(3) Sheets("koru04").Move Before:=Sheets(4) Sheets("koru05").Move Before:=Sheets(5) For i = Sheets.Count To 1 Step -1 'For i = 1 To Sheets.Count If Sheets(i).Name <> cs_kr1 And Sheets(i).Name <> cs_kr2 And _ Sheets(i).Name <> cs_kr3 And Sheets(i).Name <> cs_kr4 And _ Sheets(i).Name <> cs_kr5 Then Application.DisplayAlerts = False Sheets(i).Delete Application.DisplayAlerts = True Else Set s1 = Nothing: Set s2 = Nothing: Set s3 = Nothing: Set s4 = Nothing: Set s5 = Nothing: Exit Sub End If Next i MsgBox "Arivlenen dosyadan, " & vbCr & _ cs_kr1 & " / " & cs_kr2 & " / " & vbCr & _ cs_kr3 & " / " & cs_kr4 & " / " & vbCr & _ cs_kr5 & vbCr & " alma sayfalar silinmitir.", _ vbInformation, vbInformation, "BLG-01" End Sub Sub AktKit_KrnnSf_Sil() 'koru01, 2,3,4,5 dndaki sayfalar bu kitapta kalr Dim TargetFolder As String Dim s1 As Worksheet ', s2 As Worksheet, s3 As Worksheet Set s1 = Sheets("koru01"): Set s2 = Sheets("koru02") Set s3 = Sheets("koru03"): Set s2 = Sheets("koru04") Set s2 = Sheets("koru05") 'Taslak Sayfalar cs_kr1 = "koru01": cs_kr2 = "koru02": cs_kr3 = "koru03": cs_kr4 = "koru04": cs_kr5 = "koru05" Sub kitapismi() ActiveCell.Value = ActiveWorkbook.FullName End Sub
ActiveCell.Value = ActiveWorkbook.FullName
ActiveWorkbook.Save Sub Test() Dim objTemp As Object Dim chtMyChart As Chart Dim rngImg As Range Set rngImg = ActiveSheet.UsedRange rngImg.Copy Set objTemp = ActiveSheet.Shapes.AddShape(1, 1, 1, 1, 1) objTemp.Select ActiveSheet.Paste objTemp.Delete With Selection .CopyPicture 1, 2 Set chtMyChart = ActiveSheet.ChartObjects.Add(1, 1, .Width, .Height).Chart With chtMyChart .Paste .Export "C:\Temp.jpg" .Parent.Delete End With .Delete End With MsgBox "Resim, C:\Temp.jpg olarak kaydedildi..." Set rngImg = Nothing Set objTemp = Nothing End Sub Sub DigerDosyalariKapa() For Each Wk In Workbooks If Wk.Name <> ThisWorkbook.Name Then Wk.Close savechanges:=True End If Next Wk End Sub Sub GetColumnLetter() Dim MyColumn As String, Here As String '// Get the address of the active cell in the current selection. Const msg = "The column letters @ " Here = ActiveCell.Address '// Note Address format is $<columnletter>$<rownumber>, '// so drop the first character and the characters '// after the column letter(s). MyColumn = Mid(Here, InStr(Here, "$") + 1, InStr(2, Here, "$") - 2) '// Show the result MsgBox msg & Here & ":= " & MyColumn End Sub Sub ResetTest4() For Each n In ActiveSheet.UsedRange If n.Value <> 0 Then n.Value = 0 End If Next n End Sub Aadaki kodu alma sayfasnn kod sayfasna yaptrn. Sayfadaki aktif hcre sar olacaktr. Kodlama yapmadan nce renklendirilmi hcrelerin renkleri Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static EskiHucre As Range If Target.Interior.ColorIndex <> xlColorIndexNone Then EskiHucre.Interior.ColorIndex = xlColorIndexNone Exit Sub ElseIf Not EskiHucre Is Nothing Then EskiHucre.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 Set EskiHucre = Target End Sub
Kod alma sayfasna Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static EskiHucre As Range If Target.Interior.ColorIndex <> xlColorIndexNone Then EskiHucre.Interior.ColorIndex = xlColorIndexNone Exit Sub ElseIf Not EskiHucre Is Nothing Then EskiHucre.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 Set EskiHucre = Target End Sub Sub AddName4() Selection.Name = "MyRange4" End Sub Sub AddName2() ActiveSheet.Names.Add Name:="MyRange2", RefersTo:="=" & Selection.Address() End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal _ Target As Range, Cancel As Boolean) Cancel = True Range(Target.Offset(-1, 0).End(xlUp), Target).Select Target.Formula = "=SUBTOTAL(9," _ & Selection(1).Address(0, 0) & ":" _ & Selection(Selection.Count - 1).Address(0, 0) & ")" Target.Activate End Sub Dim eski Private Sub Worksheet_Change(ByVal Target As Range) If Target.Value < eski Then MsgBox "Mevcut deerden daha kk bir deer giremezsiniz!", vbCritical Target.Value = eski End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) eski = Target.Value End ListFormulas() Sub Sub Dim counter As Integer Dim i As Variant Dim sourcerange As Range Dim destrange As Range Set sourcerange = Selection.SpecialCells(xlFormulas) Set destrange = Range("M1") destrange.CurrentRegion.ClearContents destrange.Value = "Address" destrange.Offset(0, 1).Value = "Formula" If Selection.Count > 1 Then For Each i In sourcerange counter = counter + 1 destrange.Offset(counter, 0).Value = i.Address destrange.Offset(counter, 1).Value = "'" & i.Formula Next ElseIf Selection.Count = 1 And Left(Selection.Formula, 1) = "=" Then destrange.Offset(1, 0).Value = Selection.Address destrange.Offset(1, 1).Value = "'" & Selection.Formula Else MsgBox "This cell does not contain a formula" End If destrange.CurrentRegion.EntireColumn.AutoFit End Sub Sub AddressFormulasMsgBox() For Each Item In Selection If Mid(Item.Formula, 1, 1) = "=" Then MsgBox "The formula in " & Item.Address(rowAbsolute:=False, _ columnAbsolute:=False) & " is: " & Item.Formula, vbInformation End If Next End Sub
Sub AA_Parse_3Letter() 'converts a string in a single cell into tripletts of characters in consecutive cells, assuming one separation character 'e.g. Amino acid sequences in 3-letter-code or nucleotide tripletts 'you can select a range of cells within the Sub AA_Parse() 'converts a text string in a single cell into individual characters in consecutive cells 'you can select a range of cells within the same column 'do not select more than one column, cells to the right of this column will be overwritten If S Sub ResizeRng() Selection.Resize(7, 7).Select End Sub Sub SelectDown() Range(ActiveCell, ActiveCell.End(xlDown)).Select End Tabellennamen_auflisten() Sub Sub Dim i As Integer Dim myRange As Range Set myRange = ActiveCell myRange.Resize(Worksheets.Count).Select If (MsgBox("UYARI: Sayfalara kpr oluturulacak... !" & vbCrLf & _ Chr(13) & " Emin misin ?", vbYesNo)) _ <> vbYes Then Exit Sub For i = 1 To Worksheets.Count With myRange.Cells(i) .Value = Worksheets(i).Name .Hyperlinks.Add _ Anchor:=myRange.Cells(i), _ Address:="", _ SubAddress:=.Value & "!" & .Address, _ ScreenTip:="Blatt (" & .Value & ")", _ TextToDisplay:=.Value End With Next i myRange.Select MsgBox (" Toplam ") & ThisWorkbook.Worksheets.Count & _ (" alma sayfasna kpr oluturuldu"), vbOKOnly, ThisWorkbook.Name End Sub ActiveCell.Offset(1,1).Value = "Merhaba" Sub ActivateNextBlankDown() ActiveCell.Offset(1, 0).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop End Sub Sub range_up() Dim Cell As Range For Each Cell In Selection Cell.Select Application.SendKeys "{F2}+{ENTER}", True Next End Sub Sub ActivateNextBlankToRight() ActiveCell.Offset(0, 1).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(0, 1).Select Loop End Sub Sub EnterInfo() Dim i As Integer Dim cel As Range Set cel = ActiveCell For i = 1 To 10 cel(i).Value = 100 Next i cel(i).Value = "=SUM(R[-10]C:R[-1]C)" End Sub
Sub EnterInfo() Dim i As Integer Dim cel As Range 'Set cel = [B3] Set cel = ActiveCell For i = 1 To 10 cel(i).Value = [B1].Value - 1 + i Next i cel(i).Value = "=SUM(R[-10]C:R[-1]C)" End Sub Sub InsertRow() Dim Rng Rng = InputBox("Enter number of rows required.") Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Rng - 1, 0)).Select Selection.EntireRow.Insert End Sub Sub SelectToRight() Range(ActiveCell, ActiveCell.End(xlToRight)).Select End Sub Sub git() ActiveCell.End(xlDown).Select ' aktif hcreden aa doru son satra gider End Sub Sub git2() ActiveCell.End(xlUp).Select ' aktif hcreden yukar doru ilk satra gider End Sub Sub git3() ActiveCell.End(xlToLeft).Select ' aktif hcreden sola doru ilk satra gider End Sub Sub git4() ActiveCell.End(xlToRight).Select ' aktif hcreden saa doru son satra gider End Sub Sub SelectToLeft() Range(ActiveCell, ActiveCell.End(xlToLeft)).Select End Sub Sub SelectDown() Range(ActiveCell, ActiveCell.End(xlUp)).Select End Sub Sub aktiflestir() If IsNumeric(ActiveCell) Then ActiveCell.Font.Bold = ActiveCell.Value >= 500 End If End Sub Sub TextIntoComments() Dim cell As Range Selection.ClearComments For Each cell In Intersect(Selection, ActiveSheet.UsedRange) If Trim(cell.Text) <> "" Then cell.AddComment cell.Text cell.Comment.Visible = False cell.Comment.Shape.TextFrame.AutoSize = True BU KODU SAYFA KOD BLMNE YAZARSANIZ AKTF HCRELER RENKL OLUR Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static EskiHucre As Range If Target.Interior.ColorIndex <> xlColorIndexNone Then EskiHucre.Interior.ColorIndex = xlColorIndexNone Exit Sub ElseIf Not EskiHucre Is Nothing Then EskiHucre.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 37 Set EskiHucre = Target End Sub Sub Aktive_Zelle() az = ActiveCell.Address MsgBox az End Sub
Sub bossasil() Dim N As Long For N = Selection(1, 1).Row + Selection.Rows.Count - 1 _ To Selection(1, 1).Row Step -1 With Cells(N, 1) If .Value = 0 And Not .HasFormula Then .EntireRow.Delete End If End With Next N End Sub Sub bossasil() Dim N As Long For N = Selection(1, 1).Row + Selection.Rows.Count - 1 _ To Selection(1, 1).Row Step -1 With Cells(N, 1) If .Value = 0 And Not .HasFormula Then .EntireRow.Delete End If End With Next N End Sub Bo hcreden sonra veri varsa hepsini seer. Sub Select_from_ActiveCell_to_Last_Cell_in_Column() Dim topCel As Range Dim bottomCel As Range On Error GoTo errorHandler Set topCel = ActiveCell Set bottomCel = Cells((65536), topCel.Column).End(xlUp) If bottomCel.Row >= topCel.Row Then Range(topCel, bottomCel).Select End If Exit Sub errorHandler: MsgBox "Error no. " & Err & " - " & Error End Sub Sub SelectFirstToLastInColumn() Set TopCell = Cells(1, ActiveCell.Column) Set BottomCell = Cells(16384, ActiveCell.Column) If IsEmpty(TopCell) Then Set TopCell = TopCell.End(xlDown) If IsEmpty(BottomCell) Then Set BottomCell = BottomCell.End(xlUp) If TopCell.Row = 16384 And BottomCell.Row = 1 Then _ ActiveCell.Select Else Range(TopCell, BottomCell).Select End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Cells.Interior.ColorIndex = 0 'Turn off previous use If Cells(1, 1) = "." Then Exit Sub Target.EntireRow.Interior.ColorIndex = 38 End Sub Aadaki kodu alma sayfanzn kod sayfasna yaptrn. Sayfada aktif olan hcrenin bulunduu satr sar olacaktr. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Rows.Interior.ColorIndex = xlColorIndexNone Rows(Target.Row).Interior.ColorIndex = 6 End Sub Sub SelectEntireRow() Selection.EntireRow.Select End Sub Sub SelectEntireColumn() Selection.EntireColumn.Select End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Application.IsText(ActiveCell) = True Then MsgBox "Bu hcrede YAZI vardr." Else If ActiveCell = "" Then MsgBox "Bu hcre BO tur." Else End If If ActiveCell.HasFormula Then MsgBox "Bu hcrede FORML vardr" Else End If If IsDate(ActiveCell.Value) = True Then MsgBox "Bu hcrede TARH vardr" Else End If If IsNumeric(ActiveCell.Value) = True Then MsgBox "Bu hcrede SAYI vardr" Else End If End If End Sub Sub InserLSiRupture() Set x = ActiveCell Do Until IsEmpty(x) If x.Row > 1 Then If x.Offset(-1, 0).Value <> x.Value Then Rows(x.Row).Insert Shift:=xlDown End If End If Set x = x.Offset(1, 0) Loop End Sub Sub ContentChk() If Application.IsText(ActiveCell) = True Then MsgBox "Metin" Else If ActiveCell = "" Then MsgBox "Bo hcre" Else End If If ActiveCell.HasFormula Then MsgBox "Forml" Else End If If IsDate(ActiveCell.Value) = True Then MsgBox "Tarih" Else End If End If End Sub Sub MyPosition() myRow = ActiveCell.Row myCol = ActiveCell.Column Msgbox myRow & "," & myCol End Sub
Sub numeric_control() If Not Application.IsNumber(ActiveCell) Then MsgBox "Numerik deil" Else MsgBox "Numerik" End If End Sub Sub text_control() If Not Application.IsText(ActiveCell) Then MsgBox "Yaz deil" Else MsgBox "Yaz" End If End Sub Sub aktif() Range("J1:P1").Value = Range(ActiveCell, ActiveCell.Offset(0, 6)).Value End Sub Sub SelectFirstToLastInRow() Set LeftCell = Cells(ActiveCell.Row, 1) Set RightCell = Cells(ActiveCell.Row, 256) If IsEmpty(LeftCell) Then Set LeftCell = LeftCell.End(xlToRight) If IsEmpty(RightCell) Then Set RightCell = RightCell.End(xlToLeft) If LeftCell.Column = 256 And RightCell.Column = 1 Then _ ActiveCell.Select Else Range(LeftCell, RightCell).Select End Sub Seili hcrenin bulunduu stunun en stndeki (1 satrndaki) hcre renklenir. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Range("A1:IV1").Interior.ColorIndex = xlNone sutun = Target.Column Cells(1, sutun).Interior.ColorIndex = 6 End Sub 'Seili hcrenin bulunduu satrn en solundaki (A stunundaki) hcre renklenir. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Range("A:A").Interior.ColorIndex = xlNone satir = Target.Row Range("A" & satir).Interior.ColorIndex = 6 End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Range) Application.Goto Reference:=ActiveCell, Scroll:=True End Sub Sub toplama() t1 = ActiveCell.Offset(-1, 0).Value t2 = ActiveCell.Offset(-2, 0).Value ActiveCell.Value = t1 + t2 End Sub Sub dortsatirekle() ActiveCell.Rows("1:4").EntireRow.Select Selection.Insert Shift:=xlDown ActiveCell.Offset(3, 0).Range("A1").Select End Sub Sub dortsatirekle() ActiveCell.Rows("1:4").EntireRow.Select Selection.Insert Shift:=xlDown ActiveCell.Offset(3, 0).Range("A1").Select End Sub
Dim aCount As Integer, cCount As Integer, rCount As Integer Dim i As Integer, j As Long, aRange As String Dim rHeight() As Single, cWidth() As Single Dim AWB As Workbook, NWB As Workbook If UCase(TypeName(ActiveSheet)) <> "WORKSHEET" Then Exit Sub aCount = Selection.Areas.Count If aCount = 0 Then Exit Sub ' no cells selected cCount = Selection.Areas(1).Cells.Count If aCount > 1 Then ' multiple areas selected Application.ScreenUpdating = False Application.StatusBar = "Printing " & aCount & " selected areas..." Set AWB = ActiveWorkbook rCount = ActiveSheet.Cells.SpecialCells(xlLastCell).Row cCount = ActiveSheet.Cells.SpecialCells(xlLastCell).Column ReDim rHeight(rCount) ReDim cWidth(cCount) For i = 1 To rCount rHeight(i) = Rows(i).RowHeight Next i For i = 1 To cCount cWidth(i) = Columns(i).ColumnWidth Next i Set NWB = Workbooks.Add ' create a new workbook For i = 1 To rCount ' set row heights Rows(i).RowHeight = rHeight(i) Next i For i = 1 To cCount ' set column widths Columns(i).ColumnWidth = cWidth(i) Next i For i = 1 To aCount AWB.Activate aRange = Selection.Areas(i).Address Range(aRange).Copy ' copying the range NWB.Activate With Range(aRange) ' pastes values and formats .PasteSpecial Paste:=xlValues, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False .PasteSpecial Paste:=xlFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False End With Application.CutCopyMode = False Next i NWB.PrintOut NWB.Close False ' close the temporary workbook without saving Application.StatusBar = False AWB.Activate Set AWB = Nothing Set NWB = Nothing Else If cCount < 10 Then ' less than 10 cells selected If MsgBox("Are you sure you want to print " & _ cCount & " selected cells ?", _ vbQuestion + vbYesNo, "Print celected cells") = vbNo Then Exit Sub End If Selection.PrintOut End If End Sub Sub commenter() Dim Cmt As Comment Set Cmt = ActiveCell.AddComment Cmt.Text "Mahmut BAYRAM" With Cmt.Shape.TextFrame.Characters.Font .Name = "Arial" .Size = 14 End With End Sub Sheets("Sayfa3").Range("A1:A3").Copy Destination:=ActiveCell
Sub FirmDate() Selection.Value = Date End Sub Font listele Sub SchriftLesen() Dim C As CommandBarControl Dim i As Integer Set C = CommandBars.FindControl(ID:=1728) For i = 1 To C.ListCount With Cells(i, 1) .Value = C.List(i) .Font.Name = C.List(i) End With Next i End Sub Sub KitapveSayfaadi() ActiveCell.Value = ExecuteExcel4Macro("get.document(1)") End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal Target _ As Range, Cancel As Boolean) Cancel = True 'Get out of edit mode If Target.Row = 1 Then Exit Sub If Target.Column <> 2 Then Exit Sub 'Require Col B On Error Resume Next Application.EnableEvents = False Target.Value = Target.Value + 1 Application.EnableEvents = True If Err.Number <> 0 Then MsgBox "Unable to add 1 to value in cell " _ & Target.Address(0, 0) End If End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal _ Target As Range, Cancel As Boolean) 'David McRitchie, misc, 2001-07-02 '-- Find top cell in continguous range Cancel = True 'Get out of edit mode Range(Target.Offset(-1, 0).End(xlUp), Target).Select '-- leave selection of cells showing for visual verification. Target.Formula = "=SUBTOTAL(9," _ & Selection(1).Address(0, 0) & ":" _ & Selection(Selection.Count - 1).Address(0, 0) & ")" 'make the double-clicked cell the active cell for the range Target.Activate End Sub Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) ActiveCell = Date End Sub Private Sub Worksheet_Change(ByVal Target As Range) Dim Bul As Range, ilkadres, i Application.ScreenUpdating = False If Target.Address = "$H$1" Then Sayfa1.[I1:I65536].ClearContents Set Bul = Sayfa1.[A:A].Find(Target, LookAt:=xlWhole) If Not Bul Is Nothing Then ilkadres = Bul.Address i=1 Do i=i+1 Target(i - 1, 2) = Bul(1, 4) Set Bul = Sayfa1.[A:A].FindNext(Bul) Loop Until ilkadres = Bul.Address End If End If End Sub Aktif hcre deerini bir artr. Sub addme() i = ActiveCell ActiveCell.Value = (i + 1) End Sub
Aktif hcre deerini bir artr. Sub addme() i = ActiveCell ActiveCell.Value = (i -1) End Sub Sub artir_30() Dim pir pir = ActiveCell + 30 ActiveCell = pir End Sub Sub TopLeft() ActiveCell.Select With ActiveWindow .ScrollColumn = ActiveCell.Column .ScrollRow = ActiveCell.Row End With End Sub On Error Resume Next ActiveCell.Offset(-1, 0).Select TextBox1 = ActiveCell Call UserForm_Initialize End Sub Private Sub SpinButton1_SpinDown() On Error Resume Next ActiveCell.Offset(1, 0).Select TextBox1 = ActiveCell Call UserForm_Initialize End Sub Private Sub SpinButton2_SpinDown() On Error Resume Next ActiveCell.Offset(0, -1).Select TextBox1 = ActiveCell Call UserForm_Initialize End Sub Private Sub SpinButton2_SpinUp() On Error Resume Next ActiveCell.Offset(0, 1).Select TextBox1 = ActiveCell Call UserForm_Initialize End Sub Private Sub UserForm_Initialize() ListBox1.Clear ListBox1.AddItem (ActiveCell) TextBox1.Text = "" TextBox1 = ActiveCell End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.Row = 2 And Target.Column = 3 Then 'fr Zelle C2, ggf. anpassen ActiveWindow.Zoom = 200 Else ActiveWindow.Zoom = 100 End If End Sub Sub EmailWorkbook() Application.Dialogs(xlDialogSendMail).Show End Sub Sub aktifkolon() ActiveCell.EntireColumn.Select End Sub Sub Red_Class() Dim i As Integer For i = 1 To Workbooks.Count Workbooks(i).Activate ActiveWindow.WindowState = xlMinimized Next i End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean) Cells.Interior.ColorIndex = xlNone End Sub Sub AddName3() Dim rngSelect As String rngSelect = Selection.Address ActiveSheet.Names.Add Name:="MyRange3", RefersTo:="=" & rngSelect End Sub Private Sub CommandButton1_Click() Unload UserForm1 End Sub Hseyin Bey 'de byle alglam olacak ki Command1 yerine CommandButton1 yazm. VB de de ayn kod geerli olacaktr. Kod: Private Sub Command1_Click() Unload Form1 End Sub
Hide ile Unload arasndaki fark bu. O halde baka bir dme ile formu tekrar aktif yapmak isterseniz Initialize olayn kullanmalsnz. Eer Hseyin Bey'in d O halde zet yapacak olursak. Hide ----> Activate Unload ---> VBA iin Initialize , VB iin Load Sub UserName() ActiveWindow.Caption = ActiveWindow _ .Caption & " " & Application.UserName End Sub Sub haftasonuisaretle() For Each oCell In Range(Cells(1, 4), Cells(1, 14)) If Weekday(oCell.Value) = 7 Or Weekday(oCell.Value) = 1 Then With oCell.Interior .Pattern = xlGray16 .PatternColorIndex = 42 End With End If Next oCell End Sub Sub selectionrowscount() Dim ZeileAnfang As Integer Dim ZeileEnde As Integer Dim SpalteAnfang As Integer Dim SpalteEnde As Integer SpalteAnfang = Selection.Column SpalteEnde = Selection.Columns.Count ZeileAnfang = Selection.Row ZeileEnde = Selection.Rows.Count ZeileAnfang = ZeileAnfang ZeileEnde = ZeileEnde + ZeileAnfang SpalteEnde = SpalteEnde + SpalteAnfang - 1 Range(Cells(ZeileAnfang, SpalteAnfang), Cells(ZeileEnde, SpalteEnde)).Select End Sub Sub ZeilenAuswahl() Selection.EntireRow.Select End Sub
Sub DeleteBlankRowsEvenFaster() Set myrange = Range("B4:I31") Set blanks = myrange.SpecialCells(xlCellTypeBlanks) For Each area In blanks.Areas If area.Columns.Count = myrange.Columns.Count Then n=n+1 If n = 1 Then Set delrange = area.EntireRow Else Set delrange = Union(delrange, area.EntireRow) End If End If Next area delrange.Delete End Sub Sub DeleteBlankRows() Set myrange = Range("B4:I31") Set blanks = myrange.SpecialCells(xlCellTypeBlanks) For Each area In blanks.Areas If area.Columns.Count = myrange.Columns.Count Then area.EntireRow.Delete End If Next area End Sub Sub DeleteSheets() Application.DisplayAlerts = False For Each Sheet In Worksheets If Sheet.Name <> ActiveSheet.Name Then Sheet.Delete Next Application.DisplayAlerts = True End If End Sub Sub ArbeitsblattUmbenennen() Activesheet.Name="Neuer Name" End Sub
Dim TimeStr As String On Error GoTo EndMacro If Application.Intersect(Target, Range("A1:A10")) Is Nothing Then Exit Sub End If If Target.Cells.Count > 1 Then Exit Sub End If If Target.Value = "" Then Exit Sub End If Application.EnableEvents = False With Target If .HasFormula = False Then Select Case Len(.Value) Case 1 ' e.g., 1 = 00:01 AM TimeStr = "00:0" & .Value Case 2 ' e.g., 12 = 00:12 AM TimeStr = "00:" & .Value Case 3 ' e.g., 735 = 7:35 AM TimeStr = Left(.Value, 1) & ":" & _ Right(.Value, 2) Case 4 ' e.g., 1234 = 12:34 TimeStr = Left(.Value, 2) & ":" & _ Right(.Value, 2) Case 5 ' e.g., 12345 = 1:23:45 NOT 12:03:45 TimeStr = Left(.Value, 1) & ":" & _ Mid(.Value, 2, 2) & ":" & Right(.Value, 2) Case 6 ' e.g., 123456 = 12:34:56 TimeStr = Left(.Value, 2) & ":" & _ Mid(.Value, 3, 2) & ":" & Right(.Value, 2) Case Else Err.Raise 0 End Select .Value = TimeValue(TimeStr) End If End With Application.EnableEvents = True Exit Sub EndMacro: MsgBox "You did not enter a valid time" Application.EnableEvents = True End Sub
Dim DateStr As String On Error GoTo EndMacro If Application.Intersect(Target, Range("A1:A10")) Is Nothing Then Exit Sub End If If Target.Cells.Count > 1 Then Exit Sub End If If Target.Value = "" Then Exit Sub End If Application.EnableEvents = False With Target If .HasFormula = False Then Select Case Len(.Formula) Case 4 ' e.g., 9298 = 2-Sep-1998 DateStr = Left(.Formula, 1) & "/" & _ Mid(.Formula, 2, 1) & "/" & Right(.Formula, 2) Case 5 ' e.g., 11298 = 12-Jan-1998 NOT 2-Nov-1998 DateStr = Left(.Formula, 1) & "/" & _ Mid(.Formula, 2, 2) & "/" & Right(.Formula, 2) Case 6 ' e.g., 090298 = 2-Sep-1998 DateStr = Left(.Formula, 2) & "/" & _ Mid(.Formula, 3, 2) & "/" & Right(.Formula, 2) Case 7 ' e.g., 1231998 = 23-Jan-1998 NOT 3-Dec-1998 DateStr = Left(.Formula, 1) & "/" & _ Mid(.Formula, 2, 2) & "/" & Right(.Formula, 4) Case 8 ' e.g., 09021998 = 2-Sep-1998 DateStr = Left(.Formula, 2) & "/" & _ Mid(.Formula, 3, 2) & "/" & Right(.Formula, 4) Case Else Err.Raise 0 End Select .Formula = DateValue(DateStr) End If End With Application.EnableEvents = True Exit Sub EndMacro: MsgBox "You did not enter a valid date." Application.EnableEvents = True End Sub
Sub Tabellennamen_auflisten() 'Sisto Salera 24.06.2003 'Melanie Breden 25.06.2003 Dim i As Integer Dim myRange As Range Set myRange = ActiveCell myRange.Resize(Worksheets.Count).Select If (MsgBox("ACHTUNG: Der markierte Bereich wird berschrieben !" & vbCrLf & _ Chr(13) & " Trotzdem fortfahren ?", vbYesNo)) _ <> vbYes Then Exit Sub For i = 1 To Worksheets.Count With myRange.Cells(i) .Value = Worksheets(i).Name .Hyperlinks.Add _ Anchor:=myRange.Cells(i), _ Address:="", _ SubAddress:=.Value & "!" & .Address, _ ScreenTip:="Blatt (" & .Value & ")", _ TextToDisplay:=.Value End With Next i myRange.Select
MsgBox ("Es befinden sich ") & ThisWorkbook.Worksheets.Count & _ (" Tabellenbltter in dieser Arbeitsmappe."), vbOKOnly, ThisWorkbook.Name End Sub Option Explicit Private Sub Worksheet_Calculate() If Range("B1").Value = "E" Then ActiveSheet.Pictures(1).Visible = True Else ActiveSheet.Pictures(1).Visible = False End If End Sub 'Thisworkbook a Option Explicit Option Explicit Sub Top3LinesAllSheets() Dim wkSheet As Worksheet For Each wkSheet In Application.Worksheets With wkSheet.PageSetup .PrintTitleRows = "$1:$3" End With Sheets(wkSheet.Name).Rows("1:3").Font.Bold = True Veriler B,C,D,E stununda Private Sub Worksheet_SelectionChange(ByVal Target As Range) ' If Target.Column <> 6 Then Exit Sub ' buras aktif olursa yalnzca kontrol f stununa geince yapar For x = 2 To [b65536].End(3).Row - 1 For y = x + 1 To [b65536].End(3).Row alan1 = Cells(x, 2) & Cells(x, 3) & Cells(x, 4) & Cells(x, 5) alan2 = Cells(y, 2) & Cells(y, 3) & Cells(y, 4) & Cells(y, 5) If alan1 = alan2 Then If MsgBox(y & ".satrdaki veri " & x & ".nci satrda girilmi," & y & ".satr silmek istiyor musunuz?", vbYesNo, "Uyar") = vbYes Then Range(Cells(y, 2), Ce End If Next Next End Sub
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim mahmut As Range, bayram As Range On Error GoTo pir: Set mahmut = Range("B3:C20,D1:D7") Application.EnableEvents = False For Each bayram In Range(Target.Address) If Not Intersect(bayram, mahmut) Is Nothing Then If bayram <> "" Then bayram = "'00" & bayram End If Next bayram Set mahmut = Nothing pir: Application.EnableEvents = True End Sub Private Sub ComboBox1_Change() ActiveSheet.Cells(1, 1).Select If Not ComboBox1.Value = "" Then Worksheets(ComboBox1.Value).Select Sheets(1).ComboBox1.Value = "" End Sub Private Sub Workbook_BeforePrint(Cancel As Boolean) If ActiveSheet.Name = "Tabelle1" Then Application.OnTime Time + TimeSerial(0, 0, 1), "AfterPrint" End If End Sub Modle Public Sub AfterPrint() MsgBox ("Ich werde erst angezeigt, nachdem der Druck ''angestossen'' wurde !!!") ' hier auszufhrenden Code ergnzen End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Select Case Target.Value Case 1 Target.Interior.ColorIndex = 2 Case 2 Target.Interior.ColorIndex = 3 Case 3 Target.Interior.ColorIndex = 4 Case 4 Target.Interior.ColorIndex = 5 Case 5 Target.Interior.ColorIndex = 6 Case 6 Target.Interior.ColorIndex = 7 Case Else Target.Interior.ColorIndex = xlColorIndexNone End Select End Sub
Private Sub Worksheet_Change(ByVal Target As Range) Dim RaBereich As Range, RaZelle As Range Set RaBereich = Range("B3:C20, D1:D7") ' Set RaBereich = Union(Range("C7:I26"), Range("L7:R26"), Range("U7:AA26"), Range("AD7:AJ26")) ' ActiveSheet.Unprotect ("Passwort") For Each RaZelle In Range(Target.Address) If Not Intersect(RaZelle, RaBereich) Is Nothing Then With RaZelle Select Case UCase(.Value) Case "1" .Interior.ColorIndex = 1 .Font.ColorIndex = 2 '.NumberFormat = "General" ' Zellenformat Standard Case "2" .Interior.ColorIndex = 6 .Font.ColorIndex = 0 '.NumberFormat = "General" ' Zellenformat Standard Case "3" .Interior.ColorIndex = 3 .Font.ColorIndex = 2 '.NumberFormat = ";;;" Case "4" .Interior.ColorIndex = 4 .Font.ColorIndex = 0 '.NumberFormat = "General" ' Zellenformat Standard Case "KLAUS" .Interior.ColorIndex = 5 .Font.ColorIndex = 0 '.NumberFormat = "General" ' Zellenformat Standard Case Else .Interior.ColorIndex = xlNone .Font.ColorIndex = 0 '.NumberFormat = "General" ' Zellenformat Standard End Select End With End If Next RaZelle ' ActiveSheet.protect ("Passwort") Set RaBereich = Nothing End Sub Private Sub Worksheet_Calculate() Dim RaBereich As Range, RaZelle As Range Set RaBereich = Range("B3:C20, D1:D7") ' Set RaBereich = Union(Range("C7:I26"), Range("L7:R26"), Range("U7:AA26"), Range("AD7:AJ26")) ' ActiveSheet.Unprotect For Each RaZelle In RaBereich If Not Intersect(RaZelle, RaBereich) Is Nothing Then Select Case RaZelle.Value Case "1" RaZelle.Interior.ColorIndex = 1 Case "2" RaZelle.Interior.ColorIndex = 6 Case "3" RaZelle.Interior.ColorIndex = 3 Case "4" RaZelle.Interior.ColorIndex = 4 Case Else RaZelle.Interior.ColorIndex = xlNone End Select End If Next RaZelle ' ActiveSheet.protect Set RaBereich = Nothing End Sub
Private Sub Worksheet_Change(ByVal Target As Range) Dim Plage As Range Set Plage = Intersect(Target, Range("A1:A10")) If Plage Is Nothing Then Exit Sub For Each cellule In Plage If cellule.Value = 1 Then cellule.NumberFormat = "General"" er""" Else: cellule.NumberFormat = "General"" Snf""" End If Next End Sub Sub dortgen_sil() For Each Rectangle In ActiveSheet.Shapes Rectangle.Delete Next End Sub
End Sub 'Modle Option Explicit Const PopUpCommandBarName As String = "TemporaryPopupMenu" Sub DeletePopUp() On Error Resume Next CommandBars(PopUpCommandBarName).Delete On Error GoTo 0 End Sub Sub CreatePopUp() Dim cb As CommandBar, m As CommandBarPopup DeletePopUp Set cb = CommandBars.Add(PopUpCommandBarName, msoBarPopup, False, True) With cb With .Controls.Add(Type:=msoControlButton) .OnAction = "MyMacroName" .FaceId = 71 .Caption = "Custom Menu 1" .TooltipText = "Custom Tooltip Text 1" End With With .Controls.Add(Type:=msoControlButton) .OnAction = "MyMacroName" .FaceId = 72 .Caption = "Custom Menu 2" .TooltipText = "Custom Tooltip Text 2" End With With .Controls.Add(Type:=msoControlButton) .OnAction = "MyMacroName" .FaceId = 73 .Caption = "Custom Menu 3" .TooltipText = "Custom Tooltip Text 3" End With Set m = .Controls.Add(Type:=msoControlPopup) With m .BeginGroup = True .Caption = "Sub Menu" With .Controls.Add(Type:=msoControlButton) .OnAction = "MyMacroName" .FaceId = 71 .Caption = "Custom Menu 1" .TooltipText = "Custom Tooltip Text 1" End With With .Controls.Add(Type:=msoControlButton) .OnAction = "MyMacroName" .FaceId = 72 .Caption = "Custom Menu 2" .TooltipText = "Custom Tooltip Text 2" End With With .Controls.Add(Type:=msoControlButton) .OnAction = "MyMacroName" .FaceId = 73 .Caption = "Custom Menu 3" .TooltipText = "Custom Tooltip Text 3" End With End With Set m = Nothing End With Set cb = Nothing End Sub Sub DisplayCustomPopUp() On Error Resume Next Application.CommandBars(PopUpCommandBarName).ShowPopup On Error GoTo 0 End Sub Sub DisplayExampleUserForm() Load UserForm1 UserForm1.Show Unload UserForm1 End Sub Sub MyMacroName()
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) Cancel = True MsgBox "Click droit indisponible" End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count > 1 Then Exit Sub On Error GoTo ErrorHandler Application.EnableEvents = False If IsNumeric(Target.Value) Then If Not Target.Comment Is Nothing Then Target = Target.Value + CDbl(Target.Comment.Text) Target.Comment.Delete End If Target.AddComment (Target.Text) Application.DisplayCommentIndicator = 0 End If ErrorHandler: Application.EnableEvents = True End Sub Sub Printr() ActiveSheet.PageSetup.CenterHeader = "&""Arial,Bold Italic""&14My Report" & Chr(13) _ & Sheets(1).Range("A1") ActiveWindow.SelectedSheets.PrintOut Copies:=1 End Sub Sayfann kod blmne Private Sub Worksheet_Change(ByVal Target As Excel.Range) Target.NoteText "Die Zelle wurde am " & Format(Date, "dd.mm.yy") & " um " & Format(Now(), " hh:mm:ss") & " durch " & ActiveWorkbook.BuiltinDocum End Sub 'Modl blmne Sub Kommentare_lschen() Application.DisplayCommentIndicator = xlCommentAndIndicator Cells.Select Selection.ClearComments Range("A1").Select Selection.ClearComments Application.CommandBars("Reviewing").Visible = False Application.DisplayCommentIndicator = xlCommentIndicatorOnly End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Target.NoteText "Die Zelle wurde am " & Format(Date, "dd.mm.yy") & " um " & Format(Now(), " hh:mm:ss") & " durch " & ActiveWorkbook.BuiltinDocum End Sub Sub Kommentare_lschen() Application.DisplayCommentIndicator = xlCommentAndIndicator Cells.Select Selection.ClearComments Range("A1").Select Selection.ClearComments Application.CommandBars("Reviewing").Visible = False Application.DisplayCommentIndicator = xlCommentIndicatorOnly End Sub Private Sub Worksheet_Change(ByVal Target As Range) On Error Resume Next Target = UCase(Target) End Sub Private Sub Worksheet_Change(ByVal Target As Range) Target = BH(Target) End Sub Function BH(cevir) BH = Replace(cevir, "i", "") BH = Replace(BH, "", "I") BH = UCase(BH) End Function
Dim MyData As DataObject Sub TestClip() Set MyData = New DataObject ActiveSheet.Shapes("Dikdrtgen 4").Select MyData.SetText Selection.Text MyData.PutInClipboard [A1].Select ActiveSheet.Paste End Sub Dim FormulaCells As Range, Cell As Range Dim FormulaSheet As Worksheet Dim Row As Integer ' Create a Range object for all formula cells On Error Resume Next Set FormulaCells = Range("A1").SpecialCells(xlFormulas, 23) ' Exit if no formulas are found If FormulaCells Is Nothing Then MsgBox "Sayfada Forml Yok" Exit Sub End If ' Add a new worksheet Application.ScreenUpdating = False Set FormulaSheet = ActiveWorkbook.Worksheets.Add FormulaSheet.Name = FormulaCells.Parent.Name & "Formlleri " ' Set up the column headings With FormulaSheet Range("A1") = "Address" Range("B1") = "Formula" Range("C1") = "Value" Range("A1:C1").Font.Bold = True End With ' Process each formula Row = 2 For Each Cell In FormulaCells Application.StatusBar = Format((Row - 1) / FormulaCells.Count, "0%") With FormulaSheet Cells(Row, 1) = Cell.Address _ (RowAbsolute:=False, ColumnAbsolute:=False) Cells(Row, 2) = " " & Cell.Formula Cells(Row, 3) = Cell.Value Row = Row + 1 End With Next Cell ' Adjust column widths FormulaSheet.Columns("A:C").AutoFit Application.StatusBar = False End Sub
Dim FormulaCells As Range, Cell As Range Dim FormulaSheet As Worksheet Dim Row As Integer ' Create a Range object for all formula cells On Error Resume Next Set FormulaCells = Range("A1").SpecialCells(xlFormulas, 23) ' Exit if no formulas are found If FormulaCells Is Nothing Then MsgBox "No Formulas." Exit Sub End If ' Add a new worksheet Application.ScreenUpdating = False Set FormulaSheet = ActiveWorkbook.Worksheets.Add FormulaSheet.Name = "Formulas in " & FormulaCells.Parent.Name ' Set up the column headings With FormulaSheet Range("A1") = "Address" Range("B1") = "Formula" Range("C1") = "Value" Range("A1:C1").Font.Bold = True End With ' Process each formula Row = 2 For Each Cell In FormulaCells Application.StatusBar = Format((Row - 1) / FormulaCells.Count, "0%") With FormulaSheet Cells(Row, 1) = Cell.Address _ (RowAbsolute:=False, ColumnAbsolute:=False) Cells(Row, 2) = " " & Cell.Formula Cells(Row, 3) = Cell.Value Row = Row + 1 End With Next Cell ' Adjust column widths FormulaSheet.Columns("A:C").AutoFit Application.StatusBar = False End Sub Sub Test3() Set VBCodeMod = ThisWorkbook.VBProject.VBComponents(ActiveSheet.Index + 1).CodeModule VBCodeMod.DeleteLines 1, VBCodeMod.CountOfLines End Sub Sub formullerim() Dim R As Integer R=0 Range(Cells(1, 1), Selection.SpecialCells(xlLastCell)).Select For Each Cell In Selection If Left(Cell.Formula, 1) = "=" Then R=R+1 End If Next Cell Selection.SpecialCells(xlFormulas, 23).Select MsgBox "Toplam " & R & " Forml " & _ ActiveSheet.Name & " Adl Sayfada Bulundu" End Sub
Option Explicit Const hedefsahife = "Sayfa1" Sub auto_open() Worksheets(hedefsahife).OnDoubleClick = "pir" End Sub Sub auto_close() Worksheets(hedefsahife).OnDoubleClick = "" End Sub Sub pir() MsgBox "a ha da alt" End Sub Sub sayfaismi() ActiveCell.Value = ActiveSheet.Name End Sub Sub Copy_Sheet() Dim wSht As Worksheet Dim shtName As String shtName = "NewSheet" For Each wSht In Worksheets If wSht.Name = shtName Then MsgBox "Sheet already exists...Make necessary " & _ "corrections and try again." Exit Sub End If Next wSht Sheets(1).Copy before:=Sheets(1) Sheets(1).Name = shtName Sheets(shtName).Move After:=Sheets(Sheets.Count) End Sub Sub A1nomfeuil() Application.ScreenUpdating = False For Each x In ActiveWorkbook.Sheets x.Activate [A1] = ActiveSheet.Name Next End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) If ActiveSheet.Name = "Liste2" Then Cancel = True End If End Sub 'Aktif sayfa ismi Sub ornek() MsgBox "Active Sheet : " & ActiveSheet.Name End Sub Sub TypeSheet() MsgBox "Bu sayfann ad " & ActiveSheet.Name End Sub Sub Enregistre_1_Feuille() ActiveSheet.Copy Application.Dialogs(xlDialogSaveAs).Show 'Active la boite de dialogue Enregistrer sous End Sub Sub sol() Sheets(ActiveSheet.Index - 1).Select End Sub Sub sag() Sheets(ActiveSheet.Index + 1).Select End Sub
Private Sub CommandButton1_Click() Select Case ActiveSheet.Name Case "Sheet1" Makro1 Case "Sheet2" Makro2 Case "Sheet3" Makro3 Case Else Makro4 End Select Unload Me End Sub Sub koru() ActiveSheet.Protect Password:="pir" End Sub Sub koru_ma() ActiveSheet.Unprotect Password:="pir" End Sub Private Sub Worksheet_Change(ByVal Target As Range) On Error Resume Next If IsNumeric(Target) = False Then MsgBox "Valeur numrique obligatoire" Target.Clear Target.Select End If End Sub Sub Add_Sheet() Dim Sayfa As Worksheet Dim SayfaAd As String SayfaAd = Format(Now, "mmmm_yyyy") For Each Sayfa In Worksheets If Sayfa.Name = SayfaAd Then MsgBox "Bu isimde bir sayfa bulunmaktadr." Exit Sub End If Next Sayfa Sheets.Add.Name = SayfaAd Sheets(SayfaAd).Move After:=Sheets(Sheets.Count) Sheets("Sayfa1").Range("A:IV").Copy _ Sheets(SayfaAd).Range("A1") End Sub Sub Mail_ActiveSheet_TXT_File() Dim wb As Workbook Dim strdate As String Dim Fname As String strdate = Format(Now, "dd-mm-yy h-mm-ss") Fname = "C:\Part of " & ThisWorkbook.Name _ & " " & strdate & ".txt" Application.ScreenUpdating = False ActiveSheet.Copy Set wb = ActiveWorkbook With wb .SaveAs Fname, FileFormat:=xlText .SendMail "kubilay_karabulut@hotmail.com", _ "Bu mail excel uzerinden geliyor" .Close False End With Kill Fname Application.ScreenUpdating = True End Sub Sub YeniKitap() Dim Sh As Worksheet Set Sh = ActiveSheet3422 ActiveSheet.Copy ActiveSheet.Name = "YeniSayfa" Sh.Range("A1:Z10").Copy Range("A2") End Sub
Sub EmailSheet() On Error GoTo Terminator Application.Calculation = xlCalculationManual Dim shtName As String shtName = ActiveSheet.Name ActiveSheet.Copy ActiveWorkbook.SaveAs Filename:=Application.GetSaveAsFilename("Kopya " & shtName, "Microsoft Excel File, *.xls") Application.DisplayAlerts = False Application.Dialogs(xlDialogSendMail).Show With ActiveWorkbook .ChangeFileAccess xlReadOnly Kill .FullName .Close False End With Terminator: MsgBox "Dosya gnderilemedi" Application.Calculation = xlCalculationAutomatic End Sub Application.DisplayAlerts = False ActiveSheet.Delete Application.DisplayAlerts = True Private Sub CommandButton7_Click() Range("A1").Select ActiveWindow.SelectedSheets.PrintOut Copies:=1 Range("A1").Select End Sub Sub PrintThisSheet() ActiveSheet.PrintOut End Sub Sub YeniKitap() Dim Sh As Worksheet Set Sh = ActiveSheet ActiveSheet.Copy ActiveSheet.Name = "YeniSayfa" Sh.Range("A1:Z10").Copy Range("A2") End Sub Private Sub CommandButton7_Click() Range("A1").Select ActiveWindow.SelectedSheets.PrintOut Copies:=1 Range("A1").Select End Sub Sub HangiSutun() Dim Let_Col As String Let_Col = Left(Mid(ActiveCell.Address, 2), _ Len(Mid(ActiveCell.Address, 2)) - _ (Len(Mid(Mid(ActiveCell.Address, 2), _ Application.Search("$", Mid(ActiveCell.Address, 2), 1) _ + 1)) + 1)) MsgBox Let_Col End Sub Sub der() Range("A1").Select If Cells(ActiveCell.Row + 1, ActiveCell.Column).Value <> "" Then ActiveCell.End(xlDown).Select End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Dim myVar As Double myVar = Application.Sum(Columns(Target.Column)) If myVar <> 0 Then Application.StatusBar = Format(myVar, "###,###") Else Application.StatusBar = False End If End Sub Sub HangiSutun_2() Lettre_Col = Left(ActiveCell.Address(0, 0), _ (ActiveCell.Column < 27) + 2) MsgBox Lettre_Col End Sub
Sub PrintToAnotherPrinter() Dim strCurrentPrinter As String strCurrentPrinter = Application.ActivePrinter ' store the current active printer On Error Resume Next ' ignore printing errors Application.ActivePrinter = "microsoft fax on fax:" ' change to another printer ActiveSheet.PrintOut ' print the active sheet Application.ActivePrinter = strCurrentPrinter ' change back to the original printer On Error GoTo 0 ' resume normal error handling End Sub Eer birden daha fazla Workbook aksa sadece Active olan Window'u kapatyoruz. Eer tek br window (yani zerinde altmz) aksa tm Excel uygulamasn kapatyoruz. Ak olan pencereleri sayyor ve eer tek bir window aksa Exceli kapatyor. 'Deilse sadece o pencereyi kapatyor. If Application.Windows.Count = 1 Then Application.Quit Else Application.ActiveWindow.Close End If Sub SpreadOut() Dim bossat As Integer, J As Integer bossat = InputBox("Ka satr Olacak?", "Bo Satr Ekle") ActiveCell.Offset(1, 0).Select While ActiveCell.Value > "" And bossat > 0 For J = 1 To bossat Selection.EntireRow.Insert Next J ActiveCell.Offset(bossat + 1, 0).Select Wend End Sub Sub ActivePrinter_() 'Aktif Yazacnz ismini renin MsgBox ActivePrinter End Sub Bu kodlar Windows'un varsaylan yazcsn deitirmez. O an alan programn iindeki aktif yazcy deitirir. Private Sub UserForm_Activate() prnlist MsgBox ("u anki aktif yaziciniz : " & Printer.DeviceName & " ") End Sub Private Sub prnlist() Dim X As Integer For Each X In Printers ListBox1.AddItem X.DeviceName Next End Sub Private Sub ListBox1_Click() Dim X As Printer For Each X In Printers Set Printer = X If Printer.DeviceName = ListBox1.Text Then Exit For End If Next MsgBox ("u anki aktif yaziciniz : " & Printer.DeviceName & " ") End Sub Private Sub Worksheet_Change(ByVal Target As Range) ActiveCell.EntireColumn.AutoFit ActiveCell.EntireRow.AutoFit End Sub Selection.Resize(7,7).Select
Sub Alarm() Dim beepat As String beepat = InputBox("Give Alarm at", "hh:mm:ss " & _ Format(Now, "mm:hh"), "17:00") If beepat = "" Then MsgBox "cancelled" Exit Sub End If Application.OnTime TimeValue(beepat), "BeepMe" End Sub 'Example of a Count Down Timer Sub CountDownTimer() Dim beepat As String beepat = InputBox("Count down Timer hh:mm:ss i.e. 10:00", _ "Time now is " & Format(Now, "hh:mm:ss"), "3:00") If beepat = "" Then MsgBox "cancelled" Exit Sub End If Application.OnTime (Now + TimeValue(beepat)), "BeepMe" End Sub Sub beepme() Beep Application.OnTime (Now + TimeSerial(0, 0, 0.8)), "beepme2" End Sub Sub beepme2() Beep Application.OnTime (Now + TimeSerial(0, 0, 0.8)), "beepme3" End Sub Sub beepme3() Beep End Sub Private Sub CommandButton1_Click() ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Activate Row = ActiveCell.Row + 1 Cells(Row, 1).Activate ActiveCell.Offset(0, 0).Value = TextBox1.Text ActiveCell.Offset(0, 1).Value = TextBox2.Text ActiveCell.Offset(0, 2).Value = TextBox3.Text ActiveCell.Offset(0, 3).Value = TextBox4.Text Range("A3:D3030").Select Selection.Sort Key1:=Range("A3"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Dim i As Integer For i = 0 To GELEN.Controls.Count - 1 If Mid(GELEN.Controls(i).Name, 1, 7) = "TextBox" Then GELEN.Controls(i).Value = "" DoEvents End If Next i End Sub
Application.ScreenUpdating = False 'BU KOD MAKRO ALIINKEN SAYFA HAREKETLERN ENGELLER If TextBox1.Value = "" Then MsgBox ("KAYIT YAPILACAK KNN SMN GRNZ.") Exit Sub Else End If 'BU KOD TEXTBOX1 E KAYIT GRLMEM SE LEM YAPMASINA ZN VERMEZ. Sheets("DATA").Select Range("a2").Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop If Range("a2").Value = "" Then Range("a2").Value = 1 Else ActiveCell.Value = ActiveCell.Offset(-1, 0).Value + 1 End If 'BU KODLAR DATA SAYFASINI SEER,KAYIT OLMAYAN SATIRI BULUR,KAYIDA OTOMATK NUMARA VERR. ActiveCell.Offset(0, 1).Value = TextBox1.Value ActiveCell.Offset(0, 2).Value = TextBox2.Value ActiveCell.Offset(0, 3).Value = TextBox3.Value ActiveCell.Offset(0, 4).Value = TextBox4.Value ActiveCell.Offset(0, 5).Value = TextBox5.Value ActiveCell.Offset(0, 6).Value = TextBox6.Value ActiveCell.Offset(0, 7).Value = TextBox7.Value ActiveCell.Offset(0, 8).Value = TextBox8.Value ActiveCell.Offset(0, 9).Value = TextBox9.Value ActiveCell.Offset(0, 10).Value = TextBox10.Value ActiveCell.Offset(0, 11).Value = TextBox11.Value ActiveCell.Offset(0, 12).Value = TextBox12.Value ActiveCell.Offset(0, 13).Value = TextBox13.Value ActiveCell.Offset(0, 14).Value = TextBox14.Value ActiveCell.Offset(0, 15).Value = TextBox15.Value ActiveCell.Offset(0, 16).Value = TextBox16.Value 'BU KODLAR TEXTBOXDAK BLGLER AYNI SATIRDA,FARKLI SUTUNLARA KAYIT YAPAR TextBox1.Value = "" TextBox2.Value = "" TextBox3.Value = "" TextBox4.Value = "" TextBox5.Value = "" TextBox6.Value = "" TextBox7.Value = "" TextBox8.Value = "" TextBox9.Value = "" TextBox10.Value = "" TextBox11.Value = "" TextBox12.Value = "" TextBox13.Value = "" TextBox14.Value = "" TextBox15.Value = "" TextBox16.Value = "" 'BU KODLAR TEXTBOXLARDAK VERLER SLER MsgBox ("Bilgiler veri tabanna kayt edildi.") 'BU KOD MESAJ VERR. Application.ScreenUpdating = True 'BU KOD SAYFA HAREKETN NORMAL HALE GETRR. End Sub Sub Alt_Klasr_simleri() Dim ds, f, f1, fc, s Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("C:\SXS") Set fc = f.SubFolders For Each f1 In fc s = s & f1.Name s = s & vbCrLf Next MsgBox s End Sub
Sub Alt_Klasr_smi_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.GetParentFolderName("D:\Excelrnekleri\Vergi ade") MsgBox f End Sub Sub Alt_Klasr_smi_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.GetParentFolderName("D:\Excelrnekleri\Vergi ade") MsgBox f End Sub Sub altkl_list() With Application.FileSearch .LookIn = "C:\Windows" 'arama yaplan dizin .SearchSubFolders = True 'alt klasrler aransn m .FileType = msoFileTypeExcelWorkbooks ' aranacak dosya trleri If .Execute() > 0 Then MsgBox .FoundFiles.Count & " adet dosya bulundu." For i = 1 To .FoundFiles.Count Cells(i, 1) = .FoundFiles(i) Next i Else MsgBox "Hi dosya bulunamad.", vbCritica End If End With End Sub Sub DUZEN() For x=1 To 10 For y=1 To 10 Cells(x,y).select ActiveCell.Value = Application.WorksheetFunction.Clean(ActiveCell.Value) ActiveCell.Value = Application.WorksheetFunction.Trim(ActiveCell.Value) Next Next End Sub Sub Dateipfad() Worksheets(1).PageSetup.LeftFooter = ThisWorkbook.FullName End Sub Private Sub Workbook_Open() Dim i As Byte Dim AnaMenAk As Boolean For i = 1 To Workbooks.Count If Workbooks(i).Name = "Anamen.xls" Then AnaMenAk = True Exit Sub Else AnaMenAk = False End If Next If AnaMenAk = False Then MsgBox "Ltfen nce AnaMen.xls dosyasn anz..." ThisWorkbook.Close End If End Sub Worksheets.Add After:=Worksheets("Anasayfa"), Count:=2 Worksheets.Add Before:=Worksheets("Anasayfa")
Sub ShowStars() Randomize StarWidth = 25 StarHeight = 25 For i = 1 To 10 TopPos = Rnd() * (ActiveWindow.UsableHeight - StarHeight) LeftPos = Rnd() * (ActiveWindow.UsableWidth - StarWidth) Set NewStar = ActiveSheet.Shapes.AddShape _ (msoShape4pointStar, LeftPos, TopPos, StarWidth, StarHeight) NewStar.Fill.ForeColor.SchemeColor = Int(Rnd() * 56) Application.Wait Now + TimeValue("00:00:01") DoEvents Next i Application.Wait Now + TimeValue("00:00:02") Set myShapes = Worksheets(1).Shapes For Each shp In myShapes If Left(shp.Name, 9) = "AutoShape" Then shp.Delete Application.Wait Now + TimeValue("00:00:01") End If Next Worksheets(1).Shapes("Message").Visible = True End Sub
Private Declare Function GetEnvironmentVariable Lib "kernel32" _ Alias "GetEnvironmentVariableA" ( _ ByVal lpName As String, _ ByVal lpBuffer As String, _ ByVal nSize As Long) As Long Function GetEnvironmentVar(strEnvName As String) As String GetEnvironmentVar = String(255, 0) GetEnvironmentVariable strEnvName, _ GetEnvironmentVar, _ Len(GetEnvironmentVar) If InStr(1, GetEnvironmentVar, Chr(0)) > 0 Then GetEnvironmentVar = Left(GetEnvironmentVar, _ InStr(1, GetEnvironmentVar, Chr(0)) - 1) End If GetEnvironmentVar = strEnvName & ": " & GetEnvironmentVar End Function Sub GetEnviro() Dim strMsg As String '// Build the string msg strMsg = GetEnvironmentVar("_MACH") strMsg = strMsg & vbCr & GetEnvironmentVar("_TYPE") strMsg = strMsg & vbCr & GetEnvironmentVar("ALLUSERSPROFILE") strMsg = strMsg & vbCr & GetEnvironmentVar("APPDATA") strMsg = strMsg & vbCr & GetEnvironmentVar("CommonProgramFiles") strMsg = strMsg & vbCr & GetEnvironmentVar("COMPUTERNAME") strMsg = strMsg & vbCr & GetEnvironmentVar("ComSpec") strMsg = strMsg & vbCr & GetEnvironmentVar("HOMEDRIVE") strMsg = strMsg & vbCr & GetEnvironmentVar("HOMEPATH") strMsg = strMsg & vbCr & GetEnvironmentVar("HOMESHARE") strMsg = strMsg & vbCr & GetEnvironmentVar("Include") strMsg = strMsg & vbCr & GetEnvironmentVar("Lib") strMsg = strMsg & vbCr & GetEnvironmentVar("LOGONSERVER") strMsg = strMsg & vbCr & GetEnvironmentVar("LOGSERVER") strMsg = strMsg & vbCr & GetEnvironmentVar("NUMBER_OF_PROCESSORS") strMsg = strMsg & vbCr & GetEnvironmentVar("OS") strMsg = strMsg & vbCr & GetEnvironmentVar("Os2LibPath") strMsg = strMsg & vbCr & GetEnvironmentVar("Path") strMsg = strMsg & vbCr & GetEnvironmentVar("PATHEXT") strMsg = strMsg & vbCr & GetEnvironmentVar("PROCESSOR_ARCHITECTURE") strMsg = strMsg & vbCr & GetEnvironmentVar("PROCESSOR_IDENTIFIER") strMsg = strMsg & vbCr & GetEnvironmentVar("PROCESSOR_LEVEL") strMsg = strMsg & vbCr & GetEnvironmentVar("PROCESSOR_REVISION") strMsg = strMsg & vbCr & GetEnvironmentVar("ProgramFiles") strMsg = strMsg & vbCr & GetEnvironmentVar("SMSHOME") strMsg = strMsg & vbCr & GetEnvironmentVar("STARTUPLOG") strMsg = strMsg & vbCr & GetEnvironmentVar("SYBASE") strMsg = strMsg & vbCr & GetEnvironmentVar("SystemDrive") strMsg = strMsg & vbCr & GetEnvironmentVar("SystemRoot") strMsg = strMsg & vbCr & GetEnvironmentVar("TEMP") strMsg = strMsg & vbCr & GetEnvironmentVar("TMP") strMsg = strMsg & vbCr & GetEnvironmentVar("USERDOMAIN") strMsg = strMsg & vbCr & GetEnvironmentVar("USERDOMAIN") strMsg = strMsg & vbCr & GetEnvironmentVar("UserName") strMsg = strMsg & vbCr & GetEnvironmentVar("USERPROFILE") strMsg = strMsg & vbCr & GetEnvironmentVar("windir") MsgBox strMsg, vbInformation, "Envoronmental variables" End Sub
Declare Function ShellExecute Lib "shell32.dll" Alias _ "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _ As String, ByVal lpFile As String, ByVal lpParameters _ As String, ByVal lpDirectory As String, ByVal nShowCmd _ As Long) As Long Sub testRar() Dim Zippeur$, Archive$, Source$ Zippeur = "C:\Program Files\WinRAR\WinRAR.exe" 'Rarlanacak Arivin ad Archive = "D:\ArivinAd" 'Rar'lanacak Dosyann yolu veya Klasr Source = "D:\veri\" ShellExecute 0, "open", Zippeur, _ "a " & Archive & " " & Source, "", vbHide For i = 1 To 10: DoEvents: Next End Sub Size Bu rnek Fikir verebilir.Kendi almanza derlersiniz. A1 Hcresine stediiniz zaman atarsnz.Tabii A1 Hcresini ss:dd:nn biimlendirmeniz gerek. Kod: Sub basla() Application.OnTime Now + [a1], procedure:="Mesaj" End Sub Sub Mesaj() MsgBox "deneme" End Sub Sub SearchText() Dim SearchString, SearchChar, MyPos SearchChar = "salut" For Each cell In Range("A1:A11") SearchString = cell.Text MyPos = InStr(SearchString, SearchChar) If MyPos > 0 Then MsgBox ("Mot trouv") MsgBox "Mot trouv cette adresse: " & cell.Address cell(1, 2).Value = "(salut) est sur cette ligne" End If Next End Sub Sub arabul() ara = Application.InputBox(prompt:="Aranacak Veri?", Type:=3) Range("A3:A341").Select Selection.Find(What:=ara, After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate satir = ActiveCell.Row Range(Cells(satir, 2), Cells(satir, 8)).Select Selection.Copy Sheets("Sayfa1").Select Range("A2").Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=True End Sub
Sub Asteriks() Dim i As Integer Dim j As Integer Dim Sayac As Integer Dim SinananVeri As String Veri = InputBox("Aranan Veriyi Belirtiniz", "ARANAN VER", "") SinananVeri = "*" & Veri & "*" Set Say1 = Worksheets("Sayfa1") Set Say2 = Worksheets("Sayfa2") j=1 For i = 1 To 10 If WorksheetFunction.CountIf(Say2.Cells(i, 1), SinananVeri) > 0 Then Say1.Cells(j, 1) = Say2.Cells(i, 1) Sayac = Sayac + 1 j=j+1 End If Next i MsgBox Say2.Name & "'de aram olduunuz " & Veri & " verisini ieren toplam " & Sayac & " adet hcre deeri bulundu ve " & Say1.Name & "'de liste End Sub Private Sub CommandButton1_Click() Dim FirstMatch As String, strVal As String, MyMsg As String Dim MyData As Variant If Len(TextBox1) >= 1 Then Set MyData = Columns("C").Find(TextBox1) If Not MyData Is Nothing Then FirstMatch = MyData.Address Do strVal = strVal & MyData.Address(False, False) & vbCrLf Set MyData = Columns("C").FindNext(MyData) Loop While Not MyData Is Nothing And MyData.Address <> FirstMatch End If Else MsgBox "Aranlacak deeri girin..." Exit Sub End If If strVal = Empty Then strVal = "Bulunamad...." MyMsg = "Aranlan deer " & TextBox1 & " nn bulunduu hcreler:" _ & vbCrLf & String(35, "*") MsgBox MyMsg & vbCrLf & strVal Set MyData = Nothing End Sub
Option Compare Text Sub Check_Values_1() On Error Resume Next Dim CurCell As Range Dim Heading As String Dim Prompt As String Dim Criteria As Variant Dim Color As Long Dim lRows As Long Dim lCols As Long Dim lAllCells As Long lRows = ActiveSheet.Rows.Count lCols = ActiveSheet.Columns.Count lAllCells = lRows * lCols If Selection.Cells.Count = lAllCells Then MsgBox "To check the entire sheet, please select only one cell", 64 Exit Sub End If Heading = "Enter Criteria" Prompt = "Enter the value you want to find and highlight." Color = 3 Criteria = InputBox(Prompt, Heading) If Criteria = "" Then Exit Sub ElseIf IsNumeric(Criteria) Then Criteria = CLng(Criteria) ElseIf IsDate(Criteria) Then Criteria = CDate(Criteria) Else Criteria = CStr(Criteria) End If If Selection.Cells.Count > 1 Then For Each CurCell In Selection If CurCell.Value = Criteria Then CurCell.Interior.ColorIndex = Color Next CurCell Else For Each CurCell In ActiveSheet.UsedRange If CurCell.Value = Criteria Then CurCell.Interior.ColorIndex = Color Next CurCell End If End Sub Sub Check_Values_2() Dim CurCell As Range For Each CurCell In Range("A1:A10") If CurCell.Value = 10 Then CurCell.Value = 21 Next End Sub UserForma Bir TextBox1 ve CommandButton1 ekliyerek aadaki kodlar CommandButtonu clikliyerek aacanz kod sayfasna yazn. Private Sub CommandButton1_Click() Dim i As Byte If Len(TextBox1) > 0 Then For i = 1 To Worksheets.Count Call Myxxrt(Worksheets(i).Name) Next End If End Sub Private Function Myxxrt(ShName As String) Dim MyRng As Range On Error Resume Next Set MyRng = Range(Sheets(ShName).Cells.Find(TextBox1, LookAt:=xlWhole).Address) MsgBox "Aranlan deer " & ShName & " sayfasnda " & MyRng.Address(False, False) & " hcresinde bulundu !" Set MyRng = Nothing End Function
Sub Creation_barre_outil() Application.ScreenUpdating = False Toolbars.Add Name:="Outils NewGam" Toolbars("Outils NewGam").Visible = True Set BarOutil = Toolbars("Outils NewGam").ToolbarButtons BarOutil.Add Button:=214, Before:=1, OnAction:="Action0",Enabled:=True,Pushed:=False BarOutil(1).Name = "Interface" Set BarOutil = Toolbars("Outils NewGam").ToolbarButtons BarOutil.Add Button:=211, Before:=1, OnAction:="Action1", Enabled:=True,Pushed:=False BarOutil(1).Name = "CreTarifCatalogue" Set BarOutil = Toolbars("Outils NewGam").ToolbarButtons BarOutil.Add Button:=213, Before:=1, OnAction:="Action2", Enabled:=True, Pushed:=False BarOutil(1).Name = "CreeTarifExport" Set BarOutil = Nothing 'Positionnement de la barre d'outils With Toolbars("Outils NewGam") .Left = 620 .Top = 450 .Width = 120 End With End Sub Sub Action0() Range("a1").Formula = "Commande Action0" End Sub Sub Action1() Range("a2").Formula = "Commande Action1" End Sub Sub Action2() Range("a3").Formula = "Commande Action2" End Sub Sub SupprimeBarOutil() On Error Resume Next Toolbars("Outils NewGam").Delete End Sub
Eigene_Symbolleiste_erzeugen End Sub Sub Eigene_Symbolleiste_erzeugen() Toolbars.Add Name:="Eigene_Symbolleiste" Toolbars("Eigene_Symbolleiste").Visible = True With Application .ShowToolTips = True: .LargeButtons = False: .ColorButtons = True End With With Toolbars("Eigene_Symbolleiste") .ToolbarButtons.Add Button:=211, Before:=1 .ToolbarButtons(1).OnAction = "Dieser_Befehl_wird_bei_Klick_ausgefhrt" .ToolbarButtons(1).Name = ("Dieser Text erscheint als Quickinfotext, wenn die Maus an das Symbol gehalten wird") .Position = xlTop .Left = -1 .Top = -1 End With End Sub Sub Dieser_Befehl_wird_bei_Klick_ausgefhrt() MsgBox "Diese Meldungsbox ist der Befehl, der bei Klick auf das Symbol ausgefhrt wird.", vbOKOnly + vbInformation, "Funktion dieses Symbols" End Sub Sub Eigene_Symbolleiste_lschen() Dim Sym As Toolbar Toolbars("Eigene_Symbolleiste").Delete For Each Sym In Toolbars If Sym.Visible = True Then Sym.Left = 1 Next Sym End Sub Sub Auto_close() Eigene_Symbolleiste_lschen End Sub Sub toolres() For Each tb In Application.Toolbars tb.Reset Next tb End Sub
Dim CmdB As CommandBar Dim Ctl As CommandBarControl, nCtlC As CommandBarComboBox For Each Ctl In Application.CommandBars("Worksheet Menu Bar") _ .Controls If Ctl.Type = msoControlComboBox And _ Ctl.Caption = "Symbolleistenauswahl" Then Ctl.Delete End If Next Ctl With Application.CommandBars("Worksheet Menu Bar") Set nCtlC = .Controls.Add(Type:=msoControlComboBox, _ Before:=.Controls.Count, Temporary:=True) End With With nCtlC .Caption = "Symbolleistenauswahl" .OnAction = "Me_007_Visible" For Each CmdB In Application.CommandBars If CmdB.Type = msoBarTypeNormal Then .AddItem CmdB.NameLocal End If Next CmdB .DropDownLines = 20 .Width = 150 .ListIndex = 1 End With End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Call Me_007_Delete End Sub Public Sub Me_007_Visible() Dim CmdB As CommandBar Dim CtlC As CommandBarComboBox Dim CmdBName As String 'Dim CmdBName$ Set CtlC = Application.CommandBars("Worksheet Menu Bar") _ .Controls("Symbolleistenauswahl") CmdBName = CtlC.List(CtlC.ListIndex) For Each CmdB In Application.CommandBars If CmdB.Type = msoBarTypeNormal And _ CmdB.NameLocal = CmdBName Then CmdB.Visible = True Exit Sub End If Next CmdB MsgBox "Die Symbolleiste '" & CmdBName & "' existiert" & _ " nicht!", _ vbInformation, "Code-Beispiel (Me_007)" End Sub Public Sub Me_007_Delete() On Error Resume Next Application.CommandBars("Worksheet Menu Bar") _ .Controls("Symbolleistenauswahl").Delete On Error GoTo 0 End Sub Sub Gorunum_Arac_Cubuklari_Reset() Dim Cmbr As CommandBar For Each Cmbr In Application.CommandBars On Error Resume Next Cmbr.Reset Next Cmbr End Sub 'Aadaki kodlar da kullanlabilir: Application.CommandBars.FindControl(ID:=847).Enabled = True Application.CommandBars.FindControl(ID:=889).Enabled = True Sub toolbar_disable() For Each tb In Toolbars tb.Visible = False 'true geri getirir Next tb End Sub
Sub auto_open() Application.ScreenUpdating = False For i = 1 To Application.CommandBars.Count Application.CommandBars(i).Enabled = False Next i Application.ScreenUpdating = True End Sub Sub auto_close() Application.ScreenUpdating = False For i = 1 To Application.CommandBars.Count Application.CommandBars(i).Enabled = 1 Next i Application.ScreenUpdating = True End Sub Private VisibleCmdBs As New Collection Private Sub Workbook_Open() Dim CmdB As CommandBar For Each CmdB In Application.CommandBars If CmdB.Type = msoBarTypeNormal And CmdB.Visible = True Then VisibleCmdBs.Add CmdB, CmdB.Name CmdB.Visible = False End If Next CmdB End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim CmdB As Object For Each CmdB In VisibleCmdBs CmdB.Visible = True Next CmdB Set VisibleCmdBs = Nothing End Sub Sub Auto_Open() Application.CommandBars.FindControl(ID:=30007).Enabled = False End Sub Sub Auto_Close() Application.CommandBars.FindControl(ID:=30007).Enabled = True End Sub Sub AraclarMenusuneMaddeEkle() With Application.CommandBars("Tools").Controls.Add(msoControlButton) .Caption = "Yeni Men" .OnAction = "Goster" .FaceId = 343 End With End Sub Sub YeniMenuKaldir() CommandBars("Tools").Controls("Yeni Men").Delete End Sub Sub Goster() Dim Msg, Style, Title Msg = "Yeni men maddesi" Style = vbYes Title = "Yeni Men" Response = MsgBox(Msg, Style, Title) End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim objPopUp As CommandBarPopup Set objPopUp = Application.CommandBars("Worksheet Menu Bar").FindControl(ID:=30007) On Error Resume Next objPopUp.Controls("Calculating").Delete On Error GoTo 0 End Sub Private Sub Workbook_Open() Dim objPopUpA As CommandBarPopup Dim objPopUpB As CommandBarPopup Dim objButton As CommandBarButton Set objPopUpA = Application.CommandBars("Worksheet Menu Bar").FindControl(ID:=30007) On Error Resume Next objPopUpA.Controls("Calculating").Delete On Error GoTo 0 Set objPopUpB = objPopUpA.Controls.Add(msoControlPopup) With objPopUpB .Caption = "Calculating" .BeginGroup = True End With Set objButton = objPopUpB.Controls.Add With objButton .Caption = "Create Data" .OnAction = "ApplyData" End With Set objButton = objPopUpB.Controls.Add With objButton .Caption = "Cbm calculate" .OnAction = "CalculateCbm" End With Set objButton = objPopUpB.Controls.Add With objButton .Caption = "Qm Calculate" .OnAction = "CalculateQm" End With objPopUpB.Visible = True End Sub 'Aadaki kodlar standart modle kopyala Sub ApplyData() Dim dblFactor As Double Dim intRow As Integer, intCol As Integer dblFactor = 1 Range("A1") = "Length" Range("B1") = "Spreads" Range("C1") = "Height" Range("D1") = "Cbm" Range("E1") = "qmAfl" Rows(1).Font.Bold = True For intRow = 2 To 10 For intCol = 1 To 3 Cells(intRow, intCol) = 1.1 + dblFactor dblFactor = dblFactor + dblFactor * 0.1 Next intCol Next intRow Columns("A:C").NumberFormat = "#,##0.00" Columns("D").NumberFormat = "#,##0.000" Columns("E").NumberFormat = "#,##0.00" Columns("A:E").HorizontalAlignment = xlRight End Sub Sub CalculateCbm() Dim intRow As Integer For intRow = 2 To 10 Cells(intRow, 4).FormulaR1C1 = "=RC[-3]*RC[-2]*RC[-1]" Next intRow End Sub Sub CalculateQm() Dim intRow As Integer For intRow = 2 To 10 Cells(intRow, 5).FormulaR1C1 = _ "=2*(RC[-3]*RC[-2]+RC[-3]*RC[-1]+RC[-2]*RC[-1])" Next intRow End Sub
Application.ScreenUpdating = False For i = 1 To Cells(65536, 1).End(xlUp).Row If Trim(Cells(i, 1)) <> "" And Trim(Cells(i, 1)) <> "m.cinsi" Then Range(i & ":" & i).EntireRow.Copy Sheets("sayfa2").Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues End If Next i Application.ScreenUpdating = True
edit : yukardaki rnekteki gibi aplication 'un screenupdate'i daha sonra kullanlmayacaksa, true yapmak mantkszdr. i bittiinde zaten otomatik olarak tr sen neden yaptn derseniz, alkanlk. Application.ScreenUpdating = False For i = 1 To Cells(65536, 1).End(xlUp).Row If Trim(Cells(i, 1)) <> "" And Trim(Cells(i, 1)) <> "m.cinsi" Then Range(i & ":" & i).EntireRow.Copy Sheets("sayfa2").Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues End If Next i Application.ScreenUpdating = True
edit : yukardaki rnekteki gibi aplication 'un screenupdate'i daha sonra kullanlmayacaksa, true yapmak mantkszdr. i bittiinde zaten otomatik olarak tr sen neden yaptn derseniz, alkanlk. Sub bul() On Error GoTo 10 aranan = InputBox("erii girtiniz", "Arama Yap", " ") cells.Find(aranan).Select Exit Sub 10 MsgBox "Aranan veri bulunamad." End Sub Sub sil() For i = 1 To Range("A65536").End(xlUp).Row If Cells(i, 1) = "Sunta" Then Rows(i).Delete End If Next End Sub Sub Bul_Adres() Find = InputBox("Aranan deer?", "pir") On Error GoTo yok bul = Cells.Find(Find).Address MsgBox bul, vbInformation, "Aradnz kaydn bulunduu hcre:" Exit Sub yok: MsgBox "Kayt bulunamad", vbCritical End Sub
Sub FindItAll() Dim oSheet As Object Dim Firstcell As Range Dim NextCell As Range Dim WhatToFind As Variant WhatToFind = Application.InputBox("What are you looking for ?", "Search", , 100, 100, , , 2) If WhatToFind <> "" And Not WhatToFind = False Then For Each oSheet In ActiveWorkbook.Worksheets oSheet.Activate oSheet.[a1].Activate Set Firstcell = Cells.Find(What:=WhatToFind, LookIn:=xlValues, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) If Not Firstcell Is Nothing Then Firstcell.Activate MsgBox ("Found " & Chr(34) & WhatToFind & Chr(34) & " in " & oSheet.Name & "!" & Firstcell.Address) On Error Resume Next While (Not NextCell Is Nothing) And (Not NextCell.Address = Firstcell.Address) Set NextCell = Cells.FindNext(After:=ActiveCell) If Not NextCell.Address = Firstcell.Address Then NextCell.Activate MsgBox ("Found " & Chr(34) & WhatToFind & Chr(34) & " in " & oSheet.Name & "!" & NextCell.Address) End If Wend End If Set NextCell = Nothing Set Firstcell = Nothing Next oSheet End If End Sub Private Sub TextBox9_Change() [a1] = Replace(TextBox9, Chr(13), "") End Sub Function RengeGoreTopla(Aralik As Range, Renk As Range) As Double Dim Cell As Range, TempSum As Double, ColorIndex As Integer ColorIndex = Renk.Cells(1, 1).Interior.ColorIndex TempSum = 0 On Error Resume Next For Each Cell In Aralik.Cells If Cell.Formula <> "" Then If Cell.Interior.ColorIndex = ColorIndex Then TempSum = TempSum + Cell.Value End If End If Next Cell On Error GoTo 0 Set Cell = Nothing RengeGoreTopla = TempSum End Function
'Make cell range Background color, flash x times, x fast, in x color, 'when Ctrl-a is pressed. Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed 'Make this cell range background flash! Set myCell = Range("A1:M8") Application.DisplayStatusBar = True Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! " 'Make cell background flash to this color! 'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30, 'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11, 'Gray-50% 16, Gray-25% 15, Bright Cyan 8. newColor = 11 'Make the cell range flash fast: 0.01 to slow: 0.99 fSpeed = 0.2 'Make cell flash, this many times! Do Until x = 2 'Run loop! DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = xlNone Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub
A1:D20 hcreleri arasndaki arka plan rengi krmz olan hcreleri toplar. D21 veya A1:D20 hcreleri dnda bir hcreye =SumIfColours(3;$A$1:$D$20) fo Function SumIfColours(cellTextColour As Integer, _ Range1, ParamArray Range2()) As Double Dim objCell As Range ' Best to use this even if it does slow Excel down somewhat. Application.Volatile ' Initialise. SumIfColours = 0 ' Process first argument. ' Restrict the range to stop the loop looking ' at huge swathes of empty cells. For Each objCell In Intersect(Range1, _ Range1.Parent.UsedRange) If Application.IsNumber(objCell.Value) And _ objCell.Interior.ColorIndex = cellTextColour Then _ SumIfColours = SumIfColours + objCell.Value Next objCell ' Process additional arguments (if any) If UBound(Range2) <> 0 Then For intArgument = 1 To UBound(Range2) For Each objCell In Intersect(Range2(intArgument), _ Range2(intArgument).Parent.UsedRange) If Application.IsNumber(objCell.Value) And _ objCell.Interior.ColorIndex = cellTextColour Then _ SumIfColours = SumIfColours + objCell.Value Next objCell Next intArgument End If End Function Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" ( _ ByVal uAction As Long, _ ByVal uParam As Long, _ ByVal lpvParam As Any, _ ByVal fuWinIni As Long) As Long ' Const SPI_SETDESKWALLPAPER = 20 Const SPIF_UPDATEINIFILE = &H1 Const MyPic = "C:\muhtelif\resim1.bmp" ' Sub Test() SystemParametersInfo SPI_SETDESKWALLPAPER, ByVal 0&, MyPic, SPIF_UPDATEINIFILE End Sub 'none yapmak iin .... Const SPI_SETDESKWALLPAPER = 20 Const SPIF_UPDATEINIFILE = &H1 Const MyPic = ""
Sub AsalSayKontrolu() Y=0 Range("b9") = "" A = Range("b2") For T = 0 To 8 Step 2 If Right(A, 1) = "" & T & "" Then '0" Or Right(A, 1) = "2" Or Right(A, 1) = "4" Or Right(A, 1) = "5" Or Right(A, 1) = "6" Or Right(A, 1) = "8" Then Y=1 GoTo 22 End If Next If Right(A, 1) = "5" Then Y=1 GoTo 22 End If For T = 3 To Int(A / 2) + 1 Step 2 Range("c2") = T Range("c3") = Range("b2") / Range("c2") If Right(T, 1) = 5 Then GoTo 12 If Int(A / T) * T = A Then Y=1 T = Int(A / 2) + 1 End If 12 Next 22 If Y = 0 Then Range("c2") = "" Range("c3") = "" Range("b9").Select Range("B9") = "Yazlan Say a s a l s a y d r * * *" Else Range("B9") = "Yazlan Say Asal Deildir" End If End Sub Sub myScrollDown() ActiveWindow.SmallScroll Down:=1 ActiveWindow.ActivateNext ActiveWindow.SmallScroll Down:=1 ActiveWindow.ActivatePrevious End Sub Sub myScrollUp() ActiveWindow.SmallScroll Up:=1 ActiveWindow.ActivateNext ActiveWindow.SmallScroll Up:=1 ActiveWindow.ActivatePrevious End Sub Sub Down() ActiveCell.Offset(1, 0).Select End Sub Sub up() ActiveCell.Offset(-1, 0).Select End Sub Sub Right() ActiveCell.Offset(0, 1).Select End Sub Sub Left() ActiveCell.Offset(0, -1).Select End Sub Sub Dme1_Tklat() e = Application.CountA(Range("A:A")) Cells(e, 1).Select Selection.Delete Shift:=xlUp End Sub Sub PanZehir() CommandBars("Cell").Reset End Sub Public Sub CopyDown() LastRow = Range("A65536").End(xlUp).Row For i = 1 To LastRow If Range("A" & i).Value = "" Then Range("A" & i - 1 & ":CB" & i - 1).Copy Destination:=Range("A" & i) End If Next i End Sub
Sub Add_Sheet() Dim Sayfa As Worksheet Dim SayfaAd As String SayfaAd = Format(Now, "mmmm_yyyy") For Each Sayfa In Worksheets If Sayfa.Name = SayfaAd Then MsgBox "Bu isimde bir sayfa bulunmaktadr." Exit Sub End If Next Sayfa Sheets.Add.Name = SayfaAd Sheets(SayfaAd).Move After:=Sheets(Sheets.Count) Sheets("Sayfa1").Range("A:IV").Copy _ Sheets(SayfaAd).Range("A1") End Sub Sub Add_Sheet() Dim Sayfa As Worksheet Dim SayfaAd As String SayfaAd = Format(Now, "mmmm_yyyy") For Each Sayfa In Worksheets If Sayfa.Name = SayfaAd Then MsgBox "Bu isimde bir sayfa bulunmaktadr." Exit Sub End If Next Sayfa Sheets.Add.Name = SayfaAd Sheets(SayfaAd).Move After:=Sheets(Sheets.Count) Sheets("Sayfa1").Range("A:IV").Copy _ Sheets(SayfaAd).Range("A1") End Sub Sub NomFeuilMois() For I = 1 To 12 ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count) ActiveSheet.Name = Format(30 * I, "mmmm") Next I End Sub Function AyCevir(deger As Byte) AyCevir = Choose(deger, "Ocak", "ubat", "Mart", "Nisan", "Mays", "Haziran", _ "Temmuz", "Austos", "Eyll", "Ekim", "Kasm", "Aralk") End Function 'kullanl 'A1= 1 ve B1=aycevir(A1) 'A2=01.02.2007 ve B1=aycevir(AY(A2)) Sub AyYilSuz() Dim rng As Range, sor As String SuzIptal sor = Application.InputBox("szmek istediiniz tarih", _ Application.UserName, Format(Month(Date) - 1, "00") & Chr(47) & Year(Date), , , , , 2) Application.ScreenUpdating = False For Each rng In Range("A2:A" & Range("A65536").End(xlUp).Row) If Format(Month(rng), "00") & Chr(47) & Year(rng) <> sor Then rng.Rows.Hidden = True Next rng Application.ScreenUpdating = True End Sub Sub SuzIptal() Range("A:A").Rows.Hidden = False End Sub
Dim J As Integer Dim K As Integer Dim sDay As String Dim sTemp As String Dim iTarget As Integer Dim dBasis As Date iTarget = 13 While (iTarget < 1) Or (iTarget > 12) iTarget = Val(InputBox("Numeric month?")) If iTarget = 0 Then Exit Sub Wend Application.ScreenUpdating = False sTemp = Str(iTarget) & "/1/" & Year(Now()) dBasis = CDate(sTemp) For J = 1 To 31 sDay = Format((dBasis + J - 1), "dddd mm-dd-yyyy") If Month(dBasis + J - 1) = iTarget Then If J <= Sheets.Count Then If Left(Sheets(J).Name, 5) = "Sheet" Then Sheets(J).Name = sDay Else Sheets.Add.Move after:=Sheets(Sheets.Count) ActiveSheet.Name = sDay End If Else Sheets.Add.Move after:=Sheets(Sheets.Count) ActiveSheet.Name = sDay End If End If Next J For J = 1 To (Sheets.Count - 1) For K = J + 1 To Sheets.Count If Right(Sheets(J).Name, 10) > _ Right(Sheets(K).Name, 10) Then Sheets(K).Move Before:=Sheets(J) End If Next K Next J Sheets(1).Activate Application.ScreenUpdating = True End Sub Private Sub CommandButton1_Click() Cells([C65536].End(3).Row + 1, "C") = TextBox3 TextBox1 = "" TextBox2 = "" TextBox3 = "" UserForm_Initialize End Sub Private Sub UserForm_Initialize() SON = [C65536].End(3).Row + 1 TextBox1 = Cells(SON, "A") TextBox2 = Cells(SON, "B") TextBox3.SetFocus End Sub
sub songun() Dim MyDate as Date ActiveCell.Value = DateSerial(Year(Now), Month(Now) + 1, 0) End Sub 'tarih imdiki zaman hesaplama Sub ss1() 'As constants the following will not update [a1] = Int(Now) 'date [a2] = Now 'date and time [a3] = Date 'date [a4] = Date + Time 'same as now 'As Worksheet Functions the following will update [a5] = "=Today()" 'current date into worksheet formula [a6] = "=now()" 'current date [a7] = "=now() - Today()" 'current time when recalculated [a7].NumberFormat = "hh:mm" [a8] = "=MOD(NOW(),1)" 'current time when recalculated [a8].NumberFormat = "hh:mm" End Sub Dim J As Integer Dim K As Integer Dim sMo(12) As String sMo(1) = "January" sMo(2) = "February" sMo(3) = "March" sMo(4) = "April" sMo(5) = "May" sMo(6) = "June" sMo(7) = "July" sMo(8) = "August" sMo(9) = "September" sMo(10) = "October" sMo(11) = "November" sMo(12) = "December" For J = 1 To 12 If J <= Sheets.Count Then If Left(Sheets(J).Name, 5) = "Sheet" Then Sheets(J).Name = sMo(J) Else Sheets.Add.Move after:=Sheets(Sheets.Count) ActiveSheet.Name = sMo(J) End If Else Sheets.Add.Move after:=Sheets(Sheets.Count) ActiveSheet.Name = sMo(J) End If Next J For J = 1 To 12 If Sheets(J).Name <> sMo(J) Then For K = J + 1 To Sheets.Count If Sheets(K).Name = sMo(J) Then Sheets(K).Move Before:=Sheets(J) End If Next K End If Next J Sheets(1).Activate End Sub
Option Explicit Sub CreateMonths() Dim lDay As Long Dim iWks As Integer, iDay As Integer For iWks = 1 To 12 Worksheets.Add after:=Worksheets(Worksheets.Count) ActiveSheet.Name = Format(DateSerial(1, iWks, 1), "mmmm") For lDay = DateSerial(Year(Date), iWks, 1) To DateSerial(Year(Date), iWks + 1, 0) iDay = iDay + 1 Cells(iDay, 1).Value = DateSerial(Year(Date), iWks, iDay) Next lDay iDay = 0 Next iWks Worksheets(1).Select End Sub Sub GotoToDay() Dim iRow As Integer Worksheets(Month(Date) + 1).Select iRow = WorksheetFunction.Match(CDbl(Date), Columns(1), 0) Cells(iRow, 1).Select End Sub 'Kodun altrlaca aktif sayfaya Option Explicit
End With 'Feiertage eintragen und formatieren WS.Cells(x + 7, 2) = FeiertagCH(WS.Cells(x + 7, 1)) If WS.Cells(x + 7, 2) <> "" Then If Right(WS.Cells(x + 7, 2), 1) = "*" And _ WS.Cells(x + 7, 2).Interior.ColorIndex = xlNone Then Range(WS.Cells(x + 7, 1), WS.Cells(x + 7, 3)).Interior.ColorIndex = 15 Else Range(WS.Cells(x + 7, 1), WS.Cells(x + 7, 5)).Interior.ColorIndex = 48 End If End If End If Next x Next i With Worksheets(13) .Name = "bersicht" .PageSetup.Orientation = xlLandscape With .Columns("A:F") .ColumnWidth = 19.5 ' weitere Formatierungen der Spalten End With For i = 1 To 6 .Cells(2, i) = Format(DateSerial(0, i, 1), "MMMM") .Cells(20, i) = Format(DateSerial(0, i + 6, 1), "MMMM") Range(.Cells(2, i), .Cells(19, i)).BorderAround ColorIndex:=0, Weight:=xlThin Range(.Cells(20, i), .Cells(38, i)).BorderAround ColorIndex:=0, Weight:=xlThin Next i End With End Sub Function FeiertagCH(datum As Date) Dim J As Integer Dim O As Date Dim D As Integer J = Year(datum) D = (((255 - 11 * (J Mod 19)) - 21) Mod 30) + 21 O = DateSerial(J, 3, 1) + D + (D > 48) + 6 - _ ((J + J \ 4 + D + (D > 48) + 1) Mod 7) Select Case datum Case Is = DateSerial(J, 1, 1) FeiertagCH = "Neujahr" Case Is = DateSerial(J, 1, 2) FeiertagCH = "Berchtoldstag*" Case Is = DateSerial(J, 3, 3) FeiertagCH = "Josefstag*" Case Is = DateAdd("D", -2, O) FeiertagCH = "Karfreitag" Case Is = O FeiertagCH = "Ostersonntag" Case Is = DateAdd("D", 1, O) FeiertagCH = "Ostermontag*" Case Is = DateSerial(J, 5, 1) FeiertagCH = "Maifeiertag*" Case Is = DateAdd("D", 39, O) FeiertagCH = "Auffahrt, Christi Himmelfahrt" Case Is = DateAdd("D", 49, O) FeiertagCH = "Pfingstsonntag" Case Is = DateAdd("D", 50, O) FeiertagCH = "Pfingstmontag" Case Is = DateAdd("D", 60, O) FeiertagCH = "Fronleichnam*" Case Is = DateSerial(J, 8, 1) FeiertagCH = "Bundesfeier" Case Is = DateSerial(J, 8, 15) FeiertagCH = "Mariae Himmelfahrt*" Case Is = DateSerial(J, 11, 1) FeiertagCH = "Allerheiligen*" Case Is = DateSerial(J, 12, 8) FeiertagCH = "Mariae Empfngnis*" Case Is = DateSerial(J, 12, 24) FeiertagCH = "Heilig Abend*" Case Is = DateSerial(J, 12, 25) FeiertagCH = "Weihnachtsfeiertag" Case Is = DateSerial(J, 12, 26) FeiertagCH = "Stefanstag" Case Is = DateSerial(J, 12, 31) FeiertagCH = "Silvester*" Case Else FeiertagCH = ""
Sub CreateMonths() Dim lDay As Long Dim iWks As Integer, iDay As Integer For iWks = 1 To 12 Worksheets.Add after:=Worksheets(Worksheets.Count) ActiveSheet.Name = Format(DateSerial(1, iWks, 1), "mmmm") For lDay = DateSerial(Year(Date), iWks, 1) To DateSerial(Year(Date), iWks + 1, 0) iDay = iDay + 1 Cells(iDay, 1).Value = DateSerial(Year(Date), iWks, iDay) Next lDay iDay = 0 Next iWks Worksheets(1).Select End Sub Sub GotoToDay() Dim iRow As Integer Worksheets(Month(Date) + 1).Select iRow = WorksheetFunction.Match(CDbl(Date), Columns(1), 0) Cells(iRow, 1).Select End Sub Private Sub UserForm_Initialize() UserForm1.StartUpPosition = 0 UserForm1.Top = 10 UserForm1.Left = 10 End Sub Worksheets("Kedi2").Copy Before:=Worksheets("Kedi5") Sub als_text_speichern() Dim iRow As Long, strDatei As String, iLastRow As Integer iLastRow = Sheets(1).Cells(65536, 1).End(xlUp).Row strDatei = ThisWorkbook.Path & "\test1.txt" Open strDatei For Output As #1 For iRow = 1 To iLastRow Print #1, Format(Cells(iRow, 1), "#0.00"); Chr(9); Print #1, Format(Cells(iRow, 2), "YYYYMMDD"); Chr(9); Print #1, Cells(iRow, 3) Next iRow Close #1 End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Cells.Address <> "$A$2" Then Exit Sub If [b1] = Empty Then [b1] = "=" If IsNumeric([a1]) And [a1] <> 0 Then [b1].Formula = [b1].Formula & "+" & [a1] End Sub
Dim i As Integer Sheets("Sayfa1").Select '*** nce textoxlar kontrol edelim If txtadet.Value = "" Or txtkilo.Value = "" Or txtfiyat.Value = "" Then MsgBox "Eksik tamlama yapmsnz!" Exit Sub End If '**** imdi de ayn fiyattan varm diye bakalm '**** varsa zerine toplayalm '**** yoksa alttaki bo satra gidelim For i = 1 To 18 If txtfiyat.Value * 1 = Cells(i, 3) Then Cells(i, 1) = Cells(i, 1) + txtadet.Value Cells(i, 2) = Cells(i, 2) + txtkilo.Value Cells(i, 3) = Cells(i, 3) GoTo AtlaSona Else If Cells(i, 3).Value = "" Then Cells(i, 1) = txtadet.Value Cells(i, 2) = txtkilo.Value Cells(i, 3) = txtfiyat.Value GoTo AtlaSona End If End If Next i MsgBox "18 satrnz da dolmu" Exit Sub AtlaSona: txtadet.Value = "" txtkilo.Value = "" txtfiyat.Value = "" MsgBox "Kaydedildi" txtadet.SetFocus End Sub For x = 2 To Cells(65536, 3).End(xlUp).Row If WorksheetFunction.CountIf(Range("c2:c" & x), Cells(x, 3)) = 1 Then ComboBox1.AddItem Cells(x, 3).Value End If Next
Dim i As Integer Sheets("Sayfa1").Select '*** nce textoxlar kontrol edelim If txtadet.Value = "" Or txtkilo.Value = "" Or txtfiyat.Value = "" Then MsgBox "Eksik tamlama yapmsnz!" Exit Sub End If Dim j As Integer, k As Integer j=1 k=3 BASADONELIM: '**** imdi de ayn fiyattan varm diye bakalm '**** varsa zerine toplayalm '**** yoksa alttaki bo satra gidelim For i = k To k + 15 If txtfiyat.Value * 1 = Cells(i, j + 2) Then Cells(i, j) = Cells(i, j) + txtadet.Value Cells(i, j + 1) = Cells(i, j + 1) + txtkilo.Value Cells(i, j + 2) = Cells(i, j + 2) GoTo AtlaSona Else If Cells(i, j + 2).Value = "" Then Cells(i, j) = txtadet.Value Cells(i, j + 1) = txtkilo.Value Cells(i, j + 2) = txtfiyat.Value GoTo AtlaSona End If End If Next i If i = k + 16 And j < 16 Then '18satr dolu ve son stunlar bo ise j = j + 5 'A-F-K-P eklinde 1 den balayp 5er 5er ilerledik GoTo BASADONELIM Else If k < 72 And j = 16 Then j=1 k = k + 23 GoTo BASADONELIM Else If k = 72 And j = 16 Then j=1 k = 120 GoTo BASADONELIM Else If k < 166 And j = 16 Then j=1 k = k + 23 GoTo BASADONELIM Else If k = 166 And j = 16 Then Msgox " tm aralklar dolu" End If End If End If End If End If AtlaSona: txtadet.Value = "" txtkilo.Value = "" txtfiyat.Value = "" txtadet.SetFocus MsgBox "Kaydedildi" End Sub
Sub Ara_Yaz() Dim i As Integer Dim say1 As Integer Dim say2 As Integer Dim satir As Integer satir = 1 say1 = 0 For i = 1 To 10 say1 = UBound(Split(Cells(i, 1), "ali")) say2 = UBound(Split(Cells(i, 1), "veli")) If say1 > 0 And say2 > 0 Then Cells(satir, 3) = Cells(i, 1) satir = satir + 1 End If Next i End Sub Function AraSay(aralik As Range, veri1 As String, veri2 As String) As Long Dim ara As Range Dim say1 As Integer Dim say2 As Integer Dim satir As Integer satir = 0 For Each ara In aralik say1 = UBound(Split(ara, veri1)) say2 = UBound(Split(ara, veri2)) If say1 > 0 And say2 > 0 Then satir = satir + 1 End If Next ara AraSay = satir End Function 'Kullanl '=AraSay(A1:A200;"elma";"hal") Sub Auto_Open() Sheets("Sayfa2").Select End Sub isimgir = TextBox3.Text satrndan sonra For i = 1 To Sheets.Count If Sheets(i).Name = isimgir Then MsgBox "Ayn isimde sayfa var" Exit Sub End If Next i Private Sub CommandButton1_Click() If Not TextBox3.Text = Empty Then For i = 1 To Worksheets.Count If Sheets(i).Name = TextBox3.Text Then MsgBox "Bu isimli bir sayfa mevcut..... !" Exit Sub End If Next Set NewSh = Worksheets.Add(After:=Sheets(Sheets.Count)) NewSh.Name = TextBox3.Text End If Set NewSh = Nothing End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim W As Window Dim stCap as String stCap = ActiveWindow.Caption Application.ScreenUpdating = False If Right(stCap, 2) = ":1" Then Set W = Windows(Left(stCap, Len(stCap) - 2) & ":2") ElseIf Right(stCap, 2) = ":2" Then Set W = Windows(Left(stCap, Len(stCap) - 2) & ":1") Else Exit Sub ' Tek pencere End If W.ScrollColumn = ActiveWindow.ScrollColumn Application.ScreenUpdating = True End Sub Kod: Private Sub CommandButton5_Click() If TextBox14.Value <> "" Then Sheets("Cari Kart").Activate Cells(8, 1).Select Do While ActiveCell.Value <> "" If Trim(ActiveCell.Value) = Trim(Me.TextBox15.Value) Then If MsgBox(Me.TextBox15 & " Dosya Numaral rn Kayd Var" & " Yeniden Kayt Yaplsn m?", vbYesNo, "Mkerrer Kayt") = vbNo Then Exit Sub End If ActiveCell.Offset(1, 0).Activate Loop ActiveCell.Value = TextBox14.Value ActiveCell.Offset(0, 1).Value = TextBox15.Value ActiveCell.Offset(0, 2).Value = TextBox16.Value ActiveCell.Offset(0, 3).Value = TextBox19.Value 'diyelimki Bundan sonrakileri Sayfa2'ye kaydedeceksiniz. 'Sheets("Sayfa2").Select ile verileri kaydetmek istediiniz sayfaya geiyor 'Range ("A1).Select Aktif hcreyi seerek kayd tamamlyor. Sheets("Kasa").Select Range("B8").Select ActiveCell.Offset(1, 0).Activate ActiveCell.Value = TextBox14.Value ActiveCell.Offset(0, 1).Value = TextBox15.Value ActiveCell.Offset(0, 2).Value = TextBox16.Value ActiveCell.Offset(0, 3).Value = TextBox19.Value 'Kasa sayfasna kaytlar B8 hcresinden balamas gerekiyor 'TextBox14 deki bilgiler B stununa atlyor ActiveCell.Offset(0, 2).Value = TextBox14.Value 'TextBox17 deki bilgiler C stununa atlyor ActiveCell.Offset(0, 3).Value = TextBox17.Value 'TextBox20 deki bilgiler E stununa atlyor ActiveCell.Offset(0, 5).Value = TextBox20.Value End If End Sub Sub listele() [a2:p65536].ClearContents For a = 2 To Sheets.Count Set s1 = Sheets(a) For b = 2 To s1.[w65536].End(3).Row c=c+1 Cells(c + 1, "a") = s1.[b1] Cells(c + 1, "b") = s1.[b8] For sut = 1 To 14 Cells(c + 1, sut + 2) = s1.Cells(b, sut + 22) Next Next Next End Sub
Sub AKTAR() Set s1 = [Sayfa1] Set s2 = [Sayfa2] s1.Select s1_son = s1.[A65536].End(3).Row S2_SON = s2.[A65536].End(3).Row For x = 2 To S2_SON For y = 2 To s1_son If s1.Cells(y, 1) = s2.Cells(x, 1) Then For z = 2 To 11 s2.Cells(x, z + 8) = s1.Cells(y, z) Next z Exit For End If Next y Next s2.Select End Sub Option Explicit Private Sub CommandButton1_Click() Unload Me End Sub Private Sub TextBox1_Change() Dim Texte As String Texte = TextBox1.Text Select Case Len(Texte) Case 2, 5 Texte = Texte & "/" End Select TextBox1.Text = Texte End Sub Private Sub TextBox1_Enter() TextBox1.Text = "" End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If IsDate(TextBox1.Text) Then TextBox1.Text = Format(TextBox1.Text, "dd/mm/yyyy") Else TextBox1.Text = "" End If End Sub Sub Spalte() Dim s As Integer Dim z As Integer Dim t As String Dim u As String s = ActiveCell.Column z = ActiveCell.Row t = Columns(s).Address(0, 0) u = Rows(z).Address(0, 0) MsgBox "Spaltennummer: " & s & Chr$(13) & Chr$(13) & "Spaltenbuchstabe(n): " & Left(t, InStr(t, ":") - 1) & Chr$(13) & Chr$(13) & "Zeilennum vbOKOnly, "Adresse der aktiven Zelle ..." End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim s As Integer Dim z As Integer Dim t As String Dim u As String s = ActiveCell.Column z = ActiveCell.Row t = Columns(s).Address(0, 0) u = Rows(z).Address(0, 0) MsgBox "Stun numaras: " & s & Chr$(13) & Chr$(13) & "Stun Ad: " & Left(t, InStr(t, ":") - 1) & Chr$(13) & Chr$(13) & "Satr Numaras: " & vbOKOnly, "Ayrntl aktif hcre adresleri" End Sub
With Application.FileSearch .NewSearch .LookIn = "C:\WINDOWS" .SearchSubFolders = True 'Excel dosyas arama .FileType = msoFileTypeExcelWorkbooks .Execute For i = 1 To .FoundFiles.Count 'MsgBox .FoundFiles(i) Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.GetFile(.FoundFiles(i)) mesaj = "Oluturulma Tarihi: " & objFile.DateCreated mesaj = mesaj & vbCrLf & "Deiiklik tarihi: " & objFile.DateLastModified mesaj = mesaj & vbCrLf & "Son eriim tarihi: " & objFile.DateLastAccessed mesaj = mesaj & vbCrLf & "Dosya ad: " & objFile.Name mesaj = mesaj & vbCrLf & "Bulunduu klasr yolu: " & objFile.ParentFolder mesaj = mesaj & vbCrLf & "Bulunduu src: " & objFile.Drive mesaj = mesaj & vbCrLf & "Tam dosya yolu: " & objFile.Path mesaj = mesaj & vbCrLf & "Dosya boyutu: " & objFile.Size & " byte" mesaj = mesaj & vbCrLf & "Dosya tipi: " & objFile.Type mesaj = mesaj & vbCrLf & "Ksa ad: " & objFile.ShortName mesaj = mesaj & vbCrLf & "Ksa yolu: " & objFile.ShortPath MsgBox mesaj, , i Next i 'Word belgesi arama mesaj = "" .NewSearch .LookIn = "C:\WINDOWS" .SearchSubFolders = True .FileType = msoFileTypeWordDocuments .Execute For k = 1 To .FoundFiles.Count Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.GetFile(.FoundFiles(k)) mesaj = "Oluturulma Tarihi: " & objFile.DateCreated mesaj = mesaj & vbCrLf & "Deiiklik tarihi: " & objFile.DateLastModified mesaj = mesaj & vbCrLf & "Son eriim tarihi: " & objFile.DateLastAccessed mesaj = mesaj & vbCrLf & "Dosya ad: " & objFile.Name mesaj = mesaj & vbCrLf & "Bulunduu klasr yolu: " & objFile.ParentFolder mesaj = mesaj & vbCrLf & "Bulunduu src: " & objFile.Drive mesaj = mesaj & vbCrLf & "Tam dosya yolu: " & objFile.Path mesaj = mesaj & vbCrLf & "Dosya boyutu: " & objFile.Size & " byte" mesaj = mesaj & vbCrLf & "Dosya tipi: " & objFile.Type mesaj = mesaj & vbCrLf & "Ksa ad: " & objFile.ShortName mesaj = mesaj & vbCrLf & "Ksa yolu: " & objFile.ShortPath MsgBox mesaj, , k Next k End With MsgBox "lem tamam.", vbInformation, "www.kod.gen.tr" End Sub Sub Zelladresse() Worksheets(1).Select With ActiveCell MsgBox .Address MsgBox .Address(False) MsgBox .Address(, False) MsgBox .Address(False, False) MsgBox .Row MsgBox .Column MsgBox "Zeile: " & .Row & _ " - Spalte:" & .Column End With End Sub
Bir alternatif, Sub test(yol As String, dosyaadi As String, sayfaadi, range As String) With ActiveSheet.Range(range) .FormulaArray = "='" & yol & "\[" & dosyaadi & "]" & sayfaadi & "'!" & range .Value = .Value End With End Sub arma rnei test ("C:\klasoradi", "kitap.xls","sayfa1", "A1") kapal c:\klasoradi\kitap.xls dosyasnn sayfa1 sayfasndaki a1 hcresini alr. Bir dier alternatif Applicaiton.ScreenUpdating = False Application.EnableEvents = False Application.DisplayAlerts = False Set kitap = Workbooks.Open ("c:\klasor\kitapadi.xls") cells(1,1) = kitap.Worksheets("sayfa1").cells(1,1) Applicaiton.ScreenUpdating = True Application.EnableEvents = True Application.DisplayAlerts = True kapal c:\klasor\kitapadi.xls sayfa1 sayfasndaki a1 hcresini alr. Sub aktar() Application.ScreenUpdating = False Dim s(2) Set s(1) = Sheets("ATLYE RAPORU") Set s(2) = Sheets("BAKIM RAPORU") For a = 1 To 2 For b = 3 To s(a).[a65536].End(3).Row Set s3 = Sheets("" & s(a).Cells(b, "b")) sonsat = s3.[a65536].End(3).Row + 1 If s(a).Cells(b, "d") = "x" Then GoTo 10 s3.Cells(sonsat, "a") = s(a).Cells(b, "a") s3.Cells(sonsat, "b") = s(a).Cells(b, "c") s(a).Cells(b, "d") = "x" s3.[a3:b65536].Sort Key1:=s3.[a3] 10 Next: Next s(1).Select MsgBox "VERLER AKTARILDI" End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveCell.Column = 2 And ActiveCell.Row > 1 And ActiveCell.Row < 22 Then Kalender.Show End Sub Sub mukerrersil() Dim i, y, a As Integer a = WorksheetFunction.CountA(Range("b1:b65000")) For i = 1 To a For y = i + 1 To a If Cells(i, 1).Value = Cells(y, 1) Then Cells(i, 1).Value = Cells(i, 1).Value Cells(y, 1).Value = Cells(y, 1).Value Cells(y, 1).EntireRow.Delete End If Next y Next i End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target _ As Range, Cancel As Boolean) Cancel = True If Target.Row = 1 Then Exit Sub If Target.Column <> 2 Then Exit Sub On Error Resume Next Application.EnableEvents = False Target.Value = Target.Value + 1 Application.EnableEvents = True If Err.Number <> 0 Then MsgBox "Unable to add 1 to value in cell " _ & Target.Address(0, 0) End If End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal _ Target As Range, Cancel As Boolean) If Target.Column <> 2 Then Exit Sub If Not IsNumeric(Target) Then Exit Sub Cancel = True Dim i As Long, curv As Long, tov As Long curv = Target.Value tov = InputBox("supply new total rows", _ "Rows input", curv + 1) If tov < curv Then Exit Sub For i = curv + 1 To tov Cells(Target.Row + i - 1, 1).EntireRow.Insert Cells(Target.Row + i - 1, 3) = i Cells(Target.Row, 2) = i Next i End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) rowoffset = 0 Intersect(ActiveCell.EntireRow, Columns("A")).Value = ActiveCell.Row + rowoffset End Sub Sub Degerler() Columns("A").Value = Columns("B").Value ' Deerleri yazar Columns("A").Value = Columns("B").Formula ' Formlleri yazar End Sub Sub test() Dim ra As Range, rb As Range For Each rb In [B1:B100] For Each ra In [A1:A100] If InStr(1, ra, rb) > 0 And rb <> "" Then ra.ClearContents Next ra Next rb End Sub Sub mukerrersil() Dim i, y, a As Integer a = WorksheetFunction.CountA(Range("b1:b65000")) For i = 1 To a For y = i + 1 To a If Cells(i, 1).Value = Cells(y, 1) Then Cells(i, 1).Value = Cells(i, 1).Value Cells(y, 1).Value = Cells(y, 1).Value Cells(y, 1).EntireRow.Delete End If Next y Next i End Sub
Sub aktar() Application.ScreenUpdating = False Dim s(2) Set s(1) = Sheets("ATLYE RAPORU") Set s(2) = Sheets("BAKIM RAPORU") For a = 1 To 2 For b = 3 To s(a).[a65536].End(3).Row Set s3 = Sheets("" & s(a).Cells(b, "b")) sonsat = s3.[a65536].End(3).Row + 1 If s(a).Cells(b, "d") = "x" Then GoTo 10 s3.Cells(sonsat, "a") = s(a).Cells(b, "a") s3.Cells(sonsat, "b") = s(a).Cells(b, "c") s(a).Cells(b, "d") = "x" s3.[a3:b65536].Sort Key1:=s3.[a3] 10 Next: Next s(1).Select MsgBox "VERLER AKTARILDI" End Sub Sub Test() Dim MyRng As Range Dim NoB As Long NoB = Cells(65536, 2).End(xlUp).Row For Each MyRng In Range("B2:B" & NoB) If MyRng.Offset(0, -1) = "" Then MyRng.Offset(0, -1) = MyRng Next End Sub Option Explicit Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column <> 2 Then Exit Sub If Target.Row = 1 Then Exit Sub If Left(Target.Offset(0, -1), 1) = "~" Then Exit Sub If Left(Target.Offset(0, -1), 1) = "~" Then Exit Sub If Left(Target.Offset(0, -1), 1) = "=Row()-1" Then Exit Sub Target.Offset(0, -1).Formula = "=Row()-1" End Sub Option Explicit Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column <> 2 Then Exit Sub If Target.Row = 1 Then Exit Sub If Left(Target.Offset(0, -1), 1) = "~" Then Exit Sub If Left(Target.Offset(0, -1), 1) = "~" Then Exit Sub If Left(Target.Offset(0, -1), 1) = "=Row()-1" Then Exit Sub Target.Offset(0, -1).Formula = "=Row()-1" End Sub Option Explicit Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column <> 2 Then Exit Sub If Target.Row = 0 Then Exit Sub If Left(Target.Offset(0, -1), 0) = "~" Then Exit Sub If Left(Target.Offset(0, -1), 0) = "~" Then Exit Sub If Left(Target.Offset(0, -1), 0) = "=Row() 1" Then Exit Sub Target.Offset(0, 1).Formula = "=Row() +0" End Sub Sub xlslistele() Dim pir As Integer With Application.FileSearch .LookIn = Range("B1").Value .Filename = "*.xls" .Execute For pir = 1 To .FoundFiles.Count Cells(pir + 1, 1).Value = Dir(.FoundFiles(pir)) Next pir End With End Sub Sub clock() If ThisWorkbook.Worksheets(1).Range("B1").Value = "X" Then Exit Sub ThisWorkbook.Worksheets(1).Range("A1").Value = Format(Now, "hh:mm:ss AM/PM") Application.OnTime Now + TimeSerial(0, 0, 1), "clock" End Sub
Sub ResetTest1() For Each n In Range("B1:G13") If n.Value <> 0 Then n.Value = 0 End If Next n End Sub Private Sub Workbook_Open() ActiveSheet.Unprotect If [b2] = "" Then [b2] = Date ActiveSheet.Protect End Sub Modle Function MakroStart() Application.Volatile Tut End Function Sub Tut() MsgBox ("Tuuuuuuuuut") End Sub 'C2 ye =EER(B2>10;MakroStart();"Nix") yaz 'B2 ye 11 yaz makro alsn alt+f11 den sonra alma kitab blmne Kod: Private Sub Workbook_BeforeClose(Cancel As Boolean) Start = False End Sub Private Sub Workbook_Open() Zeitmakro Zeit = Time Start = True End Sub Kod: Public Zeit As Date Public Start As Boolean Sub Zeitmakro() Application.OnTime Now + TimeValue("00:00:01"), "Zielmakro" End Sub Sub Zielmakro() Range("B2").Value = Format(Time, "hh:mm:ss") Range("B3").Value = Format(Time - Zeit, "hh:mm:ss") If Start = True Then Call Zeitmakro End Sub Sub EnterInfo() Dim i As Integer Dim cel As Range 'Set cel = [B3] Set cel = ActiveCell For i = 1 To 10 cel(i).Value = [B1].Value - 1 + i Next i cel(i).Value = "=SUM(R[-10]C:R[-1]C)" End Sub
Dim bln As Boolean Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim wks As Worksheet Dim strName As String Dim rng As Range Dim StAr() Dim InI As Integer Set rng = Sheets("Eingabe").Range("B3") 'hier "Auslesezelle" fr neuen TabBlattNamen anpassen If Target.Address = rng.Address Then bln = True If bln = True And Target.Address <> rng.Address Then If Len(rng) < 1 Or Len(rng) > 31 Then MsgBox "Bitte min. 1 und max. 31 Zeichen eingeben !" bln = False Exit Sub End If StAr = Array(":", "/", "\", "?", "[", "]") For InI = 0 To UBound(StAr) If InStr(1, rng, StAr(InI), 0) > 0 Then MsgBox "Sonderzeichen ' " & StAr(InI) & " ' nicht zulssig !" bln = False Exit Sub End If Next InI For Each wks In ActiveWorkbook.Worksheets If UCase(wks.Name) = UCase(rng) Then MsgBox "Es existiert bereits ein Tabellenblatt mit diesem Namen !" bln = False Exit Sub End If Next Sheets.Add.Move after:=Sheets("Eingabe") ActiveSheet.Name = rng.Value Sheets("Eingabe").Select bln = False End If End Sub Sub Nodefil() Feuil1.ScrollArea = "B4:H23" End Sub Sub Okdefil() ' pour librer le dfilement Feuil1.ScrollArea = "" End Sub Sub Test() Dim i As Long, No As Long For i = 5 To Cells(65536, 2).End(xlUp).Row If Cells(i, 2) <> Empty Then No = No + 1 Cells(i, 1) = No Else Cells(i, 1) = Empty End If Next End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Range) Application.CellDragAndDrop = False If Intersect(Target, Range("B5:G22")) Is Nothing Then Range("A1").Select End If End Sub Kullanm : A1 e say yaz baka bir hcreye =bas_top(A1) Function bas_top(hucre As Range) As Integer Dim intI% For intI = 1 To Len(hucre) bas_top = bas_top + CInt(Mid(hucre, intI, 1)) Next End Function
IsCharAlpha Lib "user32" Alias "IsCharAlphaA" (ByVal cChar As Byte) As Long IsCharAlphaNumeric Lib "user32" Alias "IsCharAlphaNumericA" (ByVal cChar As Byte) As Long IsCharLower Lib "user32" Alias "IsCharLowerA" (ByVal cChar As Byte) As Long IsCharUpper Lib "user32" Alias "IsCharUpperA" (ByVal cChar As Byte) As Long
Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim strSave As String If IsCharAlphaNumeric(KeyAscii) Then strSave = " Saysal" If IsCharAlpha(KeyAscii) Then strSave = "Bu karakter" If IsCharLower(KeyAscii) Then strSave = strSave & " Kk" If IsCharUpper(KeyAscii) Then strSave = strSave & " Byk" MsgBox "Bastn tu: " & Chr$(KeyAscii) & Chr(10) & strSave End Sub Aadaki kod seili alanlarda 1215 eklinde girilen girileri 12:15 ekline dntrr. Sub InTime() Dim C As Range For Each C In Selection C = TimeSerial(Left(C, 2), Right(C, 2), 0) C = Format(C, "hh:mm") Next C End Sub Sub PrtPvw() ActiveSheet.PrintPreview False Deiiklie izin vermez True verir. ActiveWindow.View = xlNormalView End Sub Private Sub CommandButton1_Click() Me.Hide Sheets("Sayfa1").Select ActiveWindow.SelectedSheets.PrintPreview Me.Show End Sub Worksheets("sheet2").PrintOut ' Bask iin Worksheets("sheet2").PrintPreview ' Bask nizleme iin Application.Dialogs(xlDialogPrint).Show Sub PrtPvw() ActiveSheet.PrintPreview False '"False"==> Deiiklie izin vermez True verir. ActiveWindow.View = xlNormalView End Sub Private Sub Workbook_BeforePrint(Cancel As Boolean) Cancel = True End Sub Private Sub TextBox1_Change() TextBox1.Value = UCase(TextBox1.Value) Dim i As Integer ListBox1.Clear For i = 1 To Worksheets.Count - 9 If Left(Worksheets(i).Name, Len(TextBox1)) = TextBox1 Then ListBox1.AddItem Worksheets(i).Name End If Next End Sub user formundaki kapat tuunun altna aadaki kodu yazp dener misin ? visual basic kodu: -------------------------------------------------------------------------------Dismi = ActiveWorkbook.Name ActiveWorkbook.SaveCopyAs "C:\cari-a1\maltakipyedek\ " & Dismi ActiveWorkbook.Save Unload Me Windows(2).Activate With Workbooks("maltakip.xls") .Close False End With Sub AddSaveAsNewWorkbook() Dim Wk As Workbook Set Wk = Workbooks.Add Application.DisplayAlerts = False Wk.SaveAs Filename:="C:/MyData/SalesData.xls" End Sub
ncelikle "zin" isimli dosyanzdaki bir module aadaki kodu yazn. visual basic kodu: Sub ac() UserForm1.Show End Sub
Daha sonra "personel" isimli dosyanzda bulunan userformun zerindeki command butonada aadaki kodu yazn. Private Sub CommandButton1_Click() Unload Me Application.Run "izin.xls!ac" End Sub
Workbook (KTAP.XLS).Worksheets(Tablo1).Range(D8).Clear Private Sub UserForm_Initialize() For i = 1 To 20 ActiveSheet.Range("A1").Formula = _ "='C:\Yeni Klasr (2)\[Deneme.xls]Sayfa1'!C" & i UserForm1.ComboBox1.AddItem (Range("A1").Value) Next i Range("A1").Value = "" End Sub Sub FileOpened() Dim MyFile As String MyFile = "C:\den\A.xls" On Error GoTo FileInUse Open MyFile For Binary Access Read Lock Read As #1 Close #1 MsgBox "Dosya daha nceden kullanmda deil, aabilirsiniz !" Workbooks.Open MyFile Exit Sub FileInUse: MsgBox "Dosya u anda bakas tarafndan kullanlmakta !" End Sub B2'ye biti, B1'e balang tarihini yaz. D hcresinde aylar, E hcresinde o aydan ka gn olduunu gsterecek ekilde iki tarih arasndaki gn farkn bulu Sub Days() Dim sngCounter As Single Dim intRow As Integer, intDays As Integer Columns("D:E").ClearContents sngCounter = Range("B1") Do intDays = intDays + 1 If Month(sngCounter) <> Month(sngCounter + 1) Then intRow = intRow + 1 Cells(intRow, 4) = Format(sngCounter, "mmmm") Cells(intRow, 5) = intDays intDays = 0 End If sngCounter = sngCounter + 1 Loop Until sngCounter > Range("B2") intRow = intRow + 1 Cells(intRow, 4) = Format(Range("B2"), "mmmm") Cells(intRow, 5) = Day(Range("B2")) Cells(intRow + 1, 5) = Application.Sum(Range("E1:E" & intRow)) End Sub
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx A Const Gizle = &H80 Const Goster = &H40 Private Sub CommandButton1_Click() Dim hWnd1 As Long hWnd1 = FindWindow("Shell_traywnd", "") Call SetWindowPos(hWnd1, 0, 0, 0, 0, 0, Gizle) End Sub Private Sub CommandButton2_Click() Dim hWnd1 As Long hWnd1 = FindWindow("Shell_traywnd", "") Call SetWindowPos(hWnd1, 0, 0, 0, 0, 0, Goster) End Sub Option Explicit Dim handleW1 As Long Private Declare Function FindWindowA Lib "user32" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function SetWindowPos Lib "user32" _ (ByVal handleW1 As Long, _ ByVal handleW1InsertWhere As Long, ByVal w As Long, _ ByVal x As Long, ByVal y As Long, ByVal z As Long, _ ByVal wFlags As Long) As Long Const TOGGLE_HIDEWINDOW = &H80 Const TOGGLE_UNHIDEWINDOW = &H40 Sub masque() handleW1 = FindWindowA("Shell_traywnd", "") Call SetWindowPos(handleW1, 0, 0, 0, 0, 0, TOGGLE_HIDEWINDOW) End Sub Sub affiche() Call SetWindowPos(handleW1, 0, 0, 0, 0, 0, TOGGLE_UNHIDEWINDOW) End Sub Option Explicit Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Const VK_CONTROL = &H11 Const KEYEVENTF_KEYUP = &H2 Const VK_ESCAPE = &H1B Sub baslat_ac() Call keybd_event(VK_CONTROL, 0, 0, 0) Call keybd_event(VK_ESCAPE, 0, 0, 0) Call keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0) Call keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0) End Sub Sub TitleCase() Dim cell As Range For Each cell In Selection.Cells If cell.HasFormula = False Then cell = Application.Proper(cell) End If Next End Sub
Private Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hwnd As Long, _ ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hwnd As Long, _ ByVal nIndex As Long) As Long Private Declare Function DrawMenuBar Lib "user32" ( _ ByVal hwnd As Long) As Long Private Const WS_BORDER = &H800000 Private Const GWL_STYLE = (-16) Private Sub UserForm_Activate() Dim lngFormHwnd As Long, lngFormStyle As Long Me.BorderStyle = fmBorderStyleNone If Application.Version < 9 Then lngFormHwnd = FindWindow("THUNDERXFRAME", Me.Caption) Else lngFormHwnd = FindWindow("THUNDERDFRAME", Me.Caption) End If lngFormStyle = GetWindowLong(lngFormHwnd, GWL_STYLE) lngFormStyle = lngFormStyle And Not WS_BORDER SetWindowLong lngFormHwnd, GWL_STYLE, lngFormStyle DrawMenuBar lngFormHwnd End Sub Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Unload Me End Sub
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _ ByVal wCmd As Long) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As _ Long, lpRect As RECT) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, _ ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, _ ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Private FensterRegion&, Region& Private Hauptfensternummer&, Clientfensternummer& Private dummy As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Const GW_CHILD = 5 Private Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2 Private Sub UserForm_Initialize() Call pirullah End Sub Sub pirullah() Dim Abmessung As RECT Dim Abmessung1 As RECT Dim Pos1x&, Pos1y&, Pos2x&, Pos2y& If FensterRegion <> 0 Then Exit Sub UserForm1.BorderStyle = fmBorderStyleSingle Call Fensternummer(UserForm1, Abmessung, Abmessung1) Pos1x = 0 Pos1y = (Abmessung1.Top - Abmessung.Top) Pos2x = Abmessung.Right - Abmessung.Left Pos2y = Abmessung.Bottom - Abmessung.Top Region = CreateRectRgn(Pos1x, Pos1y, Pos2x, Pos2y) FensterRegion = SetWindowRgn(Hauptfensternummer, Region, True) End Sub Private Sub Fensternummer(Form As Object, Abmessung As RECT, Abmessung1 As RECT) Dim Fenstername$, Suchstring$ Suchstring = "UserForm ohne Titelzeile" Fenstername = Form.Caption Form.Caption = Suchstring Hauptfensternummer = FindWindow(vbNullString, Suchstring) Form.Caption = Fenstername Clientfensternummer = GetWindow(Hauptfensternummer, GW_CHILD) dummy = GetWindowRect(Hauptfensternummer, Abmessung) dummy = GetWindowRect(Clientfensternummer, Abmessung1) End Sub Private Sub CommanButton1_Click() Unload Me End Sub
Private Declare Function GetWindowLongA Lib "User32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function FindWindowA Lib "User32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub UserForm_Initialize() Dim hwnd As Long hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", "X", "D") & "Frame", Me.Caption) SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF End Sub Private Sub CommandButton1_Click() Unload Me End Sub Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hWnd As Long, _ ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function DrawMenuBar Lib "user32" ( _ ByVal hWnd As Long) As Long Private Sub UserForm_Initialize() Dim hWnd As Long, Style As Long hWnd = FindWindow(vbNullString, Me.Caption) Style = GetWindowLong(hWnd, -16) And Not &HC00000 SetWindowLong hWnd, -16, Style DrawMenuBar hWnd End Sub Private Sub UserForm_Activate() Dim i As Integer Dim j As Integer Label1.Caption = "" If Worksheets.Count = 1 Then Exit Sub For i = 1 To Worksheets.Count Sheets(i).Name = LCase(Sheets(i).Name) For j = i + 1 To Worksheets.Count If LCase(Worksheets(j).Name) < LCase(Worksheets(i).Name) Then Worksheets(j).Move Before:=Worksheets(i) End If Next j Next i For i = 1 To Sheets.Count If LCase(Sheets(i).Name) <> ("ana sayfa") _ And LCase(Sheets(i).Name) <> ("toplam") _ And LCase(Sheets(i).Name) <> ("stok") _ And LCase(Sheets(i).Name) <> ("sayfa1") Then ComboBox1.AddItem Sheets(i).Name End If Next Sheets("ana sayfa").Move Before:=Sheets(2) Option Explicit Declare Function Beep Lib "Kernel32" (ByVal Fq As Long, ByVal Tm As Long) As Long Sub Warnung() Beep 392, 200 Beep 494, 100 Beep 588, 200 Beep 740, 100 Beep 880, 400 Beep 740, 100 Beep 880, 900 End Sub
DoEvents kullanrsanz bekleme sresince program kilitlenmez. Dim basla Dim bekle basla = Timer bekle = 2 While Timer < basla + bekle DoEvents '2 saniye bekle Wend Sub MsgBarreEtat() barreEtatEnregistre = Application.DisplayStatusBar Application.DisplayStatusBar = True Application.StatusBar = "Cration du tarif catalogue.....Veuillez patienter, SVP....." '....excution d'une macro (gnralement long)..... Application.Wait Now + TimeValue("00:00:04") Application.StatusBar = False Application.DisplayStatusBar = barreEtatEnregistre End Sub Sub MsgHeure() mheure = Time MsgBox ("Il est: " & mheure) End Sub Sub Pause() Application.OnTime Now+TimeValue("00:00:01"), "NextMacro" End Sub Sub bekletmeli_mesaj() MsgBox "Selamun Aleykm OK !" saatsimdi = Hour(Now()) dakikasimdi = Minute(Now()) saniyesimdi = Second(Now()) + 10 zamansayaci = TimeSerial(saatsimdi, dakikasimdi, saniyesimdi) Application.Wait zamansayaci Beep MsgBox "Ve Aleykm Selam! Kusura bakma 10 saniye sonra oldu ama." End Sub Sub StatusBarExample() Application.ScreenUpdating = False ' turns off screen updating Application.DisplayStatusBar = True ' makes sure that the statusbar is visible Application.StatusBar = "Please wait while performing task 1..." ' add some code for task 1 that replaces the next sentence Application.Wait Now + TimeValue("00:00:02") Application.StatusBar = "Please wait while performing task 2..." ' add some code for task 2 that replaces the next sentence Application.Wait Now + TimeValue("00:00:02") Application.StatusBar = False ' gives control of the statusbar back to the programme End Sub Sub LanceProgramme() ValRetour = Shell("C:\WINDOWS\EXPLORER.EXE", 1) Application.Wait Now + TimeValue("00:00:04") SendKeys "%{F4}", True ' Envoie Alt+F4 pour fermer l'application EXPLORER. End Sub Sub Lanc_Explorateur() Shell "explorer.exe", vbMaximizedFocus End Sub
Aadaki kodu thisworkbook sayfasna kopyalayarak deneyin. Private Sub Workbook_SheetActivate(ByVal Sh As Object) deg=IIf(ActiveSheet.Name = "Sayfa1", True, False) With Application .FixedDecimal =deg .FixedDecimalPlaces = 2 End With End Sub Sub Button1_Click() If ActiveSheet.Name = "Sayfa1" Then With Application .FixedDecimal = True .FixedDecimalPlaces = 2 End With Else With Application .FixedDecimal = False .FixedDecimalPlaces = 2 End With End If MsgBox Application.FixedDecimal End Sub kod blmne: Sayfa1'in Kod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 19 And Target.Row = 8 Then [S1] = [S1] + 1 End If Call Islemler End Sub
ChDir-MkDir.xls'nin Module1'ine; Kod: Sub Islemler() Application.DisplayAlerts = 0 On Error Resume Next VerilecekAd = Left(Sheets("Sayfa1").Range("S8"), 3) & 241 + Sheets("Sayfa1").Range("S1") MkDir "C:\Veriyedekle" MkDir "C:\Veriyedekle\" & VerilecekAd Workbooks.Add ChDir "C:\Veriyedekle\" & VerilecekAd VerilecekAd = VerilecekAd & ".xls" ActiveWorkbook.SaveAs VerilecekAd ActiveWorkbook.Close False Application.DisplayAlerts = 1 End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Set MyIsect = Application.Intersect(Target, Range("A1:B5")) If Not MyIsect Is Nothing Then UserForm1.Show End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Set MyIsect = Application.Intersect(Target, Range("A1:B5")) If Not MyIsect Is Nothing Then UserForm1.Show End Sub Sub Dosya_Ta() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.MoveFile("D:\Excelrnekleri\Move.xls", "C:\") End Sub Sub
Option Explicit 'Belirlenen hcre aralklarnda ift tklama ile x iareti koyar ve kaldrr Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Dim RaBereich As Range Set RaBereich = Range("B3:P16,B19:P22") If Intersect(Target, RaBereich) Is Nothing Then Exit Sub Application.EnableEvents = False Cancel = True If Target.Value = "X" Then Target.Value = "" Else Target.Value = "X" End If Application.EnableEvents = True Set RaBereich = Nothing End Sub Sub Yaz() ActiveSheet.PageSetup.PrintArea = "$a$1:$h$30" ActiveSheet.PrintOut From:=1, Copies:=1, preview:=False, Collate:=True End Sub Private Sub metinayikla() Dim nums As String For i = 1 To Cells(65536, 1).End(xlUp).Row For b = 1 To Len(Cells(i, 1)) If IsNumeric(Mid(Cells(i, 1), b, 1)) = True Then nums = nums & Mid(Cells(i, 1), b, 1) End If Next b Cells(i, 1) = CLng(nums) nums = "" Next i End Sub Belirli Bir Sre ekranda bekleyen ve daha sonra kapan userform. Private Sub UserForm_Activate() TimeDebut = Timer DoEvents While Timer < TimeDebut + 10 Wend Unload Me End Sub 'Sreli UserForm-2 Private Sub UserForm_Activate() Application.Wait Now + TimeSerial(0, 0, 3) Unload Me End Sub a , b ve c adl sayfalar haricindekileri silmek istersek; Sub GereksizSayfaSil() Application.DisplayAlerts = False For Each ws In Worksheets If ws.Name = "a" Or ws.Name = "b" Or ws.Name = "c" Then GoTo sonraki ws.Delete sonraki: Next Application.DisplayAlerts = True End Sub Sub sayfasil() Application.DisplayAlerts = False For a = Sheets.Count To 1 Step -1 ad = Sheets(a).Name If IsNumeric(ad) = True And ad < 32 Then Sheets(a).Delete Next End Sub
Sub listele() Dim Klasor As String Dim Dosya As String Dim i As Integer Klasor = "C:\" Dosya = Dir(Klasor & Application.PathSeparator & "*.*", vbDirectory) Do While Dosya <> "" Cells(i + 1, 1) = Dosya i=i+1 Dosya = Dir Loop End Sub Sadece dosya isimlerini listeler.Dosya UZantlarn gstermez. Sub listele2() Dim Klasor As String Dim Dosya As String Dim i As Integer Range("A1:A65536").Clear Klasor = "C:\Dosyalar" Dosya = Dir(Klasor & "\*.*") Do While Dosya <> "" Cells(i + 1, 1) = Left(Dosya, Len(Dosya) - 4) i=i+1 Dosya = Dir Loop End Sub Sub DateinamenAuflisten() Dim Dateiname As String, i As Integer Dateiname = Dir$("c:\*.xls") uzantsn deitirebilirsiniz .doc gibi veya c:\windows\ bu yolla da klasr ii de olabilir. Do While Dateiname <> "" ActiveCell.Offset(i, 0) = Dateiname i=i+1 Dateiname = Dir$() Loop End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then Cells(ActiveCell.Row, 2).Select MsgBox "A1:A100 aralndaki hcreler seilemez!" End If End Sub Sub GereksizSayfaSil() Application.DisplayAlerts = False For Each ws In Worksheets If ws.Name = "a" Or ws.Name = "b" Or ws.Name = "c" Then GoTo sonraki ws.Delete sonraki: Next Application.DisplayAlerts = True End Sub Sub GereksizSayfaSil() Application.DisplayAlerts = False For Each ws In Worksheets If ws.Name = "a" Or ws.Name = "b" Or ws.Name = "c" Then GoTo sonraki ws.Delete sonraki: Next Application.DisplayAlerts = True End Sub Pek ok sayfa olan dosyamzdaki rnek olarak a , b ve c adl sayfalar haricindekileri silmek istersek; Kod: Sub GereksizSayfaSil() Application.DisplayAlerts = False For Each ws In Worksheets If ws.Name = "a" Or ws.Name = "b" Or ws.Name = "c" Then GoTo sonraki ws.Delete sonraki: Next Application.DisplayAlerts = True End Sub
Her zaman sylediim gibi gelitirmek sizin elinizde sutun B:B DELDE C:C OLABLR GB Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("B:B")) Is Nothing Then MsgBox "Buraya istediiniz uyary yazyorsunuz!", vbOKOnly, "www.excel.web.tr" End If End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("B:B")) Is Nothing Then MsgBox "Buraya istediiniz uyary yazyorsunuz!", vbOKOnly, "www.excel.web.tr" End If End SubSub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Declare Sub FlashMsg(Msg$, Dure&) 'cration la vole d'un userform qui affiche Msg pendant 'Dure (en millisecondes). Excel 2000 seulement 'ncessite une rfrence Microsoft Forms 2.0 Object Library Dim UsrForm As Object, lbl As MSForms.Label Set UsrForm = ThisWorkbook.VBProject.VBComponents.Add(3) With UsrForm .Properties("Caption") = "Information droulement macro" .Properties("Width") = 200 .Properties("Height") = 100 .Properties("ShowModal") = False End With Set lbl = UsrForm.Designer.Controls.Add("forms.label.1") With lbl .Caption = Msg .Left = 18: .Top = 12: .Width = 165: .Height = 55 .ForeColor = 2036353 'rouge fonc .Font.Bold = True: .Font.Size = 12 End With VBA.UserForms.Add(UsrForm.Name).Show DoEvents Sleep Dure ThisWorkbook.VBProject.VBComponents.Remove UsrForm End Sub Sub Test() FlashMsg "Fin de la proc 'Zaza'." & vbLf & "Tout va bien !", 500 End Sub Bir form ve bir label ekleyin ve formun kod sayfasna aadaki kodlar yazn. Private Sub UserForm_Activate() newHour = Hour(Now()) newMinute = Minute(Now()) newSecond = Second(Now()) + 1 waitTime = TimeSerial(newHour, newMinute, newSecond) Application.Wait waitTime UserForm1.Hide End Sub Private Sub UserForm_Initialize() Me.Label1.Caption = "Voici un message trs important..." ' dfinir End Sub Standart modle aadaki kodu yazn: Sub Goster() Userform1.Show End Sub
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub taMacro() ActiveSheet.Shapes.AddTextbox( _ msoTextOrientationHorizontal, 10, 10, 0, 0).Select With Selection .Characters.Text = "Patientez !" .AutoSize = True .ShapeRange.Fill.ForeColor.SchemeColor = 15 .Name = "leTxt" End With 'ici le corps de ta macro remplac par une temporisation Start = Timer Sleep (1000) Finish = Timer ActiveSheet.Shapes("leTxt").Delete End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("B:B")) Is Nothing Then MsgBox "B stununa deer yazyorsunuz!", vbOKOnly, "Dikkat" End If End Sub
Application.OnTimedeerleri mavi fontlu ve korumasz; tarih, metin, forml vs. dier hereyi siyah fontlu ve korumal yapar. Saylarla oynanabilir fakat die Sayfadaki nmerik TimeValue("12:00:00"), "makro ad" Sub Set_Protection() On Error GoTo errorHandler Dim myDoc As Worksheet Dim cel As Range Set myDoc = ActiveSheet myDoc.Unprotect For Each cel In myDoc.UsedRange If Not cel.HasFormula And _ Not TypeName(cel.Value) = "Date" And _ Application.IsNumber(cel) Then cel.Locked = False cel.Font.ColorIndex = 5 Else cel.Locked = True cel.Font.ColorIndex = xlColorIndexAutomatic End If Next myDoc.Protect Exit Sub errorHandler: MsgBox Error End Sub Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long Sub ComputerName() Dim lngTemp As Long, strPCName As String strPCName = Space(256) lngTemp = GetComputerName(strPCName, Len(strPCName)) MsgBox strPCName End Sub Option Explicit Declare Function Beep Lib "Kernel32" (ByVal Fq As Long, ByVal Tm As Long) As Long Sub Warnung() Beep 392, 200 Beep 494, 100 Beep 588, 200 Beep 740, 100 Beep 880, 400 Beep 740, 100 Beep 880, 900 End Sub Sub Src_Says() Dim ds, dc, s Set ds = CreateObject("Scripting.FileSystemObject") Set dc = ds.Drives s = dc.Count MsgBox s End Sub
Sub Src_simleri() Dim ds, dc, s Set ds = CreateObject("Scripting.FileSystemObject") Set dc = ds.Drives For Each src In dc s = s & vbCrLf & src Next MsgBox s End Sub Range("A1:A3").Copy Destination:=ActiveCell buna gre deitirir. Gizli sayfalar etkilenmez. Bu kod aktif sayfay baz alr ve dier sayfalar - Aktif sayfadaki seimi dier sayfalarda da seer. - Dier sayfalardaki en st sol hcreyi aktif sayfayla ayn yapar. Sub SynchSheets() ' Duplicates the active sheet's active cell upperleft cell ' Across all worksheets If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub Dim UserSheet As Worksheet, sht As Worksheet Dim TopRow As Long, LeftCol As Integer Dim UserSel As String Application.ScreenUpdating = False ' Remember the current sheet Set UserSheet = ActiveSheet ' Store info from the active sheet TopRow = ActiveWindow.ScrollRow LeftCol = ActiveWindow.ScrollColumn UserSel = ActiveWindow.RangeSelection.Address ' Loop through the worksheets For Each sht In ActiveWorkbook.Worksheets If sht.Visible Then 'skip hidden sheets sht.Activate Range(UserSel).Select ActiveWindow.ScrollRow = TopRow ActiveWindow.ScrollColumn = LeftCol End If Next sht ' Restore the original position UserSheet.Activate Application.ScreenUpdating = True End Sub Sub Dizin_smi_Olutur() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.BuildPath("C:\SXS", "\A") MsgBox a End Sub Sub Dizindeki_Son_sim() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.GetBaseName("C:\SXS\Deneme\Ben.txt") MsgBox a End Sub
Const FOF_NOCONFIRMATION = &h10& Private Type SHFILEOPSTRUCT hwnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAnyOperationsAborted As Long hNameMappings As Long lpszProgressTitle As String End Type Private Declare Sub CopyMemory Lib "KERNEL32" _ Alias "RtlMoveMemory" (hpvDest As Any, _ hpvSource As Any, ByVal cbCopy As Long) Private Declare Function SHFileOperation Lib "Shell32.dll" _ Alias "SHFileOperationA" (lpFileOp As Any) As Long Sub Test() ShellDelete "c:\aaa" End Sub Sub ShellDelete(SrcFile As String) Dim result As Long Dim lenFileop As Long Dim foBuf() As Integer Dim fileop As SHFILEOPSTRUCT lenFileop = LenB(fileop) ReDim foBuf(1 To lenFileop) With fileop .hwnd = 0 .wFunc = FO_DELETE .pFrom = SrcFile & Chr(0) & Chr(0) .fFlags = FOF_NOCONFIRMATION .lpszProgressTitle = "" & Chr(0) & Chr(0) End With Call CopyMemory(foBuf(1), fileop, lenFileop) Call CopyMemory(foBuf(19), foBuf(21), 12) result = SHFileOperation(foBuf(1)) End Sub Sub AdVer1() ActiveSheet.Names.Add Name:="Alan1", _ RefersTo:="=$A$1:$B$10" End Sub Sub say() c=0 For k = 3 To 5 'stun numaralar, istediiniz gibi ayarlayn For ara = 2 To WorksheetFunction.CountA(Columns(k)) If Cells(ara, k) Like "*" & [e2] & "*" Then c = c + 1 Next ara Next k [f2] = c 'neticenin yazdrlaca hcreyi deitirmek gerekebilir.. f2 yerine ist.hcre adresini girin End Sub
Sadece C kolonundaki bir hcreye veri girii olursa veya ift tklanrsa bu durumda alacak makronuzu aadaki iki kodun "......." yazan yerine kopyalay ift tklama ile altrmak iin Kod: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If ActiveCell.Column = 3 Then '........ End If End Sub hcredeki deer deiince altrmak iin Kod: Private Sub Worksheet_Change(ByVal Target As Range) If ActiveCell.Column = 3 Then '........ End If End Sub
her iki koduda ilgili sayfann kod sayfasna yaznz. Yapacanz ilem nmerik ise Macro1'i, alfanmerik ise Macro2'yi bir deneyin,iinizi grr sanrm. Kod: Sub Macro1() eklenecek = ActiveCell.Offset(1, 0) ActiveCell.Value = ActiveCell.Value + eklenecek End Sub Sub Macro2() eklenecek = ActiveCell.Offset(1, 0) ActiveCell.Value = ActiveCell.Value & eklenecek End Sub koddaki test.xls i gerekli isimle degistin basla kacinci sayfadan baslanacagini tane basladan sonra kac tane sayfa kopyalanacagini gosterir. Kod: Sub kopyala() Dim kitap As String Dim tane As Integer Dim basla As Integer basla = 1 tane = 2 kitap = ActiveWorkbook.Name For x = 1 To tane Workbooks(kitap).Sheets(basla).Move _ Before:=Workbooks("Test.xls").Sheets(1) Next End Sub
not: soru basliginizi seceken "makro hakkinda" gibi cok amator bir baslik secmektense, " bir kitaptaki sayfalari baska bir kitaba tasimak" gibi ilk okundugun makro forumunda bir sorunun "makro hakkinda" olmamasi zaten imkansizdir.
Sub Dme1_Tklat() With Application.FileSearch .LookIn = "C:\Windows" 'arama yaplan dizin .SearchSubFolders = True 'alt klasrler aransn m .FileType = msoFileTypeExcelWorkbooks ' aranacak dosya trleri If .Execute() > 0 Then MsgBox .FoundFiles.Count & " adet dosya bulundu." For i = 1 To .FoundFiles.Count Cells(i, 1) = .FoundFiles(i) Next i Else MsgBox "Hi dosya bulunamad.", vbCritical End If End With End Sub Dim sd ' As VBComponent Dim kodlar ' As CodeModule Dim Dosya Dim wb As Workbook i=2 On Error Resume Next Application.DisplayAlerts = False Set ObjFolder = CreateObject("Shell.Application").BrowseForFolder( _ 0, "Klasr Seiniz...", &H4, "") pth = ObjFolder.items.Item.Path ChDir (pth) Dosya = Dir("*.xls") While Dosya <> "" Set wb = Workbooks.Open(pth & "\" & Dosya) Windows(wb.Name).Visible = False For Each sd In wb.VBProject.VBComponents Set kodlar = sd.CodeModule basla = kodlar.CountOfDeclarationLines + 1 If Err.Number = 0 Then Do Until basla >= kodlar.CountOfLines If Err.Number <> 0 Then Err.Clear: Exit Do ThisWorkbook.Sheets(1).Cells(i, "A") = pth & "\" & Dosya ThisWorkbook.Sheets(1).Cells(i, "B") = kodlar.ProcOfLine(basla, vbext_pk_Proc) ThisWorkbook.Sheets(1).Cells(i, "C") = sd.Name basla = basla + kodlar.ProcCountLines( _ kodlar.ProcOfLine(basla, vbext_pk_Proc), vbext_pk_Proc) i=i+1 Loop Else Err.Clear End If Next Dosya = Dir wb.Close False Wend End Sub API ile Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub Tempo() MsgBox "Msg 1" Sleep (1000) ' pause de 1 seconde MsgBox "Msg 2" Sleep (3000) ' pause de 3 seconde MsgBox "Msg 3" End Sub 'OnTime Metodu ile Sub ALuumer() MsgBox "Il faut attendre" Application.OnTime Now + TimeValue("00:00:15"), "Eteindre" End Sub Sub Eteindre() MsgBox "15 secondes ce sont coules" End Sub
Buton kliklendiinde, class modl harekete geecektir. [Class CBtnEvents] Public WithEvents oBtn As MSForms.CommandButton Private Sub oBtn_Click() '... Kodlarnz End Sub 'UserFormda Dim oEvents As New Collection Private Sub Userform_Initialize() Dim oBtnEvts As CBtnEvents Set oBtnEvts = New CBtnEvents Set oBtnEvts.oBtn = FrmFieldShow.Controls.Add( _ bstrprogid:="forms.commandbutton.1", _ Name:="CmdToG", Visible:=True) With oBtnEvts.oBtn .Top = 50 .Height = 25 .Width = 100 .Left = (FrmFieldShow.Width / 2 - (100 / 2)) .Caption = "Ok" End with oEvents.Add oBtnEvts End Sub Sub deneme() Dim i As Integer For i = 1 To Worksheets.Count Worksheets(i).[a1].Value = Worksheets("sayfa1").[a1] Next i End Sub bu kod ile sayfa1 deki a1 hcresindeki veriyi dier sayfalara atabilrsin Sub kont() baksut = "AI" kontsut = "AL" son = Cells(65536, baksut).End(3).Row For x = 1 To son - 1 For y = x + 1 To son If Cells(x, baksut) = Cells(y, baksut) And Cells(y, kontsut) = "" Then Cells(y, kontsut) = Cells(x, kontsut) Next y Next x End Sub
Application.Dialogs(xlDialogOutline).Show End Sub Sub Dialog_53() Application.Dialogs(xlDialogPageSetup).Show End Sub Sub Dialog_54() Application.Dialogs(xlDialogParse).Show End Sub Sub Dialog_55() Application.Dialogs(xlDialogPasteSpecial).Show End Sub Sub Dialog_56() Application.Dialogs(xlDialogPatterns).Show End Sub Sub Dialog_57() Application.Dialogs(xlDialogPrint).Show End Sub Sub Dialog_58() Application.Dialogs(xlDialogPrinterSetup).Show End Sub Sub Dialog_59() Application.Dialogs(xlDialogPrintPreview).Show End Sub Sub Dialog_60() Application.Dialogs(xlDialogProperties).Show End Sub Sub Dialog_61() Application.Dialogs(xlDialogProtectDocument).Show End Sub Sub Dialog_62() Application.Dialogs(xlDialogProtectSharing).Show End Sub Sub Dialog_63() Application.Dialogs(xlDialogPublishAsWebPage).Show End Sub Sub Dialog_64() Application.Dialogs(xlDialogReplaceFont).Show End Sub Sub Dialog_65() Application.Dialogs(xlDialogRowHeight).Show End Sub Sub Dialog_66() Application.Dialogs(xlDialogRun).Show End Sub Sub Dialog_67() Application.Dialogs(xlDialogSaveAs).Show End Sub Sub Dialog_68() Application.Dialogs(xlDialogSaveWorkbook).Show End Sub Sub Dialog_69() Application.Dialogs(xlDialogSaveWorkspace).Show End Sub Sub Dialog_70() Application.Dialogs(xlDialogScenarioAdd).Show End Sub Sub Dialog_71() Application.Dialogs(xlDialogScenarioCells).Show End Sub Sub Dialog_72() Application.Dialogs(xlDialogScenarioMerge).Show End Sub Sub Dialog_73() Application.Dialogs(xlDialogSelectSpecial).Show End Sub Sub Dialog_74() Application.Dialogs(xlDialogSetBackgroundPicture).Show End Sub Sub Dialog_75() Application.Dialogs(xlDialogSetPrintTitles).Show End Sub Sub Dialog_76() Application.Dialogs(xlDialogShowToolbar).Show End Sub Sub Dialog_77() Application.Dialogs(xlDialogSort).Show End Sub Sub Dialog_78() Application.Dialogs(xlDialogStandardFont).Show End Sub
For i = 1 To Cells(65536, 1).End(xlUp).Row Cells(i, 2) = UBound(Split(Cells(i, 1), ",")) + 1 Next i A1hucresine =YUVARLA(A1;-5) 'B2hucresine =YUVARLA(B2;-5) 'C3hcresine =YUVARLA(C3;-5) Sub yuvarla() [A1] = Round((Range("A1").Value) / 50000) * 50000 [B2] = Round((Range("B2").Value) / 50000) * 50000 [C3] = Round((Range("C3").Value) / 50000) * 50000 End Sub Veriler Sheet1 de A stununda isimler, B stununda deerleri, Sonular sheet2 ye A ve B stununa yazlyor. Sub a() Dim isim, deger As Variant Dim rng As Range Dim i, z As Integer i=2 z=1 Do If Cells(i, 1).Value = "" Then GoTo bitti If Range([A1], [A10000]).Find(What:=Cells(i, 1).Value, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows).Row < i Then GoTo devam2 ReDim isim(z) ReDim deger(z) isim(z) = Cells.Find(What:=Cells(i, 1).Value, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows).Value deger(z) = Cells(i, 1).Offset(0, 1).Value hcr = i Do On Error Resume Next Set rng = Range(Cells(hcr, 1), [A10000]).FindNext If rng.Row = hcr Then GoTo devam hcr = rng.Row deger(z) = deger(z) + rng.Offset(0, 1).Value Loop devam: Sheets(2).Cells(z, 1).Value = isim(z) Sheets(2).Cells(z, 2).Value = deger(z) z=z+1 devam2: i=i+1 Loop bitti: End Sub Worksheets(Array("Sheet1","Sheet2")) Sub KorumaKaldir() Dim ws As Worksheet For Each ws In Worksheets ws.Unprotect ("a") Next End Sub Sub KorumaKoy() Dim ws As Worksheet For Each ws In Worksheets ws.Protect ("a") Next End Sub
UserForm un Initialize olayna da yazabilirsiniz Dim Ctr As Control Dim Say As Integer Say = 0 For Each Ctr In Controls If TypeName(Ctr) = "TextBox" Then Say = Say + 1 With Controls("TextBox" & (Say)).Font .Bold = 1 .Size = 12 .Name = "Verdana" .Italic = 1 End With Next End Sub UserForm un Initialize olayna da yazabilirsiniz Private Sub CommandButton1_Click() Say = 0 For Each Ctr In Controls If TypeName(Ctr) = "TextBox" Then Say = Say + 1 With Controls("TextBox" & (Say)) .Font.Bold = 1 .Font.Size = 12 .Font.Name = "Verdana" .Font.Italic = 1 .BackColor = &HC0FFC0 .ForeColor = &HFF& End With Next End Sub Sub birincisayfaharicsil() Application.DisplayAlerts = False While Worksheets.Count > 1 Sheets(2).Delete Wend Application.DisplayAlerts = True End Sub Sub birincisayfaharicsil() Application.DisplayAlerts = False While Worksheets.Count > 1 Sheets(2).Delete Wend Application.DisplayAlerts = True End Sub Sub Dialog_15() Application.Dialogs(xlDialogConsolidate).Show End Sub Private Sub CommandButton1_Click() For a=1 To sheets.count For Each hucre In sheets(a).[a1:e20] If hucre.Interior.Color = vbYellow Then If hucre.MergeCells = True Then sheets(a).select hucre.Select Selection.ClearContents Else hucre.ClearContents End If End If Next Next End Sub Sub Verbundene_Zellen() Dim cell As Range For Each cell In ActiveSheet.UsedRange If cell.MergeCells = True Then cell.Interior.ColorIndex = 3 Next End Sub
Sub Bo_Alan_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive(ds.GetDriveName("C:\")) s = UCase(d) & " Srcsnde Bo Alan:" & Chr(13) _ + vbCrLf & FormatNumber(d.AvailableSpace) s = s & " Bytes" MsgBox s End Sub Sub BosOlaniSil() Dim hucre As Range For Each hucre In Range("A1:A10") If hucre = Empty Then hucre.Rows.Select Selection.Delete Shift:=xlUp End If Next hucre End Sub 'Bu kodlar sadece A1:A10 Hcre aral iindir. Siz kendi ihtiyacnza gre For Each hucre In Range("A1:A10") 'kod satrn deitiriniz. Sub sil() On Error Resume Next Range("A1:A1000").SpecialCells(4).Delete End Sub Sub BackgroundColors() For Each cell In Range("a1:a10") If Not IsError(cell.Value) Then With cell.Interior Select Case cell.Value Case Is = Empty .ColorIndex = 10 Case Is = "?" .ColorIndex = 6 Case Else .ColorIndex = 0 'xlAutomatic End Select End With Else cell.Interior.ColorIndex = xlAutomatic End If Next cell End Sub Sub dene() For i = 2 To 1200 If Cells(i, 1) = "" Then Range(Cells(i - 1, 1), Cells(i - 1, 5)).Copy Cells(i, 1).PasteSpecial End If Next i End Sub Sub satirgizle() Dim i As Integer For i = 1 To 15 If Sheets("Sayfa1").Cells(i, 1).Value <> "" Then Rows(i).Hidden = False Else Sheets("Sayfa1").Rows(i).Hidden = True End If Next i End Sub
Sub stungizle() Dim i As Integer For i = 1 To 15 If Sheets("Sayfa1").Cells(i, 1).Value <> "" Then Column(i).Hidden = False Else Sheets("Sayfa1").Column(i).Hidden = True End If Next i End Sub Sub listele() For x = [b65526].End(3).Row To 2 Step -1 If Cells(x, 2).Value <= Empty Then Rows(x).Delete Next End Sub Sub SpreadOut() Dim bossat As Integer, J As Integer bossat = InputBox("Ka satr Olacak?", "Bo Satr Ekle") ActiveCell.Offset(1, 0).Select While ActiveCell.Value > "" And bossat > 0 For J = 1 To bossat Selection.EntireRow.Insert Next J ActiveCell.Offset(bossat + 1, 0).Select Wend End Sub Sub bossatirsil() For a = 1 To Sheets.Count sat = Sheets(a).Cells.SpecialCells(xlCellTypeLastCell).Row sut = Sheets(a).Cells.SpecialCells(xlCellTypeLastCell).Column For b = sat To 1 Step -1 If WorksheetFunction.CountA(Sheets(a).Rows(b)) = 0 Then Sheets(a).Rows(b).Delete Next For c = sut To 1 Step -1 If WorksheetFunction.CountA(Sheets(a).Columns(c)) = 0 Then Sheets(a).Columns(c).Delete Next Next End Sub Sub sil() For x = [b65526].End(3).Row To 2 Step -1 If Cells(x, 2).Value <= Empty Then Rows(x).Delete Next End Sub Sub Gizle() For Each t In Range("C9:C85").Cells If t.Value = "" Then 'bo hcreleri gizler t.EntireRow.Hidden = True End If Next t End Sub Sub Gster() For Each t In Range("C9:C85").Cells If t.Value = "" Then 'bo hcreleri gsterir t.EntireRow.Hidden = False End If Next t End Sub Sub satirgizle() Dim i As Integer For i = 1 To 15 If Sheets("Sayfa1").Cells(i, 1).Value <> "" Then Rows(i).Hidden = False Else Sheets("Sayfa1").Rows(i).Hidden = True End If Next i End Sub
Sub Bul_Sil() Dim hucre As Range For Each hucre In Range("B5:B25") Application.StatusBar = hucre.Address(False, False) '_______1 nci ALTERNATF (GZLEME)_______ If hucre.Value = "" Then hucre.EntireRow.Hidden = True '_______2 nci ALTERNATF (SLME)_______ 'If hucre.Value = "" Then hucre.Delete Shift:=xlUp Next hucre Application.StatusBar = False End Sub Sub bossatirsil() For a = 1 To Sheets.Count sat = Sheets(a).Cells.SpecialCells(xlCellTypeLastCell).Row sut = Sheets(a).Cells.SpecialCells(xlCellTypeLastCell).Column For b = sat To 1 Step -1 If WorksheetFunction.CountA(Sheets(a).Rows(b)) = 0 Then Sheets(a).Rows(b).Delete Next For c = sut To 1 Step -1 If WorksheetFunction.CountA(Sheets(a).Columns(c)) = 0 Then Sheets(a).Columns(c).Delete Next Next End Sub rnek-1: Sub DelEmptyRow() Rng = Selection.Rows.Count ActiveCell.Offset(0, 0).Select Application.ScreenUpdating = False For i = 1 To Rng If ActiveCell.Value = "" Then ' You can replace "" Selection.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If Next i Application.ScreenUpdating = True End Sub 'rnek-2: Sub BosSatirlariSil() Dim LastRow As Long, r As Long LastRow = ActiveSheet.UsedRange.Rows.Count LastRow = LastRow + ActiveSheet.UsedRange.Row - 1 Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Private Sub UserForm_Initialize() dolu_son_satr = Sheets("Sevkiyat").Cells(65536, "A").End(xlUp).Row ListBox1.RowSource = "Sevkiyat!A6:I" & dolu_son_satr ListBox1.ColumnHeads = True ListBox1.ColumnCount = 9 ListBox1.ListIndex = 0 Satirsayisi = ListBox1.ListCount Label12.Caption = Satirsayisi End Sub Sub auto_close() Range("A:A").Select Selection.SpecialCells(xlCellTypeBlanks).Select Selection.EntireRow.Delete Range("A1").Select End Sub
Sub sutungizle() Dim i As Integer For i = 1 To 15 If Sheets("Sayfa1").Cells(i, 1).Value <> "" Then Rows(i).Hidden = False Else Sheets("Sayfa1").Rows(i).Hidden = True End If Next i End Sub Sub DeleteEmptyRows() LastRow = ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Sub ayr() totalrows = ActiveSheet.UsedRange.Rows.Count For Row = totalrows To 2 Step -1 If Cells(Row, 1).Value <> Cells(Row - 1, 1).Value Then Rows(Row).Insert Next Row End Sub Option Explicit Sub Leerzeilenlschen() Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete End Sub Sub DeleteEmptyRows() LastRow = ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub
Dim Ayin_Ilk_Gunu As Date, Ayin_Son_Gunu As Date, Hedef As Range, Adres As String Ayin_Ilk_Gunu = DateSerial(Year(Now), Month(Now), 1) Ayin_Son_Gunu = DateSerial(Year(Now), Month(Now) + 1, 1) - 1
On Error Resume Next ActiveWorkbook.Names("Bayramlar").Delete On Error GoTo 0 ActiveWorkbook.Names.Add Name:="Bayramlar", RefersToR1C1:= _ "={" & CDbl(CDate("23.04.2007")) & ";" & CDbl(CDate("19.05.2007")) & ";" & CDbl(CDate("23.10.2007")) & ";" & CDbl(CDate("24.10.2007")) & ";" CDbl(CDate("29.10.2007")) & ";" & CDbl(CDate("31.12.2007")) & ";" & CDbl(CDate("01.01.2008")) & ";" & CDbl(CDate("02.01.2008")) & ";" & CDbl( Set Hedef = Range("A5") Hedef = Ayin_Ilk_Gunu Hedef.NumberFormat = "DD" With Hedef Adres = .Address(True, False) .Select .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:= _ "=VE(" & Adres & "<>"""";YADA(DEL(EHATALIYSA(DEYARA(" & Adres & ";Bayramlar;1;0)));HAFTANINGN(" & Adres & ";2)=6;HAFTANING .FormatConditions(1).Interior.ColorIndex = 3 End With With Hedef(2, 1) .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:= _ "=VE(" & Adres & "<>"""";YADA(DEL(EHATALIYSA(DEYARA(" & Adres & ";Bayramlar;1;0)));HAFTANINGN(" & Adres & ";2)=6;HAFTANING .FormatConditions(1).Interior.ColorIndex = 3 End With
Hedef.DataSeries Rowcol:=xlRows, Type:=xlChronological, Date:=xlDay, _ Step:=1, stop:=CDbl(Ayin_Son_Gunu), Trend:=False Hedef.AutoFill Destination:=Range(Hedef, Hedef.End(xlToRight)), Type:=xlFillDefault Hedef(2, 1) = Format(Hedef(1, 1), "DDD") Hedef(2, 1).AutoFill Destination:=Range(Hedef(2, 1), Hedef.End(xlToRight)(2, 1)), Type:=xlFillDefault Range(Hedef(2, 1).EntireColumn, Hedef.End(xlToRight)(2, 1).EntireColumn).Columns.AutoFit Hedef(3, 1).Formula = "=IF(AND(OR(WEEKDAY(" & Adres & ",2)=1,WEEKDAY(" & Adres & ",2)=3,WEEKDAY(" & Adres & ",2)=5),ISERROR(VLOOKUP Hedef(3, 1).AutoFill Destination:=Range(Hedef(3, 1), Hedef.End(xlToRight)(3, 1)), Type:=xlFillDefault Set Hedef = Nothing End Sub Forml A1 e kadar =NSAT((A1-HAFTANINGN(A1;2)-TARH(YIL(A1+4-HAFTANINGN(A1;2));1;-10))/7) Sub Test() ActiveSheet.UsedRange.Select Application.CommandBars.FindControl(ID:=1849).Execute End Sub Sub Test2() For i = 1 To Worksheets.Count Sheets(i).Select Sheets(i).UsedRange.Select Application.CommandBars.FindControl(ID:=1849).Execute Next End Sub Sub DoBox() ActiveSheet.Cells.Find What:="", LookAt:=xlWhole Application.CommandBars("Worksheet Menu Bar").FindControl( _ ID:=1849, recursive:=True).Execute End Sub
Private Sub CheckBox4_Click() If CheckBox4.Value = True Then CheckBox3.Enabled = False End Sub Private Sub CommandButton1_Click() If TextBox1.Text = "" Then Exit Sub If CheckBox1.Value = True Then look = 1 Else look = 2 If CheckBox3.Value = True Then bas = 1 Else bas = 2 ListBox1.Clear Set c = Range("a:a").Find(TextBox1, LookIn:=xlValues, MatchCase:=CheckBox2.Value, LookAt:=look, SearchDirection:=bas) If Not c Is Nothing Then firstAddress = c.Address ListBox1.AddItem ListBox1.List(0, 0) = c.Address ListBox1.List(0, 1) = c basla: Set c = Range("a:a").FindNext(c) If Not c Is Nothing And c.Address <> firstAddress Then a=a+1 ListBox1.AddItem ListBox1.List(a, 0) = c.Address ListBox1.List(a, 1) = c GoTo basla End If End If If CheckBox4.Value = 0 Then Exit Sub If ListBox1.ListCount > 0 Then For x = 0 To ListBox1.ListCount - 2 For y = x + 1 To ListBox1.ListCount - 1 If Val(Replace(ListBox1.List(x, 0), "$A$", "")) > Val(Replace(ListBox1.List(y, 0), "$A$", "")) Then Call swap(x, y) Next y, x End If End Sub Private Sub ListBox1_Click() Range(ListBox1.List(ListBox1.ListIndex, 0)).Select End Sub Sub swap(ind1, ind2) Set l = ListBox1 ara = l.List(ind1, 0) l.List(ind1, 0) = l.List(ind2, 0) l.List(ind2, 0) = ara ara = l.List(ind1, 1) l.List(ind1, 1) = l.List(ind2, 1) l.List(ind2, 1) = ara End Sub Private Sub Worksheet_Change(ByVal Target As Range) Dim Bul As Range, Adres On Error GoTo HATA If Target.Column = 1 And Not Target = "" Then Set Bul = Range("A:A").Find(Target, LookAt:=xlWhole) Adres = Bul.Address Set Bul = Range("A:A").FindNext(Bul) If Not Bul.Address = Adres Then MsgBox Target & " deeri daha nce girilmi" Target.Select End If End If HATA: End Sub Sub Dialog_32() Application.Dialogs(xlDialogFormulaFind).Show End Sub
Private Sub CommandButton1_Click() Application.CommandBars.FindControl(ID:=1849).Execute End Sub ListBox1.Clear son = Cells(65536, 1).End(xlUp).Row For i = 1 To son If Cells(i, 7).Value = ComboBox1.Value Then Cells(i, 1).Select c=c+1 For y = 1 To 10 ListBox1.AddItem ListBox1.List(c - 1, y - 1) = Cells(i, y + 1).Value Next End If Next
End Sub Private Sub ListBox1_Click() End Sub Private Sub UserForm_Initialize() ComboBox1.AddItem "l Sosyal Hizmetler Mdrl" ComboBox1.AddItem "Gzde Birsz ocuk Yuvas Mdrl" ComboBox1.AddItem "75. Yl Huzurevi Mdrl" ComboBox1.AddItem "Aile Danma Merkezi Mdrl" ListBox1.ColumnCount = 10 End Sub Sub Bul_Renklendir() Dim neyi As String, rng As Range, alan As Range neyi = Application.InputBox("A1:D20 hcrelerinde, bulmak istediiniz veri", , "") Set alan = Range("A1:D20") alan.Interior.ColorIndex = xlNone For Each rng In alan If StrConv(rng, vbProperCase) = StrConv(neyi, vbProperCase) Then rng.Interior.ColorIndex = 35 End If Next rng Set alan = Nothing End Sub
For Each hucre In Range("a2:a" & WorksheetFunction.CountA(Range("a1:a65000"))) If StrConv(hucre.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then hucre.Select TextBox1 = ActiveCell.Offset(0, 1).Value TextBox2 = ActiveCell.Offset(0, 2).Value TextBox3 = ActiveCell.Offset(0, 3).Value End If Next End Sub Private Sub CommandButton2_Click() 'deitir ActiveCell.Offset(0, 1).Value = TextBox1.Value ActiveCell.Offset(0, 2).Value = TextBox2.Value ActiveCell.Offset(0, 3).Value = TextBox3.Value End Sub Private Sub CommandButton3_Click() 'sil satr = ActiveCell.Row Rows(satr).Delete Shift:=xlUp 'say = WorksheetFunction.CountA(Range("A2:A65000")) For i = 1 To WorksheetFunction.CountA(Range("a2:a65000")) Cells(i + 1, 1) = i Next End Sub Private Sub CommandButton4_Click() 'kaydet Dim say As Integer For Each bak In Range("A1:A" & WorksheetFunction.CountA(Range("A1:A65000"))) If bak.Value = cbAd.Value Then MsgBox "Bu Kayt numaras bulundu." Exit Sub End If Next bak For Each bak In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000"))) If StrConv(bak.Value, vbUpperCase) = StrConv(cbAd.Value, vbUpperCase) Then MsgBox "Bu isimde bir kaydnz bulundu" Exit Sub End If Next bak b = WorksheetFunction.CountA(Sheets("sayfa1").Range("A:A")) Sheets("sayfa1").Range("a" & b + 1).Select ActiveCell = ComboBox1.Value ActiveCell.Offset(0, 1) = TextBox1.Value ActiveCell.Offset(0, 2) = TextBox2.Value ActiveCell.Offset(0, 3) = TextBox3.Value End Sub Private Sub UserForm_Initialize() b = WorksheetFunction.CountA(Range("A2:A6500")) ComboBox1.RowSource = "sayfa1!a2:a" & b End Sub
Dim
Sub AddBullets() Dim Bullet As String Dim Dash As String Dim Cel As Range Dim Str As String Dim i As Long Bullet = " " Dash = " - " 'select which cells to perform an action on For Each Cel In Selection Str = Cel.Value 'If there is already a bullet there then put a dash in its place If Left(Str, Len(Bullet)) = Bullet Then Str = Right(Str, Len(Str) - 2) Cel.Value = Dash & Str Else 'If there is already a dash there then trim back to normal text If Left(Str, Len(Dash)) = Dash Then Str = Trim(Cel.Value) i = Len(Str) - 1 If i >= 0 Then Cel.Value = Trim(Right(Str, i)) End If Else 'Otherwise add the bullet Cel.Value = Bullet & Str End If End If 'Go to the next cell in the selection and do the same thing Next Cel End Sub Bu kod alma sayfasndaki 20 deerlerini 19 ile deitirir. Sub BulDegistir() On Error GoTo ERRORHANDLER ActiveSheet.TransitionFormEntry = True Cells.Replace _ What:="20", _ Replacement:="19", _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ MatchCase:=False ERRORHANDLER: ActiveSheet.TransitionFormEntry = False End Sub Sub Bul_Renklendir() Dim neyi As String, rng As Range, alan As Range neyi = Application.InputBox("A1:D20 hcrelerinde, bulmak istediiniz veri", , "") Set alan = Range("A1:D20") alan.Interior.ColorIndex = xlNone For Each rng In alan If StrConv(rng, vbProperCase) = StrConv(neyi, vbProperCase) Then rng.Interior.ColorIndex = 35 End If Next rng Set alan = Nothing End Sub
For Each hucre In Range("a2:a" & WorksheetFunction.CountA(Range("a1:a65000"))) If StrConv(hucre.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then hucre.Select TextBox1 = ActiveCell.Offset(0, 1).Value TextBox2 = ActiveCell.Offset(0, 2).Value TextBox3 = ActiveCell.Offset(0, 3).Value End If Next End Sub Private Sub CommandButton2_Click() ActiveCell.Offset(0, 1).Value = TextBox1.Value ActiveCell.Offset(0, 2).Value = TextBox2.Value ActiveCell.Offset(0, 3).Value = TextBox3.Value End Sub Private Sub CommandButton3_Click() satr = ActiveCell.Row Rows(satr).Delete Shift:=xlUp 'say = WorksheetFunction.CountA(Range("A2:A65000")) For i = 1 To WorksheetFunction.CountA(Range("a2:a65000")) Cells(i + 1, 1) = i Next End Sub Private Sub CommandButton4_Click() b = WorksheetFunction.CountA(Sheets("sayfa1").Range("A:A")) Sheets("sayfa1").Range("a" & b + 1).Select ActiveCell = ComboBox1.Value ActiveCell.Offset(0, 1) = TextBox1.Value ActiveCell.Offset(0, 2) = TextBox2.Value ActiveCell.Offset(0, 3) = TextBox3.Value End Sub Private Sub UserForm_Initialize() b = WorksheetFunction.CountA(Range("A2:A6500")) ComboBox1.RowSource = "sayfa1!a2:a" & b End Sub Dim index As Integer Private Sub ComboBox1_Click() index = ComboBox1.ListIndex + 1 End Sub Private Sub CommandButton1_Click() End End Sub Private Sub CommandButton2_Click() For a = 1 To 13 Controls("combobox" & a).RowSource = "" Cells(index, a) = Controls("combobox" & a) If IsNumeric(Controls("combobox" & a)) = True Then Cells(index, a) = Controls("combobox" & a) * 1 Next Call UserForm_Initialize End Sub Private Sub UserForm_Initialize() For a = 1 To 13 ReDim Preserve comb(13) Set comb(a).comb = Controls("combobox" & a) adres = Range(Cells(1, a), Cells(Cells(65536, 1).End(3).Row, a)).Address Controls("combobox" & a).RowSource = adres Next End Sub 'classmodle Public WithEvents comb As MSForms.ComboBox Dim a As Integer Private Sub comb_Click() If a = 1 Then Exit Sub For a = 1 To 13 If UserForm1.Controls("combobox" & a).Name <> comb.Name Then UserForm1.Controls("combobox" & a).ListIndex = comb.ListIndex Next End Sub Private Sub comb_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) a=1 End Sub
Declare Function sndPlaySound Lib "winmm.dll" _ Alias "sndPlaySoundA" ( _ ByVal SoundName As String, _ ByVal Flags As Long) As Long Sub PlayWav(ByVal WavFileName As String) Call sndPlaySound(WavFileName, 0) End Sub
Sub TestWav() Call PlayWav(ThisWorkbook.Path + "\pir.wav") End Sub Sub Markierung() Dim Mark_Bereich Mark_Bereich = Selection.Address(False, False) MsgBox Mark_Bereich End Sub Thisworkbooka Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim Phad As String Phad = ThisWorkbook.Path ActiveWorkbook.SaveCopyAs Filename:=Phad & "\" & Format(Now, "DD-MM-YY_hh-mm") & "_Backup_Beispielmappe_113.XLS" End Sub Sub Klasr_Kopyala() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.CopyFolder "D:\Excelrnekleri", "C:\SXS" End Sub Sub EditionCopierOK() Application.CommandBars(1).Controls(2).Controls(4).Enabled = True End Sub Sub EditionCopierNo() Application.CommandBars("Edit").FindControl(ID:=19).Enabled = False End Sub Sub menuOutilsOptNo() Application.CommandBars("Tools").FindControl(ID:=522).Enabled = False End Sub Sub menuOutilsOptok() Application.CommandBars("Tools").FindControl(ID:=522).Enabled = True End Sub sheets("sayfa2").PrintOut Sn tb belki iinize yarar birde bunu deneyin a1 hresine yazdnz Sub Test() Sheets("sayfa2").PrintOut From:=1, To:=[a1].Value End Su BU KOD BUTONLARDAN VERDNZ KOMUTLARI YERNE GETRMEDEN NCE KULLANICIYA UYARI VERR Dim cevap cevap = MsgBox("Kayd Silmek stediinize Eminmisiniz ? Evet Dersen Veri Kalc Olarak Silinecek ! ", vbYesNo + vbQuestion + vbDefaultcmdsil + vbAp If cevap = vbNo Then End End If
Sub CommandBarControlID_List() Dim a, b, c Application.ScreenUpdating = False For Each ComBar In Application.CommandBars If ComBar.Name = "test" Then ComBar.Delete Next Set ComBar = Application.CommandBars.Add(Name:="test", Position:=msoBarTop) b=0 c=1 For a = 1 To 50000 On Error Resume Next Set cbb = ComBar.Controls.Add(ID:=a) If Err.Number <> 0 Then GoTo weiter cbb.CopyFace With Workbooks("FaceIDs").Sheets(1) .Cells((c Mod 100) + 1, (c \ 100) + b + 1).Formula = a .Cells((c Mod 100) + 1, (c \ 100) + b + 2).Activate ActiveSheet.Paste .Cells((c Mod 100) + 1, (c \ 100) + b + 3).Formula = cbb.Caption End With If (c + 1) Mod 100 = 0 Then b = b + 3 c=c+1 weiter: Application.CommandBars("test").FindControl(ID:=a).Delete Err.Clear Next End Sub Sub CommandBarFaceID_List() Dim a, b Application.ScreenUpdating = False For Each ComBar In Application.CommandBars If ComBar.Name = "test" Then ComBar.Delete Next On Error Resume Next Set ComBar = Application.CommandBars.Add(Name:="test", Position:=msoBarTop) Set cbb = ComBar.Controls.Add(ID:=1) b=0 For a = 1 To 3518 With cbb .FaceId = a .CopyFace End With With ThisWorkbook.Sheets(1) .Cells((a Mod 100) + 1, (a \ 100) + b + 1).Formula = a .Cells((a Mod 100) + 1, (a \ 100) + b + 2).Activate ActiveSheet.Paste End With If (a + 1) Mod 100 = 0 Then b = b + 2 Next End Sub Sub CommandBar_List() Application.ScreenUpdating = False Dim a, b, c, cbc, d b=1 d=0 For Each a In Application.CommandBars Cells(b + d, 1) = a.Name Cells(b + d, 2) = "Item-no: " & b For Each cbc In a.Controls d=d+1 Cells(b + d, 3) = cbc.Caption Cells(b + d, 4) = Cells(cbc.Type, 10) Cells(b + d, 5) = "Type: " & cbc.Type Cells(b + d, 6) = "ID: " & cbc.ID Next b=b+1 Next End Sub
Sheets("Liste").Rows(Cells(2, 1) & ":" & Cells(2, 1)).Delete Shift:=xlUp BU KOMUT BUTONU AAI YUKARI HAREKET ETTRR(ENTERE BASTIKA) Private Sub CommandButton1_Click() Sheets("sayfa2").Select Range("A1").Show End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) CommandButton1.Top = ActiveCell.Rows.Top End Sub Private Sub CommandButton1_Click() Dim NbreEnreg As Integer With UserForm1 .ComboBox1.RowSource = "A1:A9" NbreEnreg = .ComboBox1.ListCount .ComboBox1.ListRows = NbreEnreg .Show 'bu satr silebilirsiniz End With End Sub Sorunu ikitrl anladm. 1.Hcreye yazdn derleri textboxlara getirmek. Kod: Private Sub UserForm_Initialize() TextBox1.Text = Range("b1").Text TextBox2.Text = Range("b2").Text TextBox3.Text = Range("b3").Text TextBox4.Text = Range("b4").Text TextBox5.Text = Range("b5").Text End Sub 2.TextBpxa Yazdn deerleri lgili hcrelere aktarmak. Kod: Private Sub CommandButton1_Click() Range("b1").Select ActiveCell.Formula = TextBox1 Range("b2").Select ActiveCell.Formula = TextBox2 Range("b3").Select ActiveCell.Formula = TextBox3 Range("b4").Select ActiveCell.Formula = TextBox4 Range("b5").Select ActiveCell.Formula = TextBox5 End Sub Sorunu ikitrl anladm. 1.Hcreye yazdn derleri textboxlara getirmek. Kod: Private Sub UserForm_Initialize() TextBox1.Text = Range("b1").Text TextBox2.Text = Range("b2").Text TextBox3.Text = Range("b3").Text TextBox4.Text = Range("b4").Text TextBox5.Text = Range("b5").Text End Sub 2.TextBpxa Yazdn deerleri lgili hcrelere aktarmak.Kod: Private Sub CommandButton1_Click() Range("b1").Select ActiveCell.Formula = TextBox1 Range("b2").Select ActiveCell.Formula = TextBox2 Range("b3").Select ActiveCell.Formula = TextBox3 Range("b4").Select ActiveCell.Formula = TextBox4 Range("b5").Select ActiveCell.Formula = TextBox5 End Sub
Private Sub CommandButton1_Click() TextBox1 = Cells(2, 1) ComboBox1 = Cells(2, 2) TextBox2 = Cells(2, 3) TextBox3 = Cells(2, 4) End Sub 'EN SONA GT Private Sub CommandButton4_Click() Dim say As Integer say = WorksheetFunction.CountA(Range("A1:A65000")) TextBox1 = Cells(say, 1) ComboBox1 = Cells(say, 2) TextBox2 = Cells(say, 3) TextBox3 = Cells(say, 4) End Sub 'BR,BR GER GT Private Sub CommandButton2_Click() If TextBox1 = 1 Then Exit Sub Else TextBox1 = TextBox1 - 1 ComboBox1 = Cells(TextBox1 + 1, 2) TextBox2 = Cells(TextBox1 + 1, 3) TextBox3 = Cells(TextBox1 + 1, 4) End If End Sub 'BR,BR LER GT Private Sub CommandButton3_Click() Dim say As Integer say = WorksheetFunction.CountA(Range("A1:A65000")) If TextBox1 = say Then Exit Sub Else TextBox1 = TextBox1 + 1 ComboBox1 = Cells(TextBox1 + 1, 2) TextBox2 = Cells(TextBox1 + 1, 3) TextBox3 = Cells(TextBox1 + 1, 4) End If End Sub Sub Set_Protection() On Error GoTo errorHandler Dim myDoc As Worksheet Dim cel As Range Set myDoc = ActiveSheet myDoc.Unprotect For Each cel In myDoc.UsedRange If Not cel.HasFormula And _ Not TypeName(cel.Value) = "Date" And _ Application.IsNumber(cel) Then cel.Locked = False cel.Font.ColorIndex = 5 Else cel.Locked = True cel.Font.ColorIndex = xlColorIndexAutomatic End If Next myDoc.Protect Exit Sub errorHandler: MsgBox Error End Sub
Sub AfficheBoutons() Dim NewBarreOutil As CommandBar Dim NewBouton As CommandBarButton Dim i As Integer, IconOn As Integer, IconOff As Integer 'Supprime la barre si elle existe dj On Error Resume Next Application.CommandBars("BarBouton").Delete On Error GoTo 0 Set NewBarreOutil = Application.CommandBars.Add _ (Name:="BarBouton", temporary:=True) NewBarreOutil.Visible = True IconOn = 1 IconOff = 200 For i = IconOn To IconOff Set NewBouton = NewBarreOutil.Controls.Add _ (Type:=msoControlButton, ID:=2950) NewBouton.FaceId = i NewBouton.Caption = "FaceID = " & i Next i NewBarreOutil.Width = 700 NewBarreOutil.Left = 50 NewBarreOutil.Top = 120 End Sub Sub SupMenuBar() Application.CommandBars("Worksheet Menu Bar").Enabled = False End Sub Private Sub UserForm_Activate() Do If UserForms.Count < 1 Then Exit Sub DoEvents If TypeName(ActiveControl) = "CommandButton" Then _ Label1.Caption = ActiveControl.Caption Loop End Sub Sub Dme1_Tklat() Dim a Dim x a = ActiveSheet.Shapes.Count For x = 1 To a ActiveSheet.Shapes(x).Visible = False Next End Sub Private Sub CommandButton1_Click() CommandButton3.Enabled = False CommandButton4.Enabled = False CommandButton5.Enabled = False End Sub Private Sub CommandButton2_Click() CommandButton3.Enabled = True CommandButton4.Enabled = True CommandButton5.Enabled = True End Sub Sub Shape_Index_Name() Dim myVar As Shapes Dim shp As Shape Set myVar = Sheets(1).Shapes For Each shp In myVar MsgBox "Index = " & shp.ZOrderPosition & vbCrLf & "Name = " _ & shp.Name Next End Sub
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) CommandButton1.BackColor = vbYellow End Sub Private Sub UserForm_Initialize() CommandButton1.Tag = CommandButton1.BackColor End Sub Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) CommandButton1.BackColor = CommandButton1.Tag End Sub Sub TumTanimliAlanlariSil() For Each Nm In ActiveWorkbook.Names Nm.Delete Next Nm End Sub Sub DeleteNames() Dim NameX As Name For Each NameX In Names ActiveWorkbook.Names(NameX.Name).Delete Next NameX End Sub Sub Auto_Open() ActiveWindow.Zoom = 85 End Sub 'Dosyay kaydedin. Mesela Kucult.XLS ismini verin. 'Dosyay C:\Windows\Application Data\Microsoft\Excel\Xlstart klasrne kopyalayn. Sub ButunPencerelerMinimize() Dim Pencere As Window For Each Pencere In Windows If Pencere.Visible = False Then Pencere.Visible = True Pencere.WindowState = xlMinimized Next End Sub Sub Reset_Values_All_WSheets() Dim wSht As Worksheet Dim myRng As Range Dim allwShts As Sheets Dim cel As Range Set allwShts = Worksheets For Each wSht In allwShts Set myRng = wSht.Range("A1:A5, B6:B10, C1:C5, D4:D10") For Each cel In myRng If Not cel.HasFormula And cel.Value <> 0 Then cel.Value = 0 End If Next cel Next wSht End Sub Sub protectAll() Dim myCount Dim i myCount = Application.Sheets.Count Sheets(1).Select 'Bu satr 1. sayfay (sheet) seer For i = 1 To myCount ActiveSheet.Protect If i = myCount Then End End If ActiveSheet.Next.Select Next i End Sub Sub UpperCase() Dim cell As Range For Each cell In Selection.Cells If cell.HasFormula = False Then cell = UCase(cell) End If Next End Sub
Private Sub Worksheet_Change(ByVal Target As Excel.Range) Application.EnableEvents = False Target = UCase(Target) Application.EnableEvents = True End Sub Dim Upr, Lwr, Ppr Set OriginalCell = ActiveCell Set OriginalSelection = Selection If IsEmpty(ActiveCell) Then GoTo NoneFound On Error GoTo Limiting If OriginalCell = OriginalSelection Then Selection.Select GoTo Converting Else Resume Next End If Limiting: On Error GoTo NoneFound Selection.SpecialCells(xlCellTypeConstants, 3).Select Converting: Application.StatusBar = "ndere Gross- und Kleinschreibung..." For Each DCell In Selection.Cells Upr = UCase(DCell) Lwr = LCase(DCell) If Upr = DCell.Value Then DCell.Value = Lwr Else DCell.Value = Upr End If Next DCell Application.StatusBar = False Exit Sub NoneFound: MsgBox "Alle Zellen der aktuelllen Auswahl enthalten Formeln oder sindleer!", vbExclamation, " Fehler aufgetreten" OriginalSelection.Select OriginalCell.Activate End Sub Sub Cree_Repert() Dim Repert As String Repert = Dir("c:\test\", vbDirectory) If Repert = "" Then MkDir "c:\test" End If End Sub Sub Liste_Repert() Dim Repert As String Repert = Dir("c:\", vbDirectory) Do While Repert <> "" 'Si Repert est un dossier. If GetAttr("c:\" & Repert) = vbDirectory Then UserForm1.ListBox1.AddItem Repert End If Repert = Dir Loop End Sub Sub ExcelDateienZhlen() With Application.FileSearch .NewSearch .LookIn = "C:\" .Filename = "*.xls" .Execute MsgBox .FoundFiles.Count End With End Sub
Sub lfdNr() Dim Nr% Dim dName$ Dim Zielordner$, Dateiname$ 'Hier den Pfad verndern Zielordner = "c:\" 'Hier den Dateinamen verndern Dateiname = "lfdNr" dName = Zielordner & Dateiname & ".ini" Close On Error Resume Next Open dName For Input As #1 If Err > 0 Then Nr = 1 Close Open dName For Output As #1 Print #1, Nr Close Exit Sub Else Input #1, Nr Close Open dName For Output As #1 Print #1, Nr + 1 Close End If ActiveCell.Value = Nr End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Set rng = Columns("C:C") If Not (Intersect(Target, rng) Is Nothing) Then rng.ColumnWidth = 30 Else rng.ColumnWidth = 10.71 End If End Sub Sub sil() Range("c1").Select Application.ScreenUpdating = False Dim hucre As Range For Each hucre In Range("c1:c" & WorksheetFunction.CountA(Range("c1:c5000"))) Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ActiveCell.EntireRow.Select Selection.Delete Shift:=xlUp Next Application.ScreenUpdating = True End Sub Sub Add_Totals() For Each NumRange In Columns("C").SpecialCells(xlConstants, xlNumbers).Areas SumAddr = NumRange.Address(False, False) NumRange.Offset(NumRange.Count, 0).Resize(1, 1).Formula = "=SUM(" & SumAddr & ")" Next NumRange End Sub Sub Add_Totals() For Each NumRange In Columns("C").SpecialCells(xlConstants, xlNumbers).Areas SumAddr = NumRange.Address(False, False) NumRange.Offset(NumRange.Count, 0).Resize(1, 1).Formula = "=SUM(" & SumAddr & ")" Next NumRange End Sub Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Application.Intersect(Target, Range("C:C")) Is Nothing Then Target(1).Value = UCase(Target(1).Value) End If Application.EnableEvents = True End Sub
Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Application.Intersect(Target, Range("C:C")) Is Nothing Then Target(1).Value = UCase(Target(1).Value) End If Application.EnableEvents = True End Sub Sub bidahabossatgizle() For i = 6 To 160 If Range("c" & i) = "" Then _ Range("c" & i).EntireRow.Hidden = True Next End Sub Sub bidahabossatgizle() For i = 6 To 160 If Range("c" & i) = "" Then _ Range("c" & i).EntireRow.Hidden = True Next Sub aktar() Dim sonsat As Long, sat As Long, i As Long, sut As Byte Sheets("2007").Select Sheets("PARCA").Range("A3:G65536").ClearContents sonsat = Cells(65536, "A").End(xlUp).Row sat = 3 If sonsat < 3 Then Exit Sub For i = 3 To sonsat If WorksheetFunction.CountIf(Sheets("PARCA").Range("C3:C65536"), Cells(i, "C")) = 0 Then For sut = 1 To 7 Sheets("PARCA").Cells(sat, sut).Value = Cells(i, sut).Value Next sut sat = sat + 1 End If Next i Sheets("PARCA").Select MsgBox "LEM TAMAM" End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Set rng = Columns("C:C") If Not (Intersect(Target, rng) Is Nothing) Then rng.ColumnWidth = 30 Else rng.ColumnWidth = 10.71 End If End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$C$4" And Target.Value = "Y" Then Target.Value = Range("C1").Value End If End Sub Sub NomClasseur() Dim Chr As String 'dclare la variable Chr = Range("Sayfa1!C1") 'Feuille Essai et cellule C1 ChDrive "C" 'si C n'est pas le disque par dfaut ChDir "C:\" ActiveWorkbook.SaveAs Filename:=(Chr) End Sub Sub NomClasseur1() Dim Month As String * 3 'seulement les 3 premires lettres Dim Year As String Month = Range("Feuil1!C1") Year = Right(Range("Feuil1!C2"), 2) 'pour ne renvoyer que 01 de 2001 ChDrive "C" ChDir "C:\ajeter\" ActiveWorkbook.SaveAs Filename:=(Month) & (Year) End Sub
Private Sub Worksheet_Calculate() Static DblWert If Range("C10") = 100 Then If Range("C10") = DblWert Then Exit Sub MsgBox "Jetzt ist der Wert in A1 100!" End If DblWert = Range("C10") End Sub Private Sub Worksheet_Change(ByVal Target As Range) Range("D1").Value = WorksheetFunction.CountBlank(Range("C5:C15")) End Sub Sub BlendeAus() Range("C5:C20").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True End Sub Sayfann kod bmne Option Explicit Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("C8:C18")) Is Nothing Then Application.CommandBars("Cell").ShowPopup End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("C8:C18")) Is Nothing Then Application.CommandBars("Cell").ShowPopup End If End Sub Sub Makro1() Sheets("Sayfa1").Copy ActiveWorkbook.SaveAs Filename:="C:\Documents And Settings\ocamsul\Belgelerim\[a1] End Sub VBA editrnde tools-referencesi sein, alan pencerede gereksiz olan tm referanslar kaldrn
Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private Declare Function GetKeyboardState Lib "user32" _ (pbKeyState As Byte) As Long Private Declare Function SetKeyboardState Lib "user32" _ (lppbKeyState As Byte) As Long Private Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 ' Maintenance string for PSS usage End Type Const Const Const Const Const VK_CAPITAL = &H14 KEYEVENTF_EXTENDEDKEY = &H1 KEYEVENTF_KEYUP = &H2 VER_PLATFORM_WIN32_NT = 2 VER_PLATFORM_WIN32_WINDOWS = 1
Dim Keys(0 To 255) As Byte Sub SetCapsOn() Dim o As OSVERSIONINFO Dim NumLockState As Boolean Dim ScrollLockState As Boolean Dim CapsLockState As Boolean ' CapsLock handling: o.dwOSVersionInfoSize = Len(o) GetVersionEx o CapsLockState = Keys(VK_CAPITAL) If CapsLockState <> True Then 'Turn capslock on If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then '===== Win95 Keys(VK_CAPITAL) = 1 SetKeyboardState Keys(0) ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then '===== WinNT 'Simulate Key Press keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0 'Simulate Key Release keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY _ Or KEYEVENTF_KEYUP, 0 End If End If End Sub Option Explicit Public Declare Function SendCDcmd Lib "winmm.dll" _ Alias "mciSendStringA" ( _ ByVal lpstrCommand As String, _ ByVal lpstrReturnString As String, _ ByVal uReturnLength As Long, _ ByVal hwndCallback As Long) As Long Dim lRet As Long Public Sub EjectCD() lRet = SendCDcmd("set CDAudio door open", vbNullString, 127, 0) End Sub Public Sub CloseCD() lRet = SendCDcmd("set CDAudio door closed", vbNullString, 127, 0) End Sub
Private Declare Function mciExecute Lib "winmm.dll" (ByVal _ lpstrCommand As String) As Long Public Sub Ap_001_Open() Call mciExecute("Set CDaudio door open") End Sub Public Sub Ap_001_Close() Call mciExecute("Set CDaudio door closed") End Sub Option Base 1 Sub main() Dim Now As String Dim a(2) As String a(1) = "set cdaudio door open" a(2) = "set cdaudio door closed" total = 1 For I = 1 To (total * 2) If Int(I / 2) = I / 2 Then Now = vbString(a(2), 0) Else Now = vbString(a(1), 0) End If Next I End Sub Dim Buff As String Dim dwR As Long Buff = Space$(100) ' Create a buffer dwR = mciSendString(Command, ByVal Buff, Len(Buff), hWnd) vbString = Buff End Function Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Cells.Count > 1 Then Exit Sub If Not Intersect(Target, Range("A1:A10")) Is Nothing Then Target.Font.Name = "Marlett" If Target = vbNullString Then Target = "a" Else Target = vbNullString End If End If End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Cells.Count > 1 Then Exit Sub If Not Intersect(Target, Range("A1:A10")) Is Nothing Then Target.Font.Name = "Marlett" If Target = vbNullString Then Target = "a" Else Target = vbNullString End If End If End Sub Private Sub CheckBox1_Click() [A1] = CheckBox1 * 20 + 120 End Sub Private Sub UserForm_Initialize() Range("a1") = 120 End Sub Private Sub CheckBox1_Click() If Me.CheckBox1.Value = False Then Range("a1") = 120 Else Range("a1") = 100 End If End Sub
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uR
Aktif sayfaya 1 tane checkbox ve kod blmne aadaki kodlar Option Explicit Private Sub CheckBox1_Click() Range("F2").Value = CheckBox1.Value End Sub 'Modle Option Explicit Sub CheckboxEinAus() With Sheets("Tabelle1").OLEObjects("CheckBox1") .Object.Value = Not .Object.Value End With End Sub Private Sub CommandButton1_Click() If CheckBox1 = True Then Sheets("Sayfa1").PrintOut ElseIf CheckBox2 = True Then Sheets("Sayfa2").PrintOut ElseIf CheckBox3 = True Then Sheets("Sayfa3").PrintOut ElseIf CheckBox4 = True Then Sheets("Sayfa4").PrintOut End If End Sub Sub MsgAscii() Dim sayi1 As Integer For sayi1 = 1 To 255 msg = msg & (sayi1) & Chr(58) & Chr(sayi1) & Space(1) Next sayi1 MsgBox msg, 64, Chr(83) & Chr(252) & Chr(108) & Chr(101) _ & Chr(121) & Chr(109) & Chr(97) & Chr(110) & Chr(32) & Chr(85) _ & Chr(90) & Chr(85) & Chr(78) & Chr(75) & Chr(214) & Chr(80) & _ Chr(82) & Chr(220) End Sub Sub Cilt_smini_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") s = d.VolumeName MsgBox s End Sub
Private mcolUndoObjects As Collection Private mUndoObject As clsUndoObject Public Function AddAndProcessObject(oObj As Object, sProperty As String, vValue As Variant) As Boolean Set mUndoObject = New clsUndoObject With mUndoObject Set .ObjectToChange = oObj .NewValue = vValue .PropertyToChange = sProperty mcolUndoObjects.Add mUndoObject If .ExecuteCommand = True Then AddAndProcessObject = True Else AddAndProcessObject = False End If End With End Function Private Sub Class_Initialize() Set mcolUndoObjects = New Collection End Sub Private Sub Class_Terminate() ResetUndo End Sub Public Sub ResetUndo() While mcolUndoObjects.Count > 0 mcolUndoObjects.Remove (1) Wend Set mUndoObject = Nothing End Sub Public Sub UndoAll() Dim lCount As Long ' On Error Resume Next For lCount = mcolUndoObjects.Count To 1 Step -1 Set mUndoObject = mcolUndoObjects(lCount) mUndoObject.UndoChange Set mUndoObject = Nothing Next ResetUndo End Sub Public Sub UndoLast() Dim lCount As Long ' On Error Resume Next If mcolUndoObjects.Count >= 1 Then Set mUndoObject = mcolUndoObjects(mcolUndoObjects.Count) mUndoObject.UndoChange mcolUndoObjects.Remove mcolUndoObjects.Count Set mUndoObject = Nothing Else ResetUndo End If End Sub Public Function UndoCount() As Long UndoCount = mcolUndoObjects.Count End Function Function GetClass() As Class1 Set GetClass = New Class1 End Function 'Bu class modl altrmak iin ise, aadaki kod kullanlr. Dim cls As Object Sub Test() Set cls = GetClass() End Sub
Bir tane classmodule ekleyin ad AppEventClass olsun. Option Explicit Public WithEvents App As Application Private Sub App_NewWorkbook(ByVal Wb As Workbook) MsgBox "A new workbook is created!" End Sub Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean) MsgBox "A workbook is closed!" End Sub Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean) MsgBox "A workbook is printed!" End Sub Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As Boolean, Cancel As Boolean) MsgBox "A workbook is saved!" End Sub Private Sub App_WorkbookOpen(ByVal Wb As Workbook) MsgBox "A workbook is opened!" End Sub Bir tane classmodule ekleyin ad EventClass olsun. Option Explicit Public WithEvents App As Application Private Sub App_NewWorkbook(ByVal Wb As Excel.Workbook) MsgBox "Application Event: New Workbook: " & Wb.Name End Sub Private Sub App_SheetActivate(ByVal Sh As Object) MsgBox "Application Event: SheetActivate: " & Sh.Name End Sub Private Sub App_WorkbookOpen(ByVal Wb As Excel.Workbook) MsgBox "Application Event: WorkbookOpen: " & Wb.Name End Sub Private Sub UserForm_Activate() For i = 6 To 1000 If Sheets("NAAT TABLO").Cells(i, 1) = "" Then GoTo 10: UserForm2.ComboBox1.AddItem (Sheets("NAAT TABLO").Cells(i, 1)) 10: Next End Sub
Toplama sonucunu alacanz Texbox3 kabul edersek aadaki kodu Textbox3'in iine yaznz. Kod: Private Sub TextBox3_Enter() TextBox3 = CInt(TextBox1) + CInt(TextBox2) End Sub
veya Kod: Private Sub TextBox3_Enter() TextBox3 = Val(TextBox1) + Val(TextBox2) End Sub ondalkl saylarda toplamas iin Kod: Private Sub TextBox3_Enter() TextBox3 = Ccur(TextBox1) + Ccur(TextBox2) End Sub Private Sub UserForm_Initialize() For x = 2 To Cells(65536, 1).End(xlUp).Row If WorksheetFunction.CountIf(Range("a2:a" & x), Cells(x, 1)) = 1 Then ComboBox1.AddItem Cells(x, 1).Value End If Next End Sub Private Sub ComboBox1_Change() Call MyCheck End Sub Private Sub UserForm_Initialize() Call MyCheck End Sub Private Sub MyCheck() If ComboBox1 = Empty Then MultiPage1.Visible = False Else MultiPage1.Visible = True End If End Sub MultiPage1.Visible = True If ComboBox1 = "" Then MultiPage1.Visible = False Private Sub CmbUrun_Change() Set no = Worksheets("tms").Range("A1:CZ200") Set ara = Cells.Find(What:=CmbUrun.Value, After:=ActiveCell, LookIn:=xlFormulas) If Not ara Is Nothing Then ilk = ara.Address ara.Select End If LblStok1 = ActiveCell.Offset(0, 1) End Sub Private Sub UserForm_Initialize() ComboBox1.ListRows = 5 ComboBox1.Text = "PERSONEL SENZ..." ComboBox1.AddItem "DENEME 1" ComboBox1.AddItem "DENEME 2" ComboBox1.AddItem "DENEME 3" ComboBox1.AddItem "DENEME 4" ComboBox1.AddItem "DENEME 5" With ComboBox1 .SelStart = 0 .SelLength = Len(ComboBox1) End With End Sub
Private Sub ComboBox1_Change() On Error Resume Next ComboBox2.Value = Sheets("Sayfa1").Cells([Sayfa1!b1:b65536].Find(ComboBox1.Value).Row, 1) End Sub Private Sub ComboBox2_Change() On Error Resume Next ComboBox1.Value = Sheets("Sayfa1").Cells([Sayfa1!a1:a65536].Find(ComboBox2.Value).Row, 2) End Sub 1. Sayfa ismine sag tikla "KODU GRNTLE" se 2. Yeni Form Se 3. Form zerine ailir kutu ekle 4. sayfaya geri dn 5. ailir kutuda bulunmasini istedigin verileri hcrelere yaz 6. hcreleri se ve ekle ad tanimla rnegin ISIMLER olsun 7. Kod grntleyiciye geri dn 8. izdigin ailir kutuyu se 9. PROPERTIES den ROW SOURCE kutusuna ISIMLER yaz 10 comboboxa ift tikla CHANGE olayina range("c1").value = combobox1.value yazarsan setigin deger c1 hcresine aktarilir For b = 2 To Sheets("veri").Cells(65536, 5).End(xlUp).Row If WorksheetFunction.CountIf(Sheets("veri").Range("e2:e" & b), Sheets("veri").Cells(b, 5)) = 1 Then ComboBox1.AddItem Sheets("veri").Cells(b, 5).Value End If Next Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Const CB_SHOWDRPDOWN = &H14F Private Sub Combo1_GotFocus() SendMessage Combo1.hwnd, CB_SHOWDRPDOWN, True, ByVal 0& End Sub B2" hcresinin deeri "1" ise -------ComboBox2 de "A" seili B2" hcresinin deeri "2" ise -------ComboBox2 de "B" seili B2" hcresinin deeri "3" ise -------ComboBox2 de "C" seili Private Sub UserForm_Initialize() ComboBox2.AddItem "A" ComboBox2.AddItem "B" ComboBox2.AddItem "C" Select Case Sheets("Sheet ismi").Range("B2") Case 1 ComboBox2 = "A" Case 2 ComboBox2 = "B" Case 3 ComboBox2 = "C" End Select End Sub 'dier seenek Private Sub UserForm_Initialize() 'form yklendiinde Me.ComboBox2.ListIndex = Range("b2")-1 End Sub Private Sub UserForm_Activate() 'form aktif olduunda Me.ComboBox2.ListIndex = Range("b2") - 1 End Sub Private Sub CommandButton3_Click() Select Case ComboBox1.ListIndex Case 0 CommandButton1_Click Case 1 CommandButton2_Click . . End Select End Sub
Private Sub ComboBox1_Change() TextBox1.Text = Application.VLookup( _ ComboBox1.Value, Range("D8:E11"), 2, False) End Sub de yllar combo1 'combo2 de aylar (1,2,...12) '31 tanede textbox oldugunu varsaydim. Private Sub ComboBox2_Change() If ComboBox2 = 12 Then x = DateDiff("d", "1" & "." & ComboBox2 & "." & ComboBox1, "1" & "." & "1" & "." & ComboBox1 + 1) Else x = DateDiff("d", "1" & "." & ComboBox2 & "." & ComboBox1, "1" & "." & ComboBox2 + 1 & "." & ComboBox1) End If z=1 Dim ctrl As Control For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "TextBox" Then ctrl.Text = "" End If Next ctrl For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "TextBox" Then ctrl.Text = z If z = x Then Exit For z=z+1 End If Next ctrl End Sub Private Sub ComboBox1_Change() ComboBox1 = byk(ComboBox1) End Sub Function byk(veri) Dim a As Integer Dim b As String For a = 1 To Len(veri) If Mid(veri, a, 1) = "i" Then b = "" ElseIf Mid(veri, a, 1) = "" Then b = "I" Else b = Mid(UCase(veri), a, 1) End If byk = byk & b Next End Function Private Sub UserForm_Initialize() With ComboBox1 .AddItem "Kubilay" .AddItem "Akn" .AddItem "Karabulut" End With End Sub Private Sub UserForm_Initialize() Dim i% Dim TMP$ ComboBox1.Clear For i = 1 To 12 TMP = Format(DateSerial(2004, i, 1), "mmmm") ComboBox1.AddItem TMP Next i ComboBox1.ListIndex = 0 End Sub
FORMA EKLEDNZ COMBOBOXA AYLARI YAZDIRIR Private Sub UserForm_Initialize() Dim i% Dim TMP$ ComboBox1.Clear For i = 1 To 12 TMP = Format(DateSerial(2004, i, 1), "mmmm") ComboBox1.AddItem TMP Next i ComboBox1.ListIndex = 0 End Sub Private Sub ComboBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) MsgBox "EL LE VER GRLEMEZ" ComboBox1 = "" End Sub Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) MsgBox "EL LE VER GRLEMEZ" End Sub Userformun initialize olayna aadaki kodu ilave edin. Bu kod en altta bulunan comboboxa sayfa isimlerini alacaktr. visual basic kodu: -------------------------------------------------------------------------------Private Sub UserForm_Initialize() For sayfa = 1 To Worksheets.Count ComboBox1.AddItem Sheets(sayfa).Name Next sayfa End Sub --------------------------------------------------------------------------------
Sayfa isimlerini seeceiniz combobox ada aadaki kodu yazn. Bu kod comboboxtan seilen sayfaya gidecektir. Bylece tm ilemler comboboxtan seile visual basic kodu: -------------------------------------------------------------------------------Private Sub ComboBox1_Click() Sheets(ComboBox1.Value).Select End Sub Private Sub UserForm_Initialize() ComboBox1.RowSource = "LISTE!A1:A31" End Sub
Private Sub UserForm_Initialize() Dim ComboListe As Variant, i As Long ComboListe = Benzersiz_Liste(Range("A2:A500"), True) For i = 1 To UBound(ComboListe) ComboBox1.AddItem ComboListe(i) Next i End Sub Private Function Benzersiz_Liste(Aralik As Range, DuzListe As Boolean) As Variant Dim Hucre As Range, Benzersiz As New Collection, Say As Long, Dizi() As Variant Application.Volatile On Error Resume Next For Each Hucre In Aralik If Hucre.Formula <> "" Then Benzersiz.Add Hucre.Value, CStr(Hucre.Value) End If Next Hucre Benzersiz_Liste = "" If Benzersiz.Count > 0 Then ReDim Dizi(1 To Benzersiz.Count) For Say = 1 To Benzersiz.Count Dizi(Say) = Benzersiz(Say) Next Say Benzersiz_Liste = Dizi If Not DuzListe Then Benzersiz_Liste = Application.WorksheetFunction.Transpose(Benzersiz_Liste) End If End If On Error GoTo 0 End Function Private Sub ComboBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) ComboBox1 = Empty End Sub Private Sub UserForm_Initialize() With UserForm1.ComboBox1 .AddItem "izinli" .AddItem "kaak" .AddItem "mazeretsiz" .AddItem "ge" End With End Sub Private Sub CommandButton1_Click() For i = 1 To 10 UserForm1.Controls("ComboBox" & i).Text = i Next i End Sub A ve G Stun aralnn Combobox1'e girilen tarihe gre listelenmesi
Private Sub CommandButton1_Click() Dim x As Date For i = 2 To Sheets("EVRAK DEFTER").Cells(65536, 1).End(xlUp).Row x = Sheets("EVRAK DEFTER").Cells(i, 3) If x >= CDate(ComboBox1.Value) And x <= CDate(ComboBox2.Value) Then listbox1.additem Sheets("EVRAK DEFTER").Cells(i, 1) & "-" & Sheets("EVRAK DEFTER").Cells(i, 2) & "-" & Sheets("EVRAK DEFTER").Cells(i, 3) & "End If Next i End Sub 'ListBox1'in Stun ayarlarn; 'ColumnCount zelliini stediiniz stun saysn yazn. 'ColumnWidths zelliini Stun Genilii.70;80;55...gibi (Kafana Gre ayarlarsn) 'UserForm alrken Sayfaya Mdahale etmek istersen. 'UserFormu tklat ShowModal zelliini False yap. ActiveSheet.Cells(ComboBox1.ListIndex + 1, "k") = TextBox1.Value
ComboBox1.RowSource = "veri!a1:a1000" OrganizeComboBox End Sub 'Buradaki kodlar da Modle ekleyiniz Dim MyForm As Variant Option Base 1 ' Sub OrganizeComboBox() Dim noData, , J, K, m As Integer Dim MyComboArray() Dim MyRevizedComboArray() Dim MyData As Range Dim SortedColl As New Collection Dim Swap1, Swap2 As Variant ' For Each MyControl In UserForms(MyForm).Controls ' i=0 J=0 K=0 ' If TypeName(MyControl) = "ComboBox" Then noData = MyControl.ListCount ReDim MyComboArray(noData) For Each MyData In Range(MyControl.RowSource) i=i+1 MyComboArray(i) = MyData Next For m = 1 To UBound(MyComboArray) If Not WorksheetFunction.IsNumber(MyComboArray(m)) Then MyComboArray(m) = UCase(MyComboArray(m)) MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") End If Next For i = 1 To UBound(MyComboArray) For J = i + 1 To UBound(MyComboArray) - 1 If MyComboArray(i) = MyComboArray(J) Then MyComboArray(i) = "" End If Next Next ' MyControl.RowSource = "" ' For i = 1 To UBound(MyComboArray) If MyComboArray(i) <> "" Then K=K+1 ReDim Preserve MyRevizedComboArray(K) MyRevizedComboArray(K) = MyComboArray(i) End If Next ' i=0 J=0 For i = 1 To UBound(MyRevizedComboArray) SortedColl.Add MyRevizedComboArray(i) Next ' For i = 1 To SortedColl.Count - 1 For J = i + 1 To SortedColl.Count If SortedColl(i) > SortedColl(J) Then Swap1 = SortedColl(i) Swap2 = SortedColl(J) SortedColl.Add Swap1, before:=J SortedColl.Add Swap2, before:=i SortedColl.Remove i + 1 SortedColl.Remove J + 1 End If Next J Next i ' For i = 1 To SortedColl.Count MyControl.AddItem SortedColl(i)
Private Sub UserForm_Activate() Dim TMP$ Dim i As Integer Dim a$(1 To 12, 1 To 2) ComboBox1.Clear ComboBox1.ColumnCount = 2 For i = 1 To 12 a(i, 1) = Format(Format(DateSerial(2007, i, 1), "mmmm"), "mmmm") a(i, 2) = 2007 Next i ComboBox1.List = a End Sub Private Sub UserForm_Activate() Dim TMP$ Dim i As Integer ComboBox1.Clear For i = 1 To 12 TMP = Format(DateSerial(2007, i, 1), "mmmm") & " / " & Format(Now, "yyyy") ComboBox1.ListRows = 12 ComboBox1.AddItem TMP Next i End Sub Private Sub ComboBox1_Change() If ComboBox1.Value = "" Then Dim hucre As Range Me.ListBox1.RowSource = "" For Each hucre In Range("h2:h" & Range("h65536").End(xlUp).Row) If hucre.Value = "" Then Me.ListBox1.AddItem Range("B" & hucre.Row).Value End If Next End If End Sub Private Sub CommandButton1_Click() Dim i, b As Integer Dim indexsec For i = 0 To ComboBox1.ListCount On Error Resume Next combo = combo & "Veri: " & _ ComboBox1.List(i, 0) & " - ndex'i:" & i & vbCrLf Next i indexsec = InputBox("Ltfen Aadaki deger veya ndexlerden bir" _ & "deger sein" & combo, "Combobox deer se") If indexsec = "" Then Exit Sub If IsNumeric(indexsec) = True Then If indexsec > ComboBox1.ListCount Then MsgBox "Bu ndex Numaras listede yok" Exit Sub End If ComboBox1.Value = ComboBox1.List(indexsec, 0) Else For b = 0 To ComboBox1.ListCount On Error Resume Next If ComboBox1.List(b, 0) = Trim(indexsec) Then MsgBox "Yazdnz Veri " & b & " Nolu Veridir - " & ComboBox1.List(b, 0) ComboBox1.Value = ComboBox1.List(b, 0) Exit Sub End If Next b End If End Sub
Private Sub UserForm_Initialize() Sheets("YER SABT BLGLER").Activate TextBox12.Text = Range("b18").Text TextBox13.Text = Range("e18").Text TextBox14.Text = Range("b19").Text TextBox15.Text = Range("e19").Text End Sub Sheets("YER SABT BLGLER").Activate Range("b18").Select ActiveCell.Formula = TextBox12 Range("e18").Select ActiveCell.Formula = TextBox13 Range("b19").Select ActiveCell.Formula = TextBox14 Range("e19").Select ActiveCell.Formula = TextBox15 End Sub 'B18 Hcresinde 06:30 Yazl 'E18 Hcresinde 15:30 Yazl 'B19 Hcresinde 23:00 Yazl Private Sub UserForm_Initialize() For i = 1 To 8 ComboBox1.AddItem Format(Cells(i, 1), "hh:mm") Next End Sub Private Sub cb1_Change() Worksheets(cb1.Text).Select UserForm1.Hide Unload UserForm1 End Sub Private Sub UserForm_Initialize() Dim ws As Worksheet For Each ws In Worksheets Me.cb1.AddItem ws.Name Next End Sub Option Explicit Private Sub ComboBox1_Change() Worksheets(ComboBox1.Text).Select UserForm1.Hide Unload UserForm1 End Sub Private Sub UserForm_Initialize() Dim ws As Worksheet For Each ws In Worksheets Me:ComboBox1.AddItem ws.Name Next End Sub Public satir As Integer Private Sub ComboBox1_Change() satir = ComboBox1.ListIndex + 1 End Sub Private Sub CommandButton1_Click() Cells(satir, 1).EntireRow.Delete End Sub
For a = 1 To [b65536].End(3).Row If WorksheetFunction.CountIf(Range("a1:a" & a), Cells(a, "b")) > 1 Then GoTo 10 c=c+1 ComboBox2.AddItem Cells(a, "b") deg2 = ComboBox2.List(c - 1, 0) If IsNumeric(ComboBox2.List(c - 1, 0)) = True Then deg2 = ComboBox2.List(c - 1, 0) * 1 For b = 0 To c - 2 deg1 = ComboBox2.List(b, 0) If IsNumeric(ComboBox2.List(b, 0)) = True Then deg1 = ComboBox2.List(b, 0) * 1 If deg1 > deg2 Then deg = ComboBox2.List(c - 1, 0) ComboBox2.List(c - 1, 0) = ComboBox2.List(b, 0) ComboBox2.List(b, 0) = deg End If Next Private Sub ListBox1_Click() On Error Resume Next cells(ListBox1.Column(5),"a").Select End Sub ListBox1.RowSource = combobox1.text & "!A1:R15" Private Sub UserForm_Initialize() ComboBox1.RowSource = "Sayfa2!A1:A20" End Sub Private Sub ComboBox1_Change() sat = ComboBox1.ListIndex + 1 Cells(sat, "a").Select End Sub mesaj = MsgBox(ComboBox1.Value & " degerini girdiniz !", ,"Balk") Combobox ile seince aktarsn diyorsanz Private Sub ComboBox1_Change() Worksheets("sayfa1").Range("a1") = ComboBox1.Value End Sub Private Sub ComboBox1_Click() TextBox1 = ComboBox1.Column(0) TextBox2 = ComboBox1.Column(1) TextBox3 = ComboBox1.Column(2) End Sub Private Sub UserForm_Activate() With UserForm1.ComboBox1 .AddItem "masa" .AddItem "sra" .AddItem "sandalye" End With End Sub Private Sub UserForm_Initialize() With ComboBox1 .AddItem "pir" .AddItem "Mahmut" .AddItem "Bayram" End With End Sub Sub SchaltflcheInTabellenEinfgen() Dim Tabelle As Worksheet For Each Tabelle In ActiveWorkbook.Worksheets Tabelle.Activate Tabelle.Buttons.Add(96, 15, 93, 24).Select Selection.Name = "Datum" Selection.Characters.Text = "Datum" Selection.OnAction = "Datum2" Range("A1").Select Next Tabelle End Sub
Sub command_add() Dim cmdB As CommandBar Set cmdB = CommandBars.Add("MyToolbar", temporary:=True) With cmdB .Left = 50 .Top = 100 .Visible = True End With End Sub Dim x As Integer For x = 1 To 127 Cells(x, 1) = Application.CommandBars(x).Name Cells(x, 2) = Application.CommandBars(x).NameLocal Next x Private Sub CommandButton1_Click() sifre = InputBox("Kodlarn almas iin ifre gerekiyor", _ "Yetkili Kii", "ifreyi buraya yaznz.") If sifre = "excel" Then 'ifre MsgBox "ifre doruland", vbInformation, _ "ifre Doru" 'buraya kodlarnz yaptrnz ' " " Else MsgBox "Yanl ifre girdiniz." & Chr(13) & _ "Kod almas iptal edildi", vbCritical, "Yanl ifre" Cancel = True End If End Sub Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) CommandButton1.Top = CommandButton1.Top + 20 End Sub Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) CommandButton1.BackColor = vbYellow End Sub Private Sub UserForm_Initialize() CommandButton1.Tag = CommandButton1.BackColor End Sub Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) CommandButton1.BackColor = CommandButton1.Tag End Sub Userformunuzun zerindeki combobox'nzda grnmesini istediiniz sabit deerler iin formunuzun code blmne; Kod: Private Sub UserForm_Initialize() With ComboBox1 .AddItem "Kubilay" .AddItem "Akn" .AddItem "Karabulut" End With End Sub Private Function WorkbookIsOpen(wbname) As Boolean ' alma kitab aksa TRUE dndrr Dim x As Workbook On Error Resume Next Set x = Workbooks(wbname) If Err = 0 Then WorkbookIsOpen = True _ Else WorkbookIsOpen = False End Function Sub ac() sPath = "C:\My Documents\" On Error Resume Next For Each cell In Range("A1", Range("a1").End(xlDown)) Workbooks.Open Filename:=sPath & cell.Value & ".xls" Next On Error GoTo 0 For Each cell In Range("A1", Range("a1").End(xlDown)) Workbook
Sub lstProprieteFichier() lg = 1 Worksheets.Add For Each LstPro In ActiveWorkbook.BuiltinDocumentProperties Cells(lg, 1).Value = LstPro.Name On Error Resume Next Cells(lg, 2).Value = ActiveWorkbook.BuiltinDocumentProperties.Item(LstPro.Name) lg = lg + 1 Next Columns("A:A").EntireColumn.AutoFit Range("B10:B12").NumberFormat = "[$-F800]dddd, mmmm dd, yyyy" End Sub Private Sub Workbook_Open () Range("A1").Value = Range("A1").Value + 1 End Sub Option Explicit Dim FileDir As String Dim Filenumber As String Const FilePath = "C:" Private Sub cmdSave_Click() On Error Resume Next Filenumber = InputBox("Oluturulacak kitabn ismi?", "pir") If Filenumber = "" Then MsgBox "HATA", vbOKOnly, "pir" Exit Sub End If FileDir = FilePath & Filenumber & ".xls" SaveAs Filename:=FileDir On Error GoTo 0 End Sub Private Sub Workbook_Open() Application.DisplayAlerts = False Heute = Now Verfalldatum = #5/14/2003# 'Hier Verfalldatum im Format MM/TT/JJJJ eintragen
If Verfalldatum < Heute Then Dim passwort As String passwort = InputBox("Die Testphase ist abgelaufen," & Chr(13) & Chr(13) & " bitte geben Sie Ihre Registrierungs-Nr.:", "Testphase abgelaufen, Reg. If passwort <> "36" Then MsgBox " Das Kennwort ist ungltig," & Chr(13) & Chr(13) & "der Vorgang wird abgebrochen !" ThisWorkbook.Close End If MsgBox ("Registrierung erfolgreich") Application.DisplayAlerts = True End If End Sub Private Sub Workbook_Open() Dim passwort As String passwort = InputBox("Bitte geben Sie das Passwort" & Chr(13) & Chr(13) & " fr das Einfgen von Kommentaren ein:", "Passwortabfrage fr das Ein If passwort <> "36" Then MsgBox " Das Kennwort ist ungltig," & Chr(13) & Chr(13) & "Sie drfen keine Kommentare einfgen !" Application.CommandBars("Worksheet Menu Bar").Controls("Einfgen").Controls("Kommentar").Enabled = False Application.CommandBars("Cell").Controls("Kommentar einfgen").Enabled = False Exit Sub Else Application.CommandBars("Worksheet Menu Bar").Controls("Einfgen").Controls("Kommentar").Enabled = True Application.CommandBars("Cell").Controls("Kommentar einfgen").Enabled = True End If End Sub ActiveCell.SpecialCells(xlLastCell).Select
Son kaldnz hcreyi "Static" bir deikene atayabilirsiniz. Static sonhucre as Range Sub Kontrol() set sonhucre = "kontrol edilen hcre" .... End Sub 'geri dndnzde sonhucre.select 'yazdnzda bu hcre seilecektir. Worksheets(Worksheets.Count) Sub RemoveChartLinks() Dim oSht As Worksheet, oCht As ChartObject, oSeries As Series 'tm grafiklerden.. For Each oSht In ActiveWorkbook.Worksheets For Each oCht In oSht.ChartObjects For Each oSeries In oCht.Chart.SeriesCollection With oSeries .Name = .Name .Values = .Values .XValues = .XValues End With Next Next Next 'tm grafik ykl sayfalardan... For Each oCht In ActiveWorkbook.Charts For Each oSeries In oCht.SeriesCollection With oSeries .Name = .Name .Values = .Values .XValues = .XValues End With Next Next End Sub Sub RemoveAllCode() 'XL2K: ' Dim VBComp As VBComponent, AllComp As VBComponents, ' ThisProj As VBProject ' XL97 & XL2K: Dim VBComp As Object, AllComp As Object, ThisProj As Object Dim ThisRef As Reference, WS As Worksheet, DLG As DialogSheet If ActiveWorkbook.Name <> ThisWorkbook.Name Then Set ThisProj = ActiveWorkbook.VBProject Set AllComp = ThisProj.VBComponents For Each VBComp In AllComp With VBComp Select Case .Type Case vbext_ct_StdModule, vbext_ct_ClassModule, _ vbext_ct_MSForm AllComp.Remove VBComp Case vbext_ct_Document .CodeModule.DeleteLines 1, .CodeModule.CountOfLines End Select End With Next For Each ThisRef In ThisProj.References If Not ThisRef.BuiltIn Then ThisProj.References.Remove ThisRef Next End If Application.DisplayAlerts = False For Each WS In Excel4MacroSheets WS.Delete Next For Each DLG In DialogSheets DLG.Delete Next End Sub
Sub SaveWorkbookBackupToFloppyA() Dim awb As Workbook, BackupFileName As String, i As Integer, OK As Boolean If TypeName(ActiveWorkbook) = "Nothing" Then Exit Sub Set awb = ActiveWorkbook If awb.Path = "" Then Application.Dialogs(xlDialogSaveAs).Show Else BackupFileName = awb.Name OK = False On Error GoTo NotAbleToSave If Dir("A:\" & BackupFileName) <> "" Then Kill "A:\" & BackupFileName End If With awb Application.StatusBar = "Saving this workbook..." .Save Application.StatusBar = "Saving this workbook backup..." .SaveCopyAs "A:\" & BackupFileName OK = True End With End If NotAbleToSave: Set awb = Nothing Application.StatusBar = False If Not OK Then MsgBox "Dosya Yedeklenemedi!", vbExclamation, ThisWorkbook.Name End If End Sub Sub gnntarihi() Dim sFileName As String sFileName = Format(Now, "dd_mm_yyyy") + ".xls" ActiveWorkbook.SaveAs sFileName End Sub Sub Kaytsmi() ActiveWorkbook.SaveAs Filename:="C:\Mahmut.xls" End Sub alma kitabn kapatr ve kaydeder. Deiikliklerin kaydedilmek istenip istenmediini sormaz. Sub kapat() ActiveWorkbook.Close Save = True End Sub Sub kayt() ActiveWorkbook.Save End Sub Sub kayit() ActiveWorkbook.Save End Sub Sub Dialog_27() Application.Dialogs(xlDialogFileSharing).Show End Sub ActiveWorkbook.SendMail recipients:="julsn@yahoo.com" alma kitab alrken buradaki ifreyi sorar, ifre yanl girilirse dosya almaz. Sub auto_open() Static sayac As Integer Do If sayac = 3 Then ThisWorkbook.Close False Else If InputBox("ifreyi girin") = "sifrem" Then GoTo devam Else sayac = sayac + 1 End If End If Loop devam: End Sub
Sub InTheMiddle() Dim dWidth As Double, dHeight As Double With Application .WindowState = xlMaximized dWidth = .Width dHeight = .Height .WindowState = xlNormal .Top = dHeight / 4 .Height = dHeight / 2 .Left = dWidth / 4 .Width = dWidth / 2 End With End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.DisplayAlerts = False ActiveWorkbook.Save End Sub Workbooks("Kitap1.xls").Worksheets("Sayfa1").Range("A1").Value = 3 Sub SayfaKaydet() Dim sayfa As Worksheet For Each sayfa In Worksheets sayfa.Copy ActiveWorkbook.SaveAs "C:\Documents and Settings\Mahmut\Desktop\" & sayfa.Name & ".xls" ActiveWorkbook.Close False Next sayfa End Sub Sub PrintAll() ThisWorkbook.PrintOut End Sub Sub KitapSayfaAdi() MsgBox ExecuteExcel4Macro("get.document(1)") End Sub Sub SaveNow() SaveWithBackup ThisWorkbook.Save End Sub On Error Resume Next Dim Proceed As Long Proceed = MsgBox("Yedekleyip kaydetmek istiyor musunuz?" & vbNewLine & _ "Selecting No will save without Backup", vbYesNo) If Proceed = vbYes Then Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, CreateBackup:=True Application.DisplayAlerts = True End If End hcreden aaya doru dosyadaki alma sayfalarna kpr atlr. AktifSub Sub Tabellennamen_auflisten() Dim i As Integer Dim myRange As Range Set myRange = ActiveCell myRange.Resize(Worksheets.Count).Select If (MsgBox("UYARI: Sayfalara kpr oluturulacak!" & vbCrLf & _ Chr(13) & " Emin misin ?", vbYesNo)) _ <> vbYes Then Exit Sub For i = 1 To Worksheets.Count With myRange.Cells(i) .Value = Worksheets(i).Name .Hyperlinks.Add _ Anchor:=myRange.Cells(i), _ Address:="", _ SubAddress:=.Value & "!" & .Address, _ ScreenTip:="Blatt (" & .Value & ")", _ TextToDisplay:=.Value End With Next i myRange.Select MsgBox ("Toplam") & ThisWorkbook.Worksheets.Count & _ (" sayfaya kpr oluturuldu"), vbOKOnly, ThisWorkbook.Name End Sub
Sub SaveW
Sayfa adlarn silip dosya tekrar aldnda "Sayfa1, Sayfa2" eklinde yazar. 'Module blmne yaz; Global WCnt Global Sh(1 To 100) As Worksheet Global ShNames(1 To 100) As String ' Workbook'un kod sayfasna yaz; Public Sub Workbook_Open() Dim i As Integer WCnt = Worksheets.Count For i = 1 To WCnt ShNames(i) = Sheets(i).Name Set Sh(i) = Sheets(ShNames(i)) Next i End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim z As Integer For z = 1 To WCnt Sh(z).Name = ShNames(z) Next z End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then Cells(ActiveCell.Row, 2).Select MsgBox "Bu aralktaki hcreler seilemez!" End If End Sub Sub BosSatirlariSil() Dim LastRow As Long, r As Long LastRow = ActiveSheet.UsedRange.Rows.Count LastRow = LastRow + ActiveSheet.UsedRange.Row - 1 Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Sub sayfaykoru() ActiveSheet.Protect userinterfaceonly:=True ActiveSheet.EnableAutoFilter = True End Sub Sub Buyut() Dim Olcegim As Integer Olcegim = ActiveWindow.Zoom + 5 If Olcegim <= 400 Then ActiveWindow.Zoom = Olcegim End If End Sub Sub Kucult() Dim Olcegim As Integer Olcegim = ActiveWindow.Zoom - 5 If Olcegim >= 10 Then ActiveWindow.Zoom = Olcegim End If End Sub Private Sub CommandButton5_Click() Dim newFile As String, musteriadi As String say=CreateObject("Scripting.FileSystemObject").GetFolder("D:\newfolder").Files.Count+1 musteriadi = Range("D84").Value newFile = musteriadi & "_" &"_" & Format$(Date, "mm-dd-yyyy") & say & ".xls" ChDrive "D" ChDir "D:\newfolder\" ActiveWorkbook.SaveAs Filename:=newFile End Sub
Sub auto_open() Static sayac As Integer Do If sayac = 3 Then ThisWorkbook.Close False Else If InputBox("ifreyi girin") = "Buraya koymak istediiniz ifreyi yazacaksnz!" Then GoTo devam Else sayac = sayac + 1 End If End If Loop devam: End Sub Sub kapat() ActiveWorkbook.Close End Sub Aadaki kod, alma kitabnda Sheet1 isimli sayfa modulunun Name zelliini MySh olarak deitirir. visual basic kodu: -------------------------------------------------------------------------------Sub Test() Dim MyMod As Object For Each MyMod In ThisWorkbook.VBProject.VBComponents If MyMod.Name = "Sheet1" Then MyMod.Name = "MySh" Next End Sub Aklama:alma Kitabnzn Baln istediiniz ekilde deitirin Sub test() Application.Caption = "pir" ActiveWindow.Caption = "excel.web.tr" 'Incorrect MsgBox Application.Caption & " " & ActiveWindow.Caption 'Correct MsgBox Application.Caption End Sub Sub gzle() For i = 1 To ActiveWorkbook.Sheets.Count Sheets(i).Select ActiveWindow.DisplayHeadings = False Next End Sub gstermesi iin: Sub goster() For i = 1 To ActiveWorkbook.Sheets.Count Sheets(i).Select ActiveWindow.DisplayHeadings = true Next End Sub Sub SayfaKaydet() Dim sayfa As Worksheet For Each sayfa In Worksheets sayfa.Copy ActiveWorkbook.SaveAs "C:\Documents and Settings\pir\Desktop\" & sayfa.Name & ".xls" ActiveWorkbook.Close False Next sayfa End Sub
Module blmne; Global WCnt Global Sh(1 To 100) As Worksheet Global ShNames(1 To 100) As String 'workbooka; Public Sub Workbook_Open() Dim i As Integer WCnt = Worksheets.Count For i = 1 To WCnt ShNames(i) = Sheets(i).Name Set Sh(i) = Sheets(ShNames(i)) Next i End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim z As Integer For z = 1 To WCnt Sh(z).Name = ShNames(z) Next z End Sub alma Sayfanzdaki Bo Satrlar Siler Sub BosSatirlariSil() Dim LastRow As Long, r As Long LastRow = ActiveSheet.UsedRange.Rows.Count LastRow = LastRow + ActiveSheet.UsedRange.Row - 1 Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Aklama: alma sayfanzdaki alma alannz belirleyen ve iptal eden macrolar. Kod: Sub LimiteDefilement() ActiveSheet.ScrollArea = "A1:A10" End Sub Sub RetablitDefilement() ActiveSheet.ScrollArea = "" End Sub Aklama: alma sayfanzdaki hcrenin deerlerine gre hcreler renklerle dolar Kod: Private Sub Worksheet_Change(ByVal Target As Range) Select Case Target Case " ": Target.Interior.ColorIndex = 15 ' gri Case "A": Target.Interior.ColorIndex = 3 ' krmz Case "B": Target.Interior.ColorIndex = 3 Case "A&B": Target.Interior.ColorIndex = 3 Case "-": Target.Interior.ColorIndex = 4 ' yeil Case Else: Target.Interior.ColorIndex = xlNone End Select End Sub Aklama: alma Sayfanz korur ancak otomatik szler alr Kod: Sub sayfaykoru() ActiveSheet.Protect userinterfaceonly:=True ActiveSheet.EnableAutoFilter = True End Sub
ALIMA SAYFASINI KORUMAYA ALIR Sub sayfaykoru() ActiveSheet.Protect userinterfaceonly:=True ActiveSheet.EnableAutoFilter = True End Sub Aadaki makroyu bir butona balarsanz taramanza gerek kalmadan gizleme yapabilirsiniz. Sub gizle() Columns("K:IV").Hidden = True Rows("45:65536").Hidden = True End Sub tekrar gstermek iin ise Sub gster() Columns("K:IV").Hidden = False Rows("45:65536").Hidden = False End Sub Function CARPIM(SAYI1 As Integer, SAYI2 As Integer) CARPIM = SAYI1 * SAYI2 End Function
'Fonksiyonumuzu yazdk peki nerelerde ve nasl kullanacaz? ncelikle Excel, modulde yazlan bu foksiyonu Kullanc Tanml Fonksiyonlar listesine atacak 'rnek: C1 hcresine CARPIM formln girerek A1 ve B1 hcrelerindeki deerlerin arpmn hesaplatalm. C1 hcresine yazlacak forml; =CARPIM(A1;B D1 hcresine A1 ve B1 hcrelerinin arpmn yazar. Range("D1") = Range("A1") * Range("B1") Range("D1").Formula = "=(A1 * A1)" Private Sub CommandButton1_Click() If CommandButton1.Caption = "altr" Then CommandButton1.Caption = "Sorgu Gir" CommandButton1.Font.Bold = True CommandButton1.Font.Size = 15 Else CommandButton1.Caption = "altr" CommandButton1.Font.Bold = False CommandButton1.Font.Size = 20 End If End Sub Private Sub UserForm_Initialize() CommandButton1.Caption = "Sorgu Gir" End Sub MsgBox "Mesaj boxlarda satr ba yapamyorum." & vbCrlf & "Bunun bir yolu olmal !" & vbCrlf & "Acaba vbCrlf kullanrsam ne olur?", vbinformation Yada Alt+Enter'in Ascii kodu olan chr(10) kullanlabilir.
Sub A() MsgBox "A" & Chr(10) & "B" & Chr(10) & "C" & Chr(10) & "D" & Chr(10) End Sub Sub msg() MsgBox "A" & Chr(13) & "B" & Chr(13) & "C" & Chr(13) & "D" & Chr(13) End Sub Option Explicit Sub AusEin() Dim S As Integer For S = 2 To Worksheets.Count Worksheets(S).Visible = Not Worksheets(S).Visible Next End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) ActiveSheet.Protect "abc" End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Target.NoteText "Die Zelle wurde am " & Format(Date, "dd.mm.yy") & " um " & Format(Now(), " hh:mm:ss") & " durch " & ActiveWorkbook.BuiltinDocum End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) sayfa = Target.Cells.Value Sheets("sayfa3").Select End Sub
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) ActiveCell = Date & ", " & Time End Sub Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) ' MsgBox "destination: target.subaddress " & Target.SubAddress ' MsgBox "Source: Target.Range.Address " & Target.Range.Address ' MsgBox "Source: Target.Range.Value " & Target.Range(1, 1).Value Range(Target.SubAddress) = Target.ActiveCell End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Cancel = True 'Get out of edit mode ActiveCell = Target.Text On Error Resume Next ActiveCell.AddComment On Error GoTo 0 ActiveCell.Comment.Visible = False ActiveCell.Comment.Text Text:="Value from: " & Target.Address(0, 0) _ & Chr(10) & Format(Now, "ddmmmyyyy hh:mm:ss") Cancel = True ' no further need to edit the cell End Sub Sub ift_kaytlari_arala() totalrows = ActiveSheet.UsedRange.Rows.Count For Row = totalrows To 2 Step -1 If Cells(Row, 1).Value <> Cells(Row - 1, 1).Value Then Rows(Row).Insert Next Row End Sub kullanici = Application.UserName saat = Format(Now, "hh:mm:ss") tarih = Format(Date, "d mmmm yyyy dddd") sor = MsgBox(" GRMEK ZERE " & kullanici & Chr(10) & Chr(10) & _ "WWW.XXX.COM / +90 312 111 11 11" & Chr(10) & Chr(10) & _ "Tarih : " & tarih & Chr(10) & Chr(10) _ & "Saat : " & saat & Chr(10) & Chr(10) _ & "XXX A.. yi almalar Diler." & Chr(10) & Chr(10) & _ "dosyann kaydedilmesini istiyormusunuz?", 4, "") If sor = vbYes Then ActiveWorkbook.Save ActiveWorkbook.Close Else Application.DisplayAlerts = False ActiveWorkbook.Close End If End Sub Private Sub Command1_Click() pir = MsgBox("kmak istediinizden emin misiniz?", vbQuestion + vbYesNo, "k") Select Case pir Case vbYes End End Select End Sub Aadaki kodu sayfann kod sayfasna kopyalayarak deneyin. visual basic kodu: Private Sub Worksheet_Change(ByVal Target As Range) On Error Resume Next If Intersect(Target, [a:a]) Is Nothing Then Exit Sub say = WorksheetFunction.CountIf(Range("a1:a" & Target.Row - 1), Target) If say > 0 Then MsgBox "BU KAYIT MEVCUTTUR" Target.Select Target = "" End If End Sub
Aadaki kod sadece a stunu iin geerli, buna birde e stununu nasl eklerim? Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, [a:a]) Is Nothing Or Target = 0 Then Exit Sub UserForm1.Show End Sub
visual basic kodu: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 1 Or Target.Column = 5 Then say = WorksheetFunction.CountIf([m:m], Target) If say > 0 Then Exit Sub UserForm1.Show End If End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal _ Target As Range, Cancel As Boolean) 'David McRitchie, misc, 2001-07-02 '-- Find top cell in continguous range Cancel = True 'Get out of edit mode Range(Target.Offset(-1, 0).End(xlUp), Target).Select '-- leave selection of cells showing for visual verification. Target.Formula = "=SUBTOTAL(9," _ & Selection(1).Address(0, 0) & ":" _ & Selection(Selection.Count - 1).Address(0, 0) & ")" 'make the double-clicked cell the active cell for the range Target.Activate End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) If ListBox1.ListIndex = -1 Then Exit Sub cevap = MsgBox(ListBox1.List(, 0) & " nolu kayd silmek istiyor musunuz?", vbYesNo) If cevap = vbYes Then Range(Cells(ListBox1.List(, 0) + 1, 2), Cells(ListBox1.List(, 0) + 1, 6)).Delete shift:=xlUp [a65536].End(3).Delete shift:=xlUp Call UserForm_Activate End If End Sub Hcreye Maus veya Tularla Geldiinide stenilen sayfaya gemesi iin,bu kodlar O sayfann zerinde sa tu ile Kod Grntle ksmna yazlacak.Kod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$C$18" Then Sheets("Sayfa2").Select End Sub Hcreye Maus veya Tularla Geldiinide stenilen sayfaya gemesi iin,bu kodlar O sayfann zerinde sa tu ile Kod Grntle ksmna yazlacak. Kod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$C$18" Then Sheets("Sayfa2").Select End Sub
Sub MultiSheetPrint() Dim oActive As Object Dim oSheet As Object Dim oSheets As Object Dim wsPrint As Worksheet Dim oLastPic As Object Dim iPics As Integer ' remember where we are Set oSheets = ActiveWindow.SelectedSheets If oSheets.Count = 1 Then Selection.PrintOut preview:=True Exit Sub End If Set oActive = ActiveSheet Application.ScreenUpdating = False oActive.Select ' otherwise we get lots of new sheets Set wsPrint = Worksheets.Add For Each oSheet In oSheets If TypeName(oSheet) = "Worksheet" Then iPics = iPics + 1 oSheet.Activate Selection.CopyPicture wsPrint.Cells(iPics * 3 - 2, 1).Value = oSheet.Name wsPrint.Paste wsPrint.Cells(iPics * 3 - 1, 1) wsPrint.Rows(iPics * 3 - 1).RowHeight = _ wsPrint.Pictures(iPics).Height End If Next wsPrint.PrintOut preview:=True Application.DisplayAlerts = False wsPrint.Delete Application.DisplayAlerts = True oSheets.Select oActive.Activate Application.ScreenUpdating = True End Sub Sub CokluSutunSay() AreaCount = Selection.Areas.Count If AreaCount <= 1 Then MsgBox "Seili alanda " & _ Selection.Columns.Count & " stun var." Else For i = 1 To AreaCount MsgBox "Seili " & i & ". blgede " & _ Selection.Areas(i).Columns.Count & " stun var." Next i End If End Sub Declare Function GetClipCursor Lib "user32" (lprc As RECT) As Long Type RECT gauche As Long haut As Long droit As Long bas As Long End Type Dim oGCC As RECT Sub dimEcran() GetClipCursor oGCC With oGCC MsgBox .droit & " x " & .bas End With End Sub Declare Function GetSystemMetrics32 Lib "User32" _ Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long Sub DisplayMonitorInfo() Dim w As Long, h As Long w = GetSystemMetrics32(0) ' width in points h = GetSystemMetrics32(1) ' height in points MsgBox Format(w, "#,##0") & " x " & Format(h, "#,##0"), _ vbInformation, "Monitor Size (width x height)" End Sub
Declare Function GetDeviceCaps Lib "gdi32" (_ ByVal hdc As Long, _ ByVal nIndex As Long) As Long Declare Function GetDC Lib "user32" ( _ ByVal hwnd As Long) As Long Declare Function ReleaseDC Lib "user32" (_ ByVal hwnd As Long, _ ByVal hdc As Long) As Long Const HORZRES = 8 Const VERTRES = 10 Function ScreenResolution() Dim lRval As Long Dim lDc As Long Dim lHSize As Long Dim lVSize As Long lDc = GetDC(0&) lHSize = GetDeviceCaps(lDc, HORZRES) lVSize = GetDeviceCaps(lDc, VERTRES) lRval = ReleaseDC(0, lDc) ScreenResolution = lHSize & "x" & lVSize End Function Sub GetScreenSize() MsgBox ScreenResolution() End Sub Public Declare Function GetDC Lib "user32" _ (ByVal hwnd As Long) As Long Private Declare Function GetDeviceCaps Lib "gdi32" _ (ByVal hdc As Long, _ ByVal nIndex As Long) As Long Private Private Private Private Const Const Const Const HORZRES As Long = 8 VERTRES As Long = 10 BITSPIXEL As Long = 12 VREFRESH As Long = 116
Private Sub resEC() Dim hdc As Long Dim currHRes As Long Dim currVRes As Long Dim currBPP As Long Dim currVFreq As Long Dim sBPPtype As String Dim sFreqtype As String hdc = GetDC(0) ' Sistem ayarlarn al currHRes = GetDeviceCaps(hdc, HORZRES) currVRes = GetDeviceCaps(hdc, VERTRES) currBPP = GetDeviceCaps(hdc, BITSPIXEL) currVFreq = GetDeviceCaps(hdc, VREFRESH) ' Tanmlamalar Select Case currBPP Case 4: sBPPtype = "(16 Color)" Case 8: sBPPtype = "(256 Color)" Case 16: sBPPtype = "(High Color)" Case 24, 32: sBPPtype = "(True Color)" End Select Select Case currVFreq Case 0, 1: sFreqtype = "(Hardware default)" Case Else: sFreqtype = "(User-selected)" End Select Range("a1") Range("a2") Range("a3") Range("a4") End Sub = currHRes & " pixels" = currVRes & " pixels" = currBPP & " bits per pixel " & sBPPtype = currVFreq & " hz " & sFreqtype
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Sub Bild() MsgBox ("znrlk Pixel Deerleri: " & GetSystemMetrics(0) & " x " & GetSystemMetrics(1)) End Sub Sub KenarlikRengi() Dim chAna As Chart Aktif sayfadaki 1. grafii chAna olarak ayarla Set chAna = ActiveSheet.ChartObjects(1).Chart 1. serinin kenar izgilerini yeil yap chAna.SeriesCollection(1).Border.ColorIndex = 4 1. serinin 2. deerinin kenar izgilerini sar yap chAna.SeriesCollection(1).Points(2).Border.ColorIndex = 6 End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim iOffset As Integer On Error GoTo err_handler Application.EnableEvents = False If Not Application.Intersect(Target, Columns("D:E")) Is Nothing Then If Target.Column = 4 Then iOffset = 3 Else iOffset = 2 End If If IsEmpty(Target.Value) Then With Target .Font.Name = "Wingdings" .Value = Chr(252) End With Target.Offset(0, iOffset).Select Else Target.Value = "" Target.Offset(0, iOffset).Select End If End If err_handler: Application.EnableEvents = True End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Range) Zelle = Target.Address Select Case Zelle Case "$D$2" Range("$D$2").ColumnWidth = 52 'entspricht 369 Pixel Case Else Range("$D$2").ColumnWidth = 16.43 'entspricht 120 Pixel End Select End Sub Sub TanimliDegerOlanHucreler() Deger = Range("D2").Value Range("A1").Select For Each hucre In ActiveCell.CurrentRegion If hucre.Value = Deger Then Plg = Plg & hucre.Address() & "," ' Deeri ieren satr semek iin st satrn yerine bunu yaz: 'If hucre.Value = Deger Then ' Plg = Plg & hucre.Row() & ":" & hucre.Row() & "," 'End If Next hucre If Len(Plg) > 0 Then Range(Left(Plg, Len(Plg) - 1)).Select End Sub
Kod: Sub SifreAc() Dim i As Integer, j As Integer, k As Integer Dim l As Integer, m As Integer, n As Integer Dim i1 As Integer, i2 As Integer, i3 As Integer Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next For i = 65 To 66 For j = 65 To 66 For k = 65 To 66 For l = 65 To 66 For m = 65 To 66 For i1 = 65 To 66 For i2 = 65 To 66 For i3 = 65 To 66 For i4 = 65 To 66 For i5 = 65 To 66 For i6 = 65 To 66 For n = 32 To 126 ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _ Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) _ & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) If ActiveSheet.ProtectContents = False Then MsgBox "One usable password is " & Chr(i) & Chr(j) _ & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) _ & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) Exit Sub End If Next Next Next Next Next Next Next Next Next Next Next Next End Sub Dim dbs2 as Database Dim rst2 as Recordset Set dbs2 = OpenDatabase(datayolu) Set rst2 = dbs2.OpenRecordset("Select * from cr Where tarih>=datevalue('" & trh1.Value & "') and tarih<=datevalue('" & trh2.Value & "')-1 and crkod=' If rst2.RecordCount > 0 Then rst2.MoveLast rst2.MoveFirst i=1 fg5.Rows = rst2.RecordCount + 1 While Not rst2.EOF If Not IsNull(rst2("tutar")) Then fg5.TextMatrix(i, 2) = rst2("tutar") i=i+1 rst2.MoveNext Wend End If Sub data_form() ActiveWorkbook.Names.Add Name:="Database", RefersTo:="=" & Worksheets(1).Name & "!" & Range("A15:F35").Address Range("A1:F11").Select Worksheets(1).ShowDataForm End Sub Private Sub Workbook_Open() Sheets("Sayfa1").Select ActiveSheet.ShowDataForm End Sub
If KeyAscii = 8 Then DecControl = KeyAscii Exit Function End If If NOOFDEC = 0 Then If InStr(1, "0123456789-", Chr(KeyAscii)) = 0 Then DecControl = 0 Exit Function Else DecControl = KeyAscii Exit Function End If Else If InStr(1, "0123456789.-", Chr(KeyAscii)) = 0 Then DecControl = 0 Exit Function End If End If If Len(Text) - Text.SelStart > NOOFDEC And Chr(KeyAscii) = "." Then DecControl = 0 Exit Function End If If KeyAscii <> 8 Then If InStr(1, Text, ".") <> 0 And Chr(KeyAscii) = "." Then DecControl = 0 Exit Function End If Dim pos As Integer Dim RET As Integer pos = InStr(1, Text.Text, ".") If pos = 0 Then If InStr(1, "0123456789.-", Chr(KeyAscii)) = 0 Then RET = 0 Else RET = KeyAscii End If Else 'IF AFTER DECIMAL If Text.SelStart + 1 > pos Then a = Len(Text.Text) - InStr(1, Text, ".") If a >= NOOFDEC Then RET = 0 Else RET = KeyAscii End If Else RET = KeyAscii End If End If Else RET = KeyAscii End If DecControl = RET End Function Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim i As Long For i = 1 To WorksheetFunction.CountA(Range("H:H")) If Cells(i, 8).Value = "A" And Left(Cells(i, 9), 3) <> "(-)" Then Cells(i, 9) = "(-)" & Cells(i, 9).Value Cells(i, 9).HorizontalAlignment = xlRight End If Next i End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Row < 3 Then Exit Sub If Target.Column <> 1 Then Exit Sub If Not IsEmpty(Target) Then Exit Sub Application.EnableEvents = False 'should be part of Change macro Target.Offset(0, 0).Value = Target.Offset(-1, 0).Value Target.Offset(0, 1).Value = Target.Offset(-1, 1).Value Target.Offset(0, 2).Value = Target.Offset(-1, 2).Value Application.EnableEvents = True 'should be part of Change macro End Sub Sub EtiketGoster() Dim chAna As Chart Set chAna = ActiveSheet.ChartObjects(1).Chart chAna.ApplyDataLabels (xlShowValue) End Sub Sub EtiketGizle() Dim chAna As Chart Set chAna = ActiveSheet.ChartObjects(1).Chart chAna.ApplyDataLabels (xlNone) End Sub Sub aynideger() Dim Cel1 As Range, Cel2 As Range Set Cel1 = Range("A1:B1") Set Cel2 = Workbooks("Kitap1").Worksheets("Sayfa1").Range("D5") Cel1.Copy Cel2 End Sub Bu kodu bir module ierisine deil Alt+F11 ile VBAy an. Project Explorerden "This Workbook" zerine ift tklayn ve kodu bu alan sayfaya kopyalayn. Normal module sayfasna eklerseniz almaz. Deneme sonras sonucu bildirirseniz memnun olurum. Sonuca farkl ekilde giden arkadalar kodlarn paylarsa sevinirim. Kod: Private Sub yaz(deger, adres, yenideger) If deger = 0 Then yuzde = 1 ElseIf IsNumeric(deger) And IsNumeric(yenideger) Then yuzde = (deger - yenideger) / deger yuzde = yuzde * 100 * (-1) yuzde = FormatNumber(yuzde, 2) End If If deger < 1 Then deger = 0 Range(adres).ClearComments Range(adres).AddComment " " Range(adres).Comment.Visible = False Range(adres).Comment.Text Text:="Eski Deer: " & deger & Chr(10) & "Deiim: %" & yuzde End Sub Public Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) adres = Range("IV1").Value deger = Range("IV2").Value If adres > 0 Then yenideger = Range(adres).Value If deger <> yenideger Then Call yaz(deger, adres, yenideger) End If End If Range("IV1").Value = ActiveCell.Address Range("IV2").Value = ActiveCell.Value End Sub
'Normal module sayfasna eklerseniz almaz. Private Sub yaz(deger, adres, yenideger) If deger = 0 Then yuzde = 1 ElseIf IsNumeric(deger) And IsNumeric(yenideger) Then yuzde = (deger - yenideger) / deger yuzde = yuzde * 100 * (-1) yuzde = FormatNumber(yuzde, 2) End If If deger < 1 Then deger = 0 Range(adres).ClearComments Range(adres).AddComment " " Range(adres).Comment.Visible = False Range(adres).Comment.Text Text:="Eski Deer: " & deger & Chr(10) & "Deiim: %" & yuzde End Sub Public Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) adres = Range("IV1").Value deger = Range("IV2").Value If adres > 0 Then yenideger = Range(adres).Value If deger <> yenideger Then Call yaz(deger, adres, yenideger) End If End If Range("IV1").Value = ActiveCell.Address Range("IV2").Value = ActiveCell.Value End Sub Sub kopyala() Dim pir1 As Range, pir2 As Range Set pir1 = Range("A1:B2") Set pir2 = Range("F1:G2") pir2.Value = pir1.Value pir2.NumberFormat = pir1.NumberFormat End Sub Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False Me.Cells(Target.Row, 1) = Now '1 steht fr Spalte A, fr Spalte H waere es die 8 Application.EnableEvents = True End Sub Sub Accumulate() Dim n As Integer Dim t As Integer For n = 1 To 10 t=t+n Next n MsgBox " The total is " & t End Sub Sub a() b = WorksheetFunction.Sum(Sheets("sayfa1").Range("A1:A50")) End Sub 'bu kodda b deikenine A1:A50 arasndaki deerlerin toplam atanmtr. Sub Dialog_34() Application.Dialogs(xlDialogFormulaReplace).Show End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 2 Then Application.OnKey "{Del}", "" Else Application.OnKey "{Del}" End If End Sub
Sub demo() Dim saat1 As Date Dim saat2 As Date saat1 = "15/10/2005" saat2 = Date If saat2 > saat1 Then MsgBox ("Sreniz dolmu zgnm.") ActiveWorkbook.Close End If MsgBox ("Kullanm iin " & saat1 - saat2 & " gnnz kalmtr.") MsgBox "Bu gn SON GN" End If End Sub Sub Auto_Open() Dim bitis As Date bitis = "11/30/2006" If Date > bitis Then MsgBox ("Kullanm Sresi Dolmutur") ActiveWorkbook.Close End If MsgBox ("Kalan Gn : " & bitis - Date) End Sub '1 ADET COMMAND '4 ADET TEXT '5 ADET LABEL Private Sub Command1_Click() Label5.Caption = (Val(Text1) + Val(Text2) + Val(Text3) + Val(Text4)) / 4 End Sub Private Sub UserForm_Activate() Combo1.AddItem "DERSNZN SM" Combo1.AddItem "DERSNZN SM" Combo1.AddItem "DERSNZN SM" Combo1.AddItem "DERSNZN SM" Combo1.AddItem "DERSNZN SM" Combo1.AddItem "DERSNZN SM" Combo1.AddItem "DERSNZN SM" Combo1.AddItem "DERSNZN SM" Combo1.AddItem "DERSNZN SM" End Sub Private Sub Text1_Change() If Val(Text1) > 100 Or 0 > Val(Text1) Then MsgBox "GRDNZ SAYI 0 LE 100 ARASI OLMALIDIR" Text1.Text = "" End If End Sub Private Sub Text2_Change() If Val(Text2) > 100 Or Val(Text2) < 0 Then MsgBox "GRDNZ SAYI 0 LE 100 ARASI OLMALIDIR" Text2.Text = "" End If End Sub Private Sub Text3_Change() If Val(Text3) > 100 Or 0 > Val(Text3) Then MsgBox "GRDNZ SAYI 0 LE 100 ARASI OLMALIDIR" Text3.Text = "" End If End Sub Private Sub Text4_Change() If Val(Text4) > 100 Or 0 > Val(Text4) Then MsgBox "GRDNZ SAYI 0 LE 100 ARASI OLMALIDIR" Text4.Text = "" End If End Sub
If sure
Private Sub yaz(deger, adres, yenideger) If deger = 0 Then yuzde = 1 ElseIf IsNumeric(deger) And IsNumeric(yenideger) Then yuzde = (deger - yenideger) / deger yuzde = yuzde * 100 * (-1) yuzde = FormatNumber(yuzde, 2) End If If deger < 1 Then deger = 0 Range(adres).ClearComments Range(adres).AddComment " " Range(adres).Comment.Visible = False Range(adres).Comment.Text Text:="Eski Deer: " & deger & Chr(10) & "Deiim: %" & yuzde End Sub Public Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) adres = Range("IV1").Value deger = Range("IV2").Value If adres > 0 Then yenideger = Range(adres).Value If deger <> yenideger Then Call yaz(deger, adres, yenideger) End If End If Range("IV1").Value = ActiveCell.Address Range("IV2").Value = ActiveCell.Value End Sub Application.StatusBar = " LDER GROUP 2005 / - MALYET ANALZ LSTELER -" Sheets("ANA SAYFA").Select Range("A1").Select Dim kullanici As String Dim tarih As String Dim saat As String tarih = Now() kullanici = Application.UserName saat = Format(tarih, "hh:mm:ss") tarih = Format(tarih, "d mmmm yyyy dddd") MsgBox " MERHABA " & kullanici & ", HO GELDNZ!" & Chr(13) & Chr(13) & _ "Tarih : " & tarih & Chr(13) & Chr(13) _ & "Saat : " & saat & Chr(13) & Chr(13) _ & "Kalite Ynetim Mdrl yi almalar Diler." & Chr(13) & Chr(13), vbApplicationModal, " LDER GROUP End Sub Sub Auto_Close() Dim kullanici As String Dim tarih As String Dim saat As String tarih = Now() kullanici = Application.UserName saat = Format(tarih, "hh:mm:ss") tarih = Format(tarih, "d mmmm yyyy dddd") MsgBox " GRMEK ZERE " & kullanici & Chr(13) & Chr(13) & _ "Tarih : " & tarih & Chr(13) & Chr(13) _ & "Saat : " & saat & Chr(13) & Chr(13) _ & "Kalite Ynetim Mdrl yi almalar Diler." & Chr(13) & Chr(13), vbApplicationModal, " LDER GROUP
2005 "
2005 "
' run this macro from a button or something similar... Sub SheetNavigation() Dim ws As Worksheet Application.ScreenUpdating = False Set dlg = ActiveWorkbook.DialogSheets.Add With dlg.DialogFrame .Left = 0 .Top = 0 .Height = 300 ' dialog height .Width = 300 ' dialog width End With dlg.Buttons(1).Left = 245 ' position of button1 dlg.Buttons(2).Left = 245 ' position of button2 With dlg.ListBoxes.Add(10, 15, 230, 275) ' size of listbox For Each ws In ActiveWorkbook.Worksheets If ws.Visible Then .AddItem ws.Name Next ws .ListIndex = 0 .OnAction = "DisplaySheet" End With dlg.DialogFrame.Text = "Select the worksheet you want to activate" dlg.Visible = False Application.ScreenUpdating = True If dlg.Show Then Worksheets(dlg.ListBoxes(1).List(dlg.ListBoxes(1).ListIndex)).Activate End If Application.DisplayAlerts = False dlg.Delete Application.DisplayAlerts = True Set ws = Nothing Set dlg = Nothing End Sub Private Sub DisplaySheet() Sheets(dlg.ListBoxes(1).List(dlg.ListBoxes(1).ListIndex)).Activate End Sub zerindeki bir makinedeki bir excel kitabnn iindeki makroyu kendi makinenizden altrmak Kod: Application.Run "\\makineadi\klasoradi\kitapadi.xls!makroadi" eer kitaplar ayn makine zerinde ise Kod: Application.Run "c:\klasoradi\kitapadi.xls!makroadi" Sub Essai() Run ("Kitap1.xls!Module1.MAkro1") End Sub Form2 VBA Public Sub Buton1_Click() Msgbox "Merhaba" End Sub 'Form1 VBA 'da Private Sub Buton1_Click() userform2.buton1_click End Sub Application.Run "kitap2.xls!makro1"
Sub firma() Dim no no = InputBox("Firma Ad Giriniz!", "Firma Ad Girii") a = Cells.Find(what:=no).Activate ActiveCell.EntireRow.Copy Application.Sheets("Sayfa2").Activate b = WorksheetFunction.CountA(Range("A:A")) Cells(b + 1, 1).Select ActiveSheet.Paste End Sub Sub dortgen_sil() For Each Rectangle In ActiveSheet.Shapes Rectangle.Delete Next End Sub Declare Function SetVolumeLabel Lib "kernel32" Alias "SetVolumeLabelA" _ (ByVal lpRootPathName As String, ByVal lpVolumeName As String) As Long Sub NommeDSK() retval = SetVolumeLabel("a:\", "MaDisquette") 'pour supprimer le label 'retval = SetVolumeLabel("a:\", vbNullString) End Sub Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private hWnd As Long Const SHFMT_DRV_A = 0 Const SHFMT_DRV_B = 1 Const SHFMT_ID_DEFAULT = &HFFFF Const SHFMT_OPT_QUICKFORMAT = 0 Const SHFMT_OPT_FULLFORMAT = 1 Const Const Const Const SHFMT_OPT_SYSONLY = 2 SHFMT_ERROR = -1 SHFMT_CANCEL = -2 SHFMT_NOFORMAT = -3
Private Sub format() Dim Res As Long hWnd = FindWindow(vbNullString, Me.Caption) Res = SHFormatDrive(hWnd, SHFMT_DRV_A, SHFMT_ID_DEFAULT, SHFMT_OPT_QUICKFORMAT) Select Case Res Case SHFMT_ERROR MsgBox "Hata.", vbCritical Case SHFMT_CANCEL MsgBox "ptal edildi.", vbInformation Case SHFMT_NOFORMAT MsgBox "Formatl deil.", vbInformation Case Else MsgBox "Formatlama bitti." End Select End Sub
Private Sub CommandButton1_Click() format End Sub Const SHFD_CAPACITY_DEFAULT = 0 ' default drive capacity Const SHFD_CAPACITY_360 = 3 ' 360KB, applies to 5.25" drives only Const SHFD_CAPACITY_720 = 5 ' 720KB, applies to 3.5" drives only Const SHFD_FORMAT_QUICK = 0 ' quick format Const SHFD_FORMAT_FULL = 1 ' full format Const SHFD_FORMAT_SYSONLY = 2 ' copies system files only (Win95 Only!) Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwndOwner As Long, ByVal iDrive As Long, ByVal iCapacity As Long, ByVal iFormatType As L Sub Disket_formatla() SHFormatDrive hwnd, 0, SHFD_CAPACITY_DEFAULT, SHFD_FORMAT_QUICK End Sub
Sub SaveWorkbookBackupToFloppyA() Dim awb As Workbook, BackupFileName As String, i As Integer, OK As Boolean If TypeName(ActiveWorkbook) = "Nothing" Then Exit Sub Set awb = ActiveWorkbook If awb.path = "" Then Application.Dialogs(xlDialogSaveAs).Show Else BackupFileName = awb.Name OK = False On Error GoTo NotAbleToSave If Dir("A:" & BackupFileName) <> "" Then Kill "A:" & BackupFileName End If With awb Application.StatusBar = "Saving this workbook..." .Save Application.StatusBar = "Saving this workbook backup..." .SaveCopyAs "A:" & BackupFileName OK = True End With End If NotAbleToSave: Set awb = Nothing Application.StatusBar = False If Not OK Then MsgBox "Backup Copy Not Saved!", vbExclamation, ThisWorkbook.Name End If End Sub
'//The Shell function runs other programs asynchronously so what '//What you basically have to do is Open the existing Process '//for the running Application and, LOOP & WAIT for the processes return state '//ie when the specified process is in the signaled state '//or a timeout occurs. Private Declare Function OpenProcess Lib "kernel32" ( _ ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Private Declare Function WaitForSingleObject Lib "kernel32" ( _ ByVal hHandle As Long, _ ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" ( _ ByVal hProcess As Long, _ lpExitCode As Long) As Long '&HFFFF Private Const SYNCHRONIZE = &H100000 '// Note:SYNCHRONIZE Windows NT/2000 Private Const INFINITE = &HFFFF 'OR -1& '// INFINITE, the functions time-out interval never elapses. Private Const STILL_ACTIVE = &H103 Public Function ShellAndWait(ByVal BatFile As String) ' ' Shells a new process and waits for it to complete. ' Calling application is totally non-responsive while ' new process executes. ' Dim PID As Long Dim hProcess As Long Dim nRet As Long '// Unlike other Functions Shell generates an error '// instead of returning a 0 so handling the error '// = Application NOT started. On Error Resume Next PID = Shell(BatFile, vbMinimizedNoFocus) If Err Then '// handle the error here and End MsgBox "Could NOT exercute:= " & BatFile End End If On Error GoTo 0 '// SYNCHRONIZE For Windows NT/2000: '// Enables using the process handle in any of the wait '// functions to wait for the process to terminate. '// obviously with NT you need access rights. hProcess = OpenProcess(SYNCHRONIZE, False, PID) '// Just set the dwMilliseconds to INFINITE to initiate a Loop nRet = WaitForSingleObject(hProcess, INFINITE) Do GetExitCodeProcess hProcess, nRet DoEvents Loop While nRet = STILL_ACTIVE CloseHandle hProcess End Function Sub OpenFileAndWait() Dim sApp As String '// Define the Application FullPath here sApp = "C:\A\Batch.bat" 'sApp = "C:\windows\system32\calc.exe" '// Lets DoIt ShellAndWait sApp '// Tell me if Successful MsgBox "Finished running task!" End Sub
Sub polygon() 'zeichnet Polygon Application.ScreenUpdating = False anzeck = InputBox("Wieviele Ecken ?") If anzeck = Empty Or Not IsNumeric(anzeck) Or anzeck < 3 Then Exit Sub seite = InputBox("Seitenlnge ?") If seite = Empty Or Not IsNumeric(seite) Then Exit Sub a = 200 ActiveSheet.Drawings.Add(a, a, a + seite, a, False) _ .Select winkel = 180 - 360 / anzeck gegenwinkel = 180 - (winkel + 90) winkel1 = 3.14159265358979 * winkel / 180 gegenwinkel1 = 3.14159265358979 * gegenwinkel / 180 x = a + seite y=a k=1 For i = 1 To anzeck - 1 x = x - k * seite * Sin(gegenwinkel1) y = y + k * seite * Cos(gegenwinkel1) Selection.AddVertex x, y k = k * (-1) gegenwinkel1 = gegenwinkel1 - winkel1 Next Application.ScreenUpdating = True End Sub Sub sec() Worksheets(Array(1, 3, 5)).Select End Sub Sub Src_smi() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.GetDriveName("C:\SXS\Deneme\Ben.txt") MsgBox a End Sub Sub Dizindeki_Son_sim() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.GetBaseName("C:\SXS\Deneme\Ben.txt") MsgBox a End Sub Sub Src_smi() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.GetDriveName("C:\SXS\Deneme\Ben.txt") MsgBox a End Sub Dim d_tarih Do d_tarih = InputBox("Doum Tarihiniz r:01/04/1979", "Doum Tarihinizi Yazn Ltfen") Loop While Not IsDate(d_tarih) MsgBox (WeekdayName(Weekday(d_tarih, 0), False, 0) + " " + "Gn Domusunuz.")
Dim sDollars As String Dim sCents As String Dim iLen As Integer Dim sTemp As String Dim iPos As Integer Dim iHundreds As Integer Dim iTens As Integer Dim iOnes As Integer Dim sUnits(2 To 5) As String Dim bHit As Boolean Dim vOnes As Variant Dim vTeens As Variant Dim vTens As Variant If Not IsNumeric(vNumber) Then Exit Function End If sDollars = Format(vNumber, "###0.00") iLen = Len(sDollars) - 3 If iLen > 15 Then DollarText = CVErr(xlErrNum) Exit Function End If sCents = Right$(sDollars, 2) & "/100 Dollars" If vNumber < 1 Then DollarText = sCents Exit Function End If sDollars = Left$(sDollars, iLen) vOnes = Array("", "One", "Two", "Three", "Four", "Five", _ "Six", "Seven", "Eight", "Nine") vTeens = Array("Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", _ "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen") vTens = Array("", "", "Twenty", "Thirty", "Forty", "Fifty", _ "Sixty", "Seventy", "Eighty", "Ninety") sUnits(2) = "Thousand" sUnits(3) = "Million" sUnits(4) = "Billion" sUnits(5) = "Trillion" sTemp = "" For iPos = 15 To 3 Step -3 If iLen >= iPos - 2 Then bHit = False If iLen >= iPos Then iHundreds = Asc(Mid$(sDollars, iLen - iPos + 1, 1)) - 48 If iHundreds > 0 Then sTemp = sTemp & " " & vOnes(iHundreds) & " Hundred" bHit = True End If End If iTens = 0 iOnes = 0 If iLen >= iPos - 1 Then iTens = Asc(Mid$(sDollars, iLen - iPos + 2, 1)) - 48 End If If iLen >= iPos - 2 Then iOnes = Asc(Mid$(sDollars, iLen - iPos + 3, 1)) - 48 End If If iTens = 1 Then sTemp = sTemp & " " & vTeens(iOnes) bHit = True Else If iTens >= 2 Then sTemp = sTemp & " " & vTens(iTens) bHit = True End If If iOnes > 0 Then If iTens >= 2 Then sTemp = sTemp & "-" Else sTemp = sTemp & " " End If sTemp = sTemp & vOnes(iOnes) bHit = True End If End If
aktif sayfaya alr kutu ekleyin. Referansn A stununa verin. A stunundakileri dolayl olarak b14 te gsterir ActiveSheet.Shapes("Drop Down 1").Select [b14] = Evaluate("=INDIRECT(""A" & Selection.Value & """" & ")") [b13].Select End Sub Sub yaz() ActiveSheet.Shapes("Drop Down 1").Select [b14] = Evaluate("=INDIRECT(""A" & Selection.Value & """" & ")") [b13].Select End Sub Sub doluyazdir() ActiveSheet.UsedRange.Select Selection.PrintOut End Sub Sub ActivateNextBlankDown() ActiveCell.Offset(1, 0).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop End Sub 'Not: Satrlar iin (0,1) olmaldr. Sub DoluHucreSay() 'Returns a count of non-blank cells in a selection Dim myCount As Integer 'using the CountA ws function (all non-blanks) myCount = Application.CountA(Selection) MsgBox "Seili alandaki bo olmayan hcre says: " _ & myCount, vbInformation, "Dolu Hcre Say" End Sub Sub doluhucre_sec() Dim range As range Sheets("Sayfa1").Activate ActiveSheet.UsedRange.Select For Each range In Selection If range.HasFormula = False Then range.Value = UCase(range.Value) End If Next End Sub Sub doluhucre_sec() Dim range As range Sheets("Sayfa1").Activate ActiveSheet.UsedRange.Select For Each range In Selection If range.HasFormula = False Then range.Value = LCase(range.Value) End If Next End Sub Seili hcrenin altnda veriler varsa onlar seer. lk bo hcreden sonra ilk deer olan hcreyi seer. Range(ActiveCell,ActiveCell.End(xlDown)).Select 'stteki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlUp)).Select 'Sadaki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlToRight)).Select 'Soldaki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlToLeft)).Select 'Aktif hcrenin etrafndaki dolu hcreleri seer. ActiveCell.CurrentRegion.Select 'Seimin etrafndaki dolu hcreleri seer. Selection.CurrentRegion.Select 'Btn veri olan hcreleri seer. Range(Range("A1"), ActiveCell.SpecialCells(xlLastCell)).Select Sub DoluKayitSayisi() Sayi = WorksheetFunction.CountA(Range("A1:A9000")) 'Eer mesajla almak isterseniz u koduda ekleyin MsgBox Sayi End Sub
Private Sub CommandButton1_Click() Dim MyRng As Range Dim NoA1 As Long Set sh1 = Sheets("Sayfa1") Set sh2 = Sheets("Sayfa2") NoA1 = sh1.Cells(65536, 1).End(xlUp).Row For Each MyRng In sh1.Range("A1:A" & NoA1) NoA2 = sh2.Cells(65536, 1).End(xlUp).Row + 1 If MyRng <> "m.cinsi" And MyRng <> "" Then sh2.Range("A" & NoA2) = MyRng sh2.Range("B" & NoA2) = MyRng.Offset(0, 1) sh2.Range("C" & NoA2) = MyRng.Offset(0, 2) sh2.Range("D" & NoA2) = MyRng.Offset(0, 3) End If Next End Sub activesheet.usedrange.select veya, C2 den balayarak C stunundaki son dolu hcreye kadar seim: range("c2:c" & cells(65536, 3).end(xlup).row).select baka bir yazm ekli de; range("c2:c" & range("c65536").end(xlup).row).select Sub Select_Cells() addr = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address Intersect(Range(addr).EntireRow, Range("C:L")).Select End Sub Sub Copy_Cells() addr = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address Intersect(Range(addr).EntireRow, Range("C:L")).Select Selection.Copy Sheet2.Range("A65536").End(xlUp).Offset(1, 0) End Sub Sub SelAllData() Application.ScreenUpdating = False Dim myLastRow As Long Dim myLastColumn As Long Range("A1").Select On Error Resume Next myLastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row myLastColumn = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column myLastCell = Cells(myLastRow, myLastColumn).Address myRange = "a1:" & myLastCell Application.ScreenUpdating = True Range(myRange).Select End Sub Private Sub CommandButton1_Click() Dim say Dim ekle On Error Resume Next For say = 1 To UserForm1.Controls.Count If Mid(Controls(say).Name, 1, 7) = "TextBox" Then GoTo ileri Else GoTo gec End If ileri: If Controls(say).Text <> "" Then ekle = ekle + 1 End If gec: Next say MsgBox ekle End Sub
Function LastCell(ws As Worksheet) As Range Dim LastRow&, LastCol% On Error Resume Next With ws LastRow& = .Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByRows).Row LastCol% = .Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByColumns).Column End With Set LastCell = ws.Cells(LastRow&, LastCol%) End Function Sub RealLastCell() RLC = LastCell(ActiveSheet).Address(False, False) MsgBox ("The ""real"" last cell is..." & vbCrLf & vbLf & RLC) End Sub Sub Used_Range() ActiveSheet.UsedRange.Select End Sub Function WorkbookOpen(WorkBookName As String) As Boolean WorkbookOpen = False On Error GoTo WorkBookNotOpen If Len(Application.Workbooks(WorkBookName).Name) > 0 Then WorkbookOpen = True Exit Function End If WorkBookNotOpen: End Function Sub AA() If Not WorkbookOpen("C.xls") Then Workbooks.Open "C.xls" End If End Sub Sub Auto_Open() Workbooks.Open ThisWorkbook.Path & "\Dosya.xls", UpdateLinks:=0 ThisWorkbook.Close False End Sub Sub auto_open() Sheets("GR").Select Range("a1").Select MsgBox "GR Sayfasndaki gerekli bilgileri doldurun " End Sub 'ThisWorkbook'a aklama ekler(kitap aldnda otomatik devreye girer. Private Sub Workbook_Open() Call MsgBox("Programlayan : Mahmut BAYRAM" & vbNewLine & vbNewLine & _ "Sonular kontrol etmeyi unutmayn!" & vbNewLine & vbNewLine & _ "sayfalar kopyalayabilirsiniz. ", vbInformation, "UYARI") End Sub Sub auto_open() Sheets("GR").Select Range("a1").Select MsgBox "GR Sayfasndaki gerekli bilgileri doldurun " End Sub 'ThisWorkbook'a aklama ekler(kitap aldnda otomatik devreye girer. Private Sub Workbook_Open() Call MsgBox("Programlayan : pir." & vbNewLine & vbNewLine & _ "Sonular kontrol etmeyi unutmayn!" & vbNewLine & vbNewLine & _ "sayfalar kopyalayabilirsiniz. ", vbInformation, "UYARI") End Sub
Sub DateiAuswahl() Dim WB As Workbook Dim TB As Worksheet Dim i% Dim dName Dim dFilter$ dFilter = "Excel-Dateien(*.xls), *.xls" ChDrive "c" ChDir "c:\" dName = Application.GetOpenFilename(dFilter) If dName = False Then Exit Sub Set WB = Workbooks.Open(dName) Set TB = WB.Worksheets(1) For i = 1 To 20 TB.Cells(i, 5) = "Spalte E - Zeile " & i Next i End Sub Function DosyaAdi() As String Application.Volatile DosyaAdi = Application.Caller.Parent.Parent.FullName End Function UYARI: Aadaki ilevlerin sonu verebilmesi iin alma kitabnn kaydedilmi olmas gerekmektedir. alma kitabnn tam yolunu, adn ve alma sayfas adn birlikte yazdrmak iin; =HCRE("DosyaAd") alma kitabnn yolunu yazdrmak iin; =SOLDAN(HCRE("DosyaAd");BUL("[";HCRE("DosyaAd");1)-1) alma kitab adn dosya uzants ile birlikte yazdrmak iin; =PARAAL(HCRE("DosyaAd");MBUL("[";HCRE("DosyaAd");1)+1;MBUL("]";HCRE("DosyaAd");1)-MBUL("[";HCRE("DosyaAd"))-1) alma kitab adn dosya uzants olmakszn yazdrmak iin; =PARAAL(HCRE("DosyaAd");MBUL("[";HCRE("DosyaAd");1)+1;MBUL("]";HCRE("DosyaAd");1)-MBUL("[";HCRE("DosyaAd"))-5)
alma sayfas adn yazdrmak iin; =SADAN(HCRE("DosyaAd");UZUNLUK(HCRE("DosyaAd"))-MBUL("]";HCRE("DosyaAd");1)) Tek bana bir ie yaramayan bir kod. Ad geen dosya ismi hafzada tutuluyor ve ilemler bu dosya zerinden yaplyor. rnekler ikinci blmde 'verilecek Sub Dosya_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFile("D:\Excelrnekleri\Soru.xls") MsgBox f End Sub 'Bu kodda ise dosya deil,sadece ismi alnyor. Sub Dosya_smi_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.GetFileName("D:\Excelrnekleri\Soru.xls") 'Sadece Dosya ismi alnd iin SET tabiri kullanlmaz MsgBox f End Sub Sub ProcessBooks() Dim wkbk As Workbook Dim i As Long With Application.FileSearch .NewSearch .LookIn = "C:\My Documents" .SearchSubFolders = False .FileName = "*.xls" .FileType = msoFileTypeExcelWorkbooks If .Execute() > 0 Then
Sub dosya_ara() With Application.FileSearch .LookIn = "C:\Windows" 'arama yaplan dizin .SearchSubFolders = True 'alt klasrler aransn m '.FileType = msoFileTypeExcelWorkbooks ' aranacak dosya trleri .Filename = "*.txt" 'aranacak dosya isimleri/uzantlar If .Execute() > 0 Then MsgBox .FoundFiles.Count & " adet dosya bulundu." For i = 1 To .FoundFiles.Count Cells(i, 1) = .FoundFiles(i) Next i Else MsgBox "Hi dosya bulunamad.", vbCritical End If End With End Sub Sub dosya_ara() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.FileExists("C:\testfile.txt") If a = True Then MsgBox "Bu isimde bir dosya var" Else MsgBox "Bu isimde bir dosya yok" End If End Sub istediiniz dosyalar (alt klasrler dahil) nasl bulacanz ve bir comboda nasl listeleyeceiniz yazyor. Diskteki 'Bir forma btnara ismli bir dme ve comsonuc isimli bir combobox yerletirmeniz yeterli. Private Sub btnara_Click() comsonuc.Clear comsonuc.Refresh Dim arama As Object Dim aradosya As Object Set arama = CreateObject("FileSearch.Search") Call arama.SearchFiles("d:\", "*.mp3", True) Call arama.SearchFiles("C:\", "*.xls", True) DoEvents If arama.Files.Count > 0 Then For Each aradosya In arama.Files comsonuc.AddItem aradosya.FileName Set aradosya = Nothing Next End If Set arama = Nothing comsonuc.text="ARAMA BTT" End Sub Sub Existe() If Dir$("c:\ajeter\test.xls") = "" Then MsgBox " Pas trouv ce fichier :O(" Else MsgBox " OK ! Trouv :O)" End If End Sub Sub Dosya_Bilgisi_Gster() Dim ds, f, s Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFile("D:\Excelrnekleri\Soru.xls") s = UCase("D:\Excelrnekleri\Soru.xls") & vbCrLf s = s & "Created: " & f.DateCreated & vbCrLf 'Oluturma s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf 'Son Eriim s = s & "Last Modified: " & f.DateLastModified 'Son Deitirilme MsgBox s, 0, "Folder Access Info" End Sub
Sub auto_open() Dim fso, drv, cdr Set fso = CreateObject("Scripting.FileSystemObject") For Each drv In fso.Drives If drv.driveType = 4 Then Set cdr = drv Next If cdr.volumename <> "CD nin ad" Then MsgBox "Ltfen program cd sini takmadan program altrmaynz" ThisWorkbook.Close False End If End Sub Function FileExists(FullFileName As String) As Boolean FileExists = Len(Dir(FullFileName)) > 0 End Function Sub ss() If Not FileExists("C:\f.xls") Then MsgBox "Aradnz dosya belirtilen dizinde yok" Else Workbooks.Open "C:\f.xls" End If End Sub
Sub CreateMenu() ' creates a new menu. ' can also be used to create commandbarbuttons ' may be automatically executed from an Auto_Open macro or a Workbook_Open eventmacro Dim cbMenu As CommandBarControl, cbSubMenu As CommandBarControl RemoveMenu ' delete the menu if it already exists ' create a new menu on an existing commandbar (the next 6 lines) Set cbMenu = Application.CommandBars(1).Controls.Add(msoControlPopup, , , , True) With cbMenu .Caption = "&My menu" .Tag = "MyTag" .BeginGroup = False End With ' or add to an existing menu (use the next line instead of the previous 6 lines) 'Set cbMenu = Application.CommandBars.FindControl(, 30007) ' Tools-menu If cbMenu Is Nothing Then Exit Sub ' didn't find the menu... ' add menuitem to menu With cbMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "&Menu Item1" .OnAction = ThisWorkbook.Name & "!Macroname" End With ' add menuitem to menu With cbMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "&Menu Item2" .OnAction = ThisWorkbook.Name & "!Macroname" End With ' add a submenu Set cbSubMenu = cbMenu.Controls.Add(msoControlPopup, 1, , , True) With cbSubMenu .Caption = "&Submenu1" .Tag = "SubMenu1" .BeginGroup = True End With ' add menuitem to submenu (or buttons to a commandbar) With cbSubMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "&Submenu Item1" .OnAction = ThisWorkbook.Name & "!Macroname" .Style = msoButtonIconAndCaption .FaceId = 71 .State = msoButtonDown ' or msoButtonUp End With ' add menuitem to submenu (or buttons to a commandbar) With cbSubMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "&Submenu Item2" .OnAction = ThisWorkbook.Name & "!Macroname" .Style = msoButtonIconAndCaption .FaceId = 72 .Enabled = False ' or True End With ' add a submenu to the submenu Set cbSubMenu = cbSubMenu.Controls.Add(msoControlPopup, 1, , , True) With cbSubMenu .Caption = "&Submenu2" .Tag = "SubMenu2" .BeginGroup = True End With ' add menuitem to submenu submenu With cbSubMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "&Submenu Item1" .OnAction = ThisWorkbook.Name & "!Macroname" .Style = msoButtonIconAndCaption .FaceId = 71 .State = msoButtonDown ' or msoButtonUp End With
Sub MenuErstellen() Dim MB As CommandBar Dim Ctrl1 As CommandBarControl Dim Ctrl2 As CommandBarControl Dim Ctrl1a As CommandBarControl Dim Ctrl1b As CommandBarControl Set MB = CommandBars.Add(Name:="Neues Men", MenuBar:=True) Set Ctrl1 = MB.Controls.Add(Type:=msoControlPopup) Ctrl1.Caption = "Untermen1" Set Ctrl2 = MB.Controls.Add(Type:=msoControlPopup) Ctrl2.Caption = "Untermen2" Set Ctrl1a = Ctrl1.Controls.Add(Type:=msoControlPopup) Ctrl1a.Caption = "Daten" Set Ctrl1b = Ctrl1.Controls.Add(Type:=msoControlPopup) Ctrl1b.Caption = "bertragen" CommandBars("Neues Men").Visible = True End Sub MenuBars(xlWorksheet).Menus.Add "&Test Men" Set ml = MenuBars(xlWorksheet).Menus("Test Men") With ml .MenuItems.Add Caption:="&Daten erfassen", _ OnAction:="DatenSpeichern" .MenuItems.AddMenu Caption:="&Auswertungen" With .MenuItems("Auswertungen") .MenuItems.Add Caption:="&Auswertung1", _ OnAction:="" .MenuItems.Add Caption:="A&uswertung2", _ OnAction:="" End With End With End Sub Private Sub Workbook_Deactivate() MenuBars(xlWorksheet).Reset End Sub Private Sub Workbook_Open() MenuBars(xlWorksheet).Menus.Add "&Test Men" Set ml = MenuBars(xlWorksheet).Menus("Test Men") With ml .MenuItems.Add Caption:="&Daten erfassen", _ OnAction:="DatenSpeichern" .MenuItems.AddMenu Caption:="&Auswertungen" With .MenuItems("Auswertungen") .MenuItems.Add Caption:="&Auswertung1", _ OnAction:="" .MenuItems.Add Caption:="A&uswertung2", _ OnAction:="" End With End With End Sub Sub Menueleiste_ausblenden() Application.CommandBars("Worksheet Menu Bar").Enabled = False End Sub Sub Menueleiste_einblenden() Application.CommandBars("Worksheet Menu Bar").Enabled = True End Sub Sub supBA() For Each LaBarMenu In ActiveMenuBar.Menus LaBarMenu.Delete Next MsgBox "Barre de menus supprime !" ActiveMenuBar.Reset MsgBox "Barre de menus rtablie !" End Sub Sub ac() Application.CommandBars(1).Enabled = True End Sub
Sub Dosya_simleri() Dim ds, dc, f, s Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("C:\SXS") Set dc = f.Files For Each dosya In dc s = s & vbCrLf & dosya.Name Next MsgBox s End Sub Sub Dosya_simleri() Dim ds, dc, f, s Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("C:\SXS") Set dc = f.Files For Each dosya In dc s = s & vbCrLf & dosya.Name Next MsgBox s End Sub Sub Dosyalar() Dim Klasor As String Dim Dosya As String Dim i As Integer Klasor = "C:\osman" Dosya = Dir(Klasor & Application.PathSeparator & "*.*", vbDirectory) Do While Dosya <> "" Cells(i + 1, 1) = Dosya i=i+1 Dosya = Dir Loop End Sub Sub Dosya_smi_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.GetFileName("D:\Excelrnekleri\Soru.xls") 'Sadece Dosya ismi alnd iin SET tabiri kullanlmaz MsgBox f End Sub Tek bana bir ie yaramayan bir kod. Sub Dosya_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFile("D:\Excelrnekleri\Soru.xls") MsgBox f End Sub ThisWorkbook'a Private Sub Workbook_Open() Worksheets("Sayfa1").Range("A1").Value = Worksheets("Sayfa1").Range("A1").Value + 1 MsgBox "Bu dosya " & Worksheets("Sayfa1").Range("A1").Value & " kez ald" & vbCrLf & "En son aan : " & Worksheets("Sayfa1").Range("B1") Worksheets("Sayfa1").Range("B1") = Application.UserName ThisWorkbook.Save End Sub Sub Auto_Open() 'belirtilen dizinde "pir" isimli bir klasr olup olmadna bakar yoksa oluturur On Error Resume Next If Dir("C:\pir") = "" Then MkDir "C:\pir" Sheets("Sheet1").Select End Sub Sub dosyaekle() 'belirtilen dizine dosya ekler. ayn isimli dosya varsa ncekini siler yeniden ekler Dim Dosyam As String, Message As String Workbooks.Add 'alma kitab ekler Dosyam = "C:\pir.xls" 'yeni eklenecek dosyamzn ismi On Error Resume Next Kill Dosyam 'nceki dosyay kaldrr On Error GoTo 0 ActiveWorkbook.SaveAs Filename:=Dosyam 'dosyaya isim verir ActiveWorkbook.Close End Sub
Sub Auto_Open() 'belirtilen dizinde "mahmut" isimli bir klasr olup olmadna bakar yoksa oluturur On Error Resume Next If Dir("C:\mahmut") = "" Then MkDir "C:\pir" Sheets("Sheet1").Select End Sub Sub dosyaekle() 'belirtilen dizine dosya ekler. ayn isimli dosya varsa ncekini siler yeniden ekler Dim Dosyam As String, Message As String Workbooks.Add 'alma kitab ekler Dosyam = "C:\mahmut.xls" 'yeni eklenecek dosyamzn ismi On Error Resume Next Kill Dosyam 'nceki dosyay kaldrr On Error GoTo 0 ActiveWorkbook.SaveAs Filename:=Dosyam 'dosyaya isim verir ActiveWorkbook.Close End Sub Sub dosya_listeleme() Dim datename As String, i As Integer datename = Dir$("C:\Documents and Settings\pir\Belgelerim\*.xls") Do While datename <> "" ActiveCell.Offset(i, 0) = datename i=i+1 datename = Dir$() Loop End Sub Sub Verstecken() For Each tb in Toolbars tb.Visible = False Next tb End Dosya_zellikleri_Ayarla() Sub Sub zellik = InputBox("Dosyann Deitirmek stediiniz zelliini Aadan Seip" + Chr(13) + _ "Bolua Sadece zellik Numarasn Yaznz:" + Chr(13) + vbCrLf + _ "Normal = 0, Salt Okunur = 1, Gizli = 2 , Sistem = 4, Volume = 8, Directory = 16 , Ariv = 32 , Link/Ksayol = 64 , Sktrlm = 128") Dim ds, f, r Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFile("C:\Deneme.txt") If f.Attributes And zellik Then r = MsgBox("Dosya zellii Zaten" & " " & zellik & Chr(13) & _ "Silmek stiyor musunuz?", vbYesNo, "Dosya zellii Ayarla/Temizle") If r = vbYes Then f.Attributes = f.Attributes - zellik MsgBox "Dosya zellii Temizlendi" Else MsgBox "Dosya zellii Olduu Gibi Brakld" End If Else r = MsgBox("Dosya zellii Ayarlanmam. imdi ayarlamak stiyor musunuz?", vbYesNo, "Dosya zellii Ayarla/Temizle") If r = vbYes Then f.Attributes = f.Attributes + zellik MsgBox "Dosya zellii ayarland." Else MsgBox "Dosya zellii Olduu Gibi brakld." End If End If End Sub server altndan bircok kullanc bu dosyay kullanabiliyor 'eger dosya kullanlyorsa baka bir kullanc amaya altgnda dosya kullanyor sonra deneyin gibi bir msg box ckmas ve dosyann kapanmas Sub Auto_Open() Workbooks.Open "d:\macro\numaratr\numaratr.xls" If Workbooks("numaratr.xls").ReadOnly = True Then MsgBox "DOSYA KULLANIMDADIR. LUTFEN SONRA DENEYINIZ" deg=1 Workbooks("numarar.xls").Close End If UserForm1.Show End Sub
Sub Dosya_Says() Dim ds, dc, f, s Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("C:\SXS") Set dc = f.Files s = dc.Count MsgBox s End Sub Sub Dosya_Says() Dim ds, dc, f, s Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("C:\SXS") Set dc = f.Files s = dc.Count MsgBox s End Sub Dosya isminden sonra gelen yere ,dosya Salt okunursa True yazmalsnz.Yoksa "Access Denied" yani "Giri Reddedildi" der.
Sub Dosya_Sil() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.DeleteFile "C:\SXS\Deneme.txt", True End Sub Sub sil() Kill "C:\Documents And Settings\pir\Belgelerim\pir.xls" End Sub Sub Dosya_Sistemi_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") s = d.FileSystem MsgBox s End Sub Sub Dosya_Sistemi_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") s = d.FileSystem MsgBox s End Sub Private Declare Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBu Sub Dosya_Sistemi() Dim DosyaSistemi As String DosyaSistemi = String$(255, Chr$(0)) GetVolumeInformation "C:\", 0, 255, 0, 0, 0, DosyaSistemi, 255 DosyaSistemi = Left$(DosyaSistemi, InStr(1, DosyaSistemi, Chr$(0)) - 1) MsgBox DosyaSistemi End Sub Sub dosya_sonunda_son_harf() Dim ds, a, son Set ds = CreateObject("Scripting.FileSystemObject") Set a = ds.OpenTextFile("c:\deneme.txt") Do While a.AtEndOfStream <> True son = a.Read(1) 'Dosya Sonundaki son harfi verir. Loop MsgBox son a.Close End Sub Sub dosya_sonunda_tm_satr() Dim ds, a, son Set ds = CreateObject("Scripting.FileSystemObject") Set a = ds.OpenTextFile("c:\deneme.txt") Do While a.AtEndOfStream <> True son = a.Readline 'Dosya Sonundaki tm satr verir. Loop MsgBox son a.Close End Sub
Sub Dosya_Ta() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.MoveFile("D:\Excelrnekleri\Move.xls", "C:\") End Sub Sub Uzant_smi() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.GetExtensionName("D:\Excelrnekleri\Soru.xls") MsgBox f End Sub Sub Uzant_smi() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.GetExtensionName("D:\Excelrnekleri\Soru.xls") MsgBox f End Sub Private Function FileExists(fname) As Boolean ' Dosya varsa DORU dndrr. Dim x As String x = Dir(fname) If x <> "" Then FileExists = True _ Else FileExists = False End Function Sub Win_Rar() Dim WinRar, Arsiv, Kaynak WinRar = "C:\Program Files\WinRAR\WinRAR.exe" 'WinRar uygulamasnn tam yolunu yazn Kaynak = "C:\Belgelerim\Test.xls" 'Sktrlacak dosyann ve ya klasrn tam ad, Arsiv = "A:\" & Left(Dir(Kaynak), Application.Find(".", Dir(Kaynak)) - 1) 'Sktrldktan sonra rar dosyasna verilecek isim 'Rar dosyas oluturuluyor ShellExecute 0, "open", WinRar, _ "a " & Arsiv & " " & Kaynak, "", vbHide For i = 1 To 10: DoEvents: Next Application.Wait Now + TimeValue("00:00:03") 'Setup dosyas oluturuluyor ShellExecute 0, "open", WinRar, _ "s " & Arsiv & ".rar", "", vbHide For i = 1 To 10: DoEvents: Next Application.Wait Now + TimeValue("00:00:10") Kill Arsiv & ".rar" End Sub Sub Yedek() '/_ Dismi= ActiveWorkbook.Name ActiveWorkbook.SaveCopyAs "D:\Alihan_Bordro\ " & Dismi ActiveWorkbook.Save End Sub Sub Enregistre_Sous() Rponse = MsgBox("Voulez-vous enregistrer ce classeur ?", vbYesNo) If Rponse = vbYes Then Nom = InputBox("Donnez un nom de fichier !" & Chr(13) & "Exemple: Rapport") If Nom = "" Then Exit Sub Else GoTo continu End If continu: ChDrive "c" ChDir "c:\" 'Indiquez le rpertoire ActiveWorkbook.SaveAs Filename:=(Nom) End If End Sub
pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" _ (ByVal pidl As Long, ByVal pszPath As String) As Long Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long Private z! Function GetDirectory(Msg) As String Dim bInfo As BROWSEINFO Dim path As String Dim r As Long, x As Long, pos As Integer With bInfo .pidlRoot = 0& .lpszTitle = Msg .ulFlags = &H1 End With x = SHBrowseForFolder(bInfo) path = Space$(512) r = SHGetPathFromIDList(ByVal x, ByVal path) If r Then pos = InStr(path, Chr$(0)) GetDirectory = Left(path, pos - 1) Else GetDirectory = "" End If End Function Sub Dateisuche(Laufwerk, Dateien) Dim tmp, Wdhlg, Dateiname As String On Error Resume Next If Right(Laufwerk, 1) <> "\" Then Laufwerk = Laufwerk + "\" tmp = Dir(Laufwerk & Dateien) Do While Len(tmp) Dateiname = Laufwerk & tmp Application.StatusBar = Dateiname Cells(z, 1).Select Cells(z, 1) = Laufwerk & tmp 'Pfad Cells(z, 2) = FileLen(Laufwerk & tmp) 'Gre Cells(z, 3) = FileDateTime(Laufwerk & tmp) 'Datum/Zeit Cells(z, 4) = tmp 'nur Dateiname z=z+1 tmp = Dir() Loop tmp = Dir(Laufwerk, vbDirectory) Do While Len(tmp) If (tmp <> ".") And (tmp <> "..") Then If (GetAttr(Laufwerk & tmp) And vbDirectory) = vbDirectory Then Dateisuche Laufwerk & tmp, Dateien z=z-1 Wdhlg = Dir(Laufwerk, vbDirectory) z=z+1 Do While Wdhlg <> tmp Wdhlg = Dir() Loop End If End If tmp = Dir() Loop On Error GoTo 0 Application.StatusBar = False End Sub Sub Suchen() Dim Laufwerk$, Dateien$ 'Ersze Zeile, in der eine Eintragung erfolgt z=2 'Alte Eintragungen lschen [a1:e5000] = "" 'Ersatz: ... = "C:\Eigene Dateien" Laufwerk = GetDirectory("Bitte einen Ordner whlen") If Laufwerk = "" Then Exit Sub
Sub a() Set xl = CreateObject("Excel.Sheet") xl.Application.Workbooks.Open Range("K1") End Sub Sub ExcelDateienffnen() With Application.FileSearch .NewSearch .LookIn = "C:\" \Belgelerim eklinde de olabilir. .SearchSubFolders = False .FileType = msoFileTypeExcelWorkbooks .Execute For i = 1 To .FoundFiles.Count Workbooks.Open .FoundFiles(i) Next i End With End Sub
lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long Sub Verzeichnisse_auflisten() Dim Pfad1, Name1, Anzahl, X, X0, X1, X2, Verz, Anzverz, Gre Dim TB1, TB2 As Worksheet Dim msg As String Set TB1 = ThisWorkbook.Worksheets(1) Set TB2 = ThisWorkbook.Worksheets(2) start = Now TB1.[a:D] = "" TB2.[a:D] = "" If ThisWorkbook.Worksheets.Count > 2 Then Application.DisplayAlerts = False For X = 3 To ThisWorkbook.Worksheets.Count ThisWorkbook.Worksheets(3).Delete Next X Application.DisplayAlerts = True End If msg = "Whlen Sie bitte einen Ordner aus:" Pfad1 = getdirectory(msg) If Pfad1 = "" Then Exit Sub Name1 = Dir(Pfad1, vbDirectory) TB1.[a2] = Pfad1 Anzahl = 2 TB1.[a1] = "Pfad" TB1.[b1] = "UnterVerz." TB1.[c1] = "Anz. Dateien" TB1.[d1] = "Datgre in Verz." X0 = 2 X1 = 2 Do While TB1.Cells(Rows.Count, 1).End(xlUp).Row <> TB1.Cells(Rows.Count, 2).End(xlUp).Row For X2 = X0 To X1 Pfad1 = TB1.Cells(X2, 1) If Right(Pfad1, 1) <> "\" Then Pfad1 = Pfad1 & "\" Name1 = Dir(Pfad1, vbDirectory) Verz = 0 Do While Name1 <> "" If Name1 <> "." And Name1 <> ".." Then If (GetAttr(Pfad1 & Name1) And vbDirectory) = vbDirectory Then Anzahl = Anzahl + 1 TB1.Cells(Anzahl, 1) = Pfad1 & Name1 & "\" Verz = Verz + 1 End If End If Name1 = Dir Loop TB1.Cells(X2, 2) = Verz Next X2 X0 = X1 + 1 X1 = X2 Loop Anzverz = TB1.Cells(Rows.Count, 1).End(xlUp).Row i=1 ii = 0 For Verz = 2 To Anzverz Anzahl = 0 Gre = 0 Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(TB1.Cells(Verz, 1)) Set fc = f.Files For Each f1 In fc If i = 65536 Then ii = ii + 1 ThisWorkbook.Worksheets.Add.Move After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count) ThisWorkbook.Worksheets(ii + 2).Name = "Dateien " & ii + 1 Set TB2 = ThisWorkbook.Worksheets(ii + 2) i=1
Dim cmb As CommandBar Dim cmbp As CommandBarPopup Set cmb = Application.CommandBars. _ Add(Name:="MeineLeiste", _ Position:=msoBarTop, _ Temporary:=True) Set cmbp = cmb.Controls.Add(Type:=msoControlPopup) cmb.Visible = True cmbp.Caption = "Mein Submen" With cmbp.Controls.Add(Type:=msoControlButton, _ Temporary:=True) .Caption = "Meine 1. Prozedur" .BeginGroup = True .FaceId = 59 .OnAction = "MeineProzedur1" End With With cmbp.Controls.Add(Type:=msoControlButton, _ Temporary:=True) .Caption = "Meine 2. Prozedur" .FaceId = 49 .OnAction = "MeineProzedur2" End With Set cmb = Nothing Set cmbp = Nothing End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim cmb As CommandBar Set cmb = Application.CommandBars("MeineLeiste") cmb.Delete Set cmb = Nothing End Sub Sub MeineProzedur1() MsgBox Application.UserName End Sub Sub MeineProzedur2() MsgBox Now() End Sub Sub MenueleisteAusblenden() Application.CommandBars("Worksheet Menu Bar").Enabled = False End Sub Sub MenueleisteAusblenden() Application.CommandBars("Worksheet Menu Bar").Enabled = True End Sub
Application.CommandBars.ActiveMenuBar.Enabled = False On Error GoTo hata If foto <> False Then Image1.Picture = LoadPicture("E:\Office\WINDOWS\Resim\" & foto & ".bmp") 'BU SATIRIN ALIMASI N "C" BLMNE "Resim" adnda bir klasr a Image1.PictureSizeMode = fmPictureSizeModeStretch End If End If Next bak Exit Sub hata: Image1.Picture =loadpicture("") Aadaki kod dosyalar siler. Ancak dosya kullanmda olmamaldr. Dosya ad yerine *.xls kullanlabilir. Ancak bunu dikkatli kullann. Sub Killfile() Dim MyFile As String 'This line of code is optional On Error Resume Next 'On hitting errors, code resumes next code MyFile = "c:\folder\filename.xls" kill MyFile End Sub Sub dosyasil() On Error Resume Next RmDir "C:\pir\xp\beyza" End Sub
Function WorkbookOpen(WorkBookName As String) As Boolean WorkbookOpen = False On Error GoTo WorkBookNotOpen If Len(Application.Workbooks(WorkBookName).Name) > 0 Then WorkbookOpen = True Exit Function End If WorkBookNotOpen: End Function Sub AA() If Not WorkbookOpen("C.xls") Then Workbooks.Open "C.xls" End If End Sub Private Sub Workbook_Open() Open ThisWorkbook.Path & "\pirr.log" For Append As #1 Print #1, Application.UserName, Now Close #1 End Sub Private Sub Workbook_Open() If Weekday(Date, vbMonday) = 1 Then ThisWorkbook.Sheets.Add.Name = _ Format(Date, "dd-mm-yy") & " au " & _ Format(Date + 6, "dd-mm-yy") End If End Sub Sub dosya_ara() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.FileExists("C:\testfile.txt") If a = True Then MsgBox "Bu isimde bir dosya var" Else MsgBox "Bu isimde bir dosya yok" End If End Sub Private Sub cmdkillevet_Click() ChDrive ("D:") Kill "D:\Depo\DepoKart\" & frmdosyasil.lbldosyasiladi.Caption ChDir "D:\Depo\DepoKart" Worksheets("Giris").lstmusteri.Clear Dosya = Dir("*.*") While Dosya <> "" Worksheets("Giris").lstmusteri.AddItem Dosya Dosya = Dir Wend 'ChDir "C:\Belgelerim" End Sub Sub Auto_Open() Dim exdate As Date exdate = "11/30/2004" If Date > exdate Then MsgBox ("You have reached end of your trail period") ActiveWorkbook.Close End If MsgBox ("You have " & exdate - Date & "Days left") End Sub
IncludeSubFolder As Boolean) As Variant Dim FileList() As String, FileCount As Long CreateFileList = "" Erase FileList If FileFilter = "" Then FileFilter = "*.*" ' all files With Application.FileSearch .NewSearch .LookIn = CurDir .Filename = FileFilter .SearchSubFolders = IncludeSubFolder .FileType = msoFileTypeAllFiles If .Execute(SortBy:=msoSortByFileName, _ SortOrder:=msoSortOrderAscending) = 0 Then Exit Function ReDim FileList(.FoundFiles.Count) For FileCount = 1 To .FoundFiles.Count FileList(FileCount) = .FoundFiles(FileCount) Next FileCount .FileType = msoFileTypeExcelWorkbooks ' reset filetypes End With CreateFileList = FileList Erase FileList End Function Sub TestCreateFileList() Dim FileNamesList As Variant, i As Integer 'ChDir "C:\My Documents" FileNamesList = CreateFileList("*.*", False) Range("A:A").ClearContents For i = 1 To UBound(FileNamesList) Cells(i + 1, 1).Formula = FileNamesList(i) Next i End Sub Sub Yedek() '/_ Dismi= ActiveWorkbook.Name ActiveWorkbook.SaveCopyAs "D:\Alihan_Bordro\ " & Dismi ActiveWorkbook.Save End Sub
Kod: Sub Dateiname_Hyperlink() Dim StDateiname As String Dim Dateiform As String Dim InI As Long, TotFiles As Long Dim Suchpfad As String Dim OldStatus As Variant Suchpfad = InputBox("Yolunu deitirebilirsiniz", "Adres yolu", Application.DefaultFilePath) If Suchpfad = "" Then Exit Sub Dateiform = InputBox("Dosya uzantsn siz deitiriniz", "Uzant", "*.xls") If Dateiform = "" Then Exit Sub Application.ScreenUpdating = True OldStatus = Application.StatusBar Sheets.Add After:=Worksheets(Worksheets.Count) With Application.FileSearch .LookIn = Suchpfad .SearchSubFolders = True .Filename = Dateiform If .Execute() > 0 Then TotFiles = .FoundFiles.Count Application.StatusBar = "Total " & TotFiles & " gefunden" For InI = 1 To .FoundFiles.Count Application.StatusBar = "Datei: " & InI & " von " & TotFiles StDateiname = Mid(.FoundFiles(InI), InStrRev(.FoundFiles(InI), "\") + 1) ActiveSheet.Hyperlinks.Add Anchor:=Cells(InI, 1), _ Address:=.FoundFiles(InI), TextToDisplay:=StDateiname Cells(InI, 2) = FileLen(.FoundFiles(InI)) Cells(InI, 3) = FileDateTime(.FoundFiles(InI)) Next InI End If End With Application.StatusBar = OldStatus Application.ScreenUpdating = True End Sub Sub auto_close() sor = MsgBox("Gle gle " & Format(Now, "dd.mmmm.yy hh:mm") & Chr(10) & Chr(10) & "dosyann kaydedilmesini istiyormusunuz?", 4, "") If sor = vbYes Then ActiveWorkbook.Save ActiveWorkbook.Close Else Application.DisplayAlerts = False ActiveWorkbook.Close End If End Sub Sub gununtarihi() Dim sFileName As String sFileName = Format(Now, "dd_mm_yyyy") + ".xls" ActiveWorkbook.SaveAs sFileName End Sub Sub KayitIsmi() ActiveWorkbook.SaveAs Filename:="C:\dosya.xls" End Sub Sub kapa() MsgBox "Bu program pir dzenlemitir.", , "KAPATILIYOR" ActiveWorkbook.Close True End Sub
'Ayrca C:\aclsarsiv.txt olarak ayrca txt dosyas oluturuyor.. Private Sub Workbook_Open() Dim Counter As Long, LastOpen As String, Msg As String LastOpen = GetSetting("xxrt", "Dosya", "Opened", "") [a1] = "En son al tarihi: " & LastOpen [a2] = "Dosyay en son aan kullanc: " & Application.UserName LastOpen = Date & " " & Time SaveSetting "xxrt", "Dosya", "Opened", LastOpen Dim LastRowA As Integer Dim veri1 As String Dim veri2 As String Dim i As Integer Open "C:\aclsarsiv.txt" For Output As #1 LastRowA = Cells(65536, 1).End(xlUp).Row For i = 1 To LastRowA veri1 = Cells(i, 1).Text veri2 = Cells(i, 2).Text Print #1, veri1; " "; veri2; Next i Close #1 'C Klasrnde txt hazrlad 'enson aan kiinin yazl bulunduuSayfa1 a1 ve a2 deki verileri siler.. 'eer Sayfa1'de silmesini istemezseniz aadakileri silin. Sheets("Sayfa1").Select Range("A1:A2").Select Selection.ClearContents Range("A1").Select End Sub 'Mesaj olarakta [a1] = "En son al tarihi: " & LastOpen [a2] = "Dosyay en son aan kullanc: " & Application.UserName 'Kodlarnn altna bunlar yazn. MsgBox "En son al tarihi: " & LastOpen MsgBox "Dosyay en son aan kullanc: " & Application.UserName ThisWorkbook'a Private Sub Workbook_Open() Dim Counter As Long, LastOpen As String, Msg As String LastOpen = GetSetting("xxrt", "Dosya", "Opened", "") [a1] = "En son al tarihi: " & LastOpen [a2] = "Dosyay en son aan kullanc: " & Application.UserName MsgBox "En son al tarihi: " & LastOpen MsgBox "Dosyay en son aan kullanc: " & Application.UserName LastOpen = Date & " " & Time SaveSetting "xxrt", "Dosya", "Opened", LastOpen Dim LastRowA As Integer Dim veri1 As String Dim veri2 As String Dim i As Integer Open "C:\aclsarsiv.txt" For Output As #1 LastRowA = Cells(65536, 1).End(xlUp).Row For i = 1 To LastRowA veri1 = Cells(i, 1).Text veri2 = Cells(i, 2).Text Print #1, veri1; " "; veri2; Next i Close #1 'C Klasrnde txt hazrlad 'enson aan kiinin yazl bulunduuSayfa1 a1 ve a2 deki verileri siler.. 'eer Sayfa1'de silmesini istemezseniz aadakileri silin. Sheets("Sayfa1").Select Range("A1:A2").Select Selection.ClearContents Range("A1").Select End Sub
Private Sub Workbook_BeforeSave _ (ByVal SaveAsUI As Boolean, Cancel As Boolean) sifre = InputBox("i Maa cmali olduundan Kayt iin ifre Girmelisiniz.", _ "Yetkili Kii", "Kaydetmek in ifre girin") If sifre = "123456" Then'rnek ifre olarak 123456 MsgBox "Kayt ilemi tamamland", vbInformation, _ "KAYIT BAARILI" Else MsgBox "Yanl ifre girdiniz." & Chr(13) & _ "Dosya kaydedilemedi", vbCritical, "HATALI FRE" Cancel = True End If End Sub Sub kapatkaydetme() ActiveWindow.Close SaveChanges:=False End Sub Option Explicit Sub DateAsFilename() Dim sFileName As String sFileName = Format(Now, "dd.mm.yyyy") + ".xls" ' tarih formatn deitirebilirsiniz (ddmmyy) gibi ActiveWorkbook.SaveAs sFileName End Sub .Ayrca C:\aclsarsiv.txt olarak ayrca txt dosyas oluturuyor.. Kod: Private Sub Workbook_Open() Dim Counter As Long, LastOpen As String, Msg As String LastOpen = GetSetting("xxrt", "Dosya", "Opened", "") [a1] = "En son al tarihi: " & LastOpen [a2] = "Dosyay en son aan kullanc: " & Application.UserName LastOpen = Date & " " & Time SaveSetting "xxrt", "Dosya", "Opened", LastOpen Dim LastRowA As Integer Dim veri1 As String Dim veri2 As String Dim i As Integer Open "C:\aclsarsiv.txt" For Output As #1 LastRowA = Cells(65536, 1).End(xlUp).Row For i = 1 To LastRowA veri1 = Cells(i, 1).Text veri2 = Cells(i, 2).Text Print #1, veri1; " "; veri2; Next i Close #1 'C Klasrnde txt hazrlad 'enson aan kiinin yazl bulunduuSayfa1 a1 ve a2 deki verileri siler.. 'eer Sayfa1'de silmesini istemezseniz aadakileri silin. Sheets("Sayfa1").Select Range("A1:A2").Select Selection.ClearContents Range("A1").Select End Sub
Mesaj olarakta Kod: [a1] = "En son al tarihi: " & LastOpen [a2] = "Dosyay en son aan kullanc: " & Application.UserName Kodlarnn altna bunlar yazn.Kod: MsgBox "En son al tarihi: " & LastOpen MsgBox "Dosyay en son aan kullanc: " & Application.UserName
C1, C2, C3 veC4'e X deerlerini 'D1, D2,D3 ve D4'e Y deerlerini 'E1, E2, E3 ve E4'e Z deerlerini girin. Sub xyz() Dim i As Integer Dim j As Integer Dim k As Integer Dim satir As Integer satir = 1 For k = 1 To 4 For j = 1 To 4 For i = 1 To 4 Cells(satir, 1) = Cells(k, 3) & Cells(j, 4) & Cells(i, 5) satir = satir + 1 Next i Next j Next k End Sub Sub TableauAnTrimestre() For An = 1 To 5 Cells(1, An + 1).Value = 2000 + An Next An For Trimestre = 1 To 4 Cells(Trimestre + 1, 1).Value = "Trim" & Trimestre Next Trimestre End Sub =yuvarla(C1;2) F1 satrna bunu yazp 1000. satra kadar kopyalar Sub Doldur() Dim i As Integer [F1].FormulaR1C1 = "=ROUND(RC[-3],2)" For i = 2 To 1000 Cells(i, 6).Select Selection.FillDown Next i End Sub Sub if_then_anweisung() For r = 1 To 15 If r = 10 Then MsgBox "Zahl = 10" If r = 15 Then MsgBox "Schleifenende" Next r End Sub Sub JourSemaine() Dim semaine(1 To 7) As String semaine(1) = "Lundi" semaine(2) = "Mardi" semaine(3) = "Mercredi" semaine(4) = "Jeudi" semaine(5) = "Vendredi" semaine(6) = "Samedi" semaine(7) = "Dimanche" For i = 1 To 7 Selection.Offset(i - 1, 0).Formula = semaine(i) Next i End Sub
Sub sil() Dim i As Integer For i = 1 To Sheets.Count If Worksheets(i).Name <> "Rapor" Then Worksheets(i).Cells.Delete Selection.Style = "Normal" 'hcreyi reset eder yani ilk altaki haline evirir End If Next i End Sub For j = 1 To Shapes.Count Shapes(j).Delete Next j End Sub Sub sili() Dim wks As Worksheets For Each wks In Worksheets wks.Pictures.Delete Next wks End Sub a = Mid(Date, 3, 1) DTPicker1.Value = Format(Date, "dd" + a + "mm" + a + "yyyy") Private Sub DTPicker1_Change() [B3] = DTPicker1.Value End Sub Date = gunkontrol.Fields("tarih") a = Mid(Date, 3, 1) DTPicker1.Value = Format(Date, "dd" + a + "mm" + a + "yyyy") ancak bu kod yazldnda bilgisayarn sistem tarihi de database den galen tarih olarak deiiyor. bunu nlemek ii yle bir kontrol uygulayabiliriz: sondate = Date Date = gunkontrol.Fields("tarih") a = Mid(Date, 3, 1) DTPicker1.Value = Format(Date, "dd" + a + "mm" + a + "yyyy") Date = sondate Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _ ByVal Target As Excel.Range) Application.StatusBar = Sh.Name & ":" & Target.Address End Sub Thisworkbook'a Application.StatusBar = Application.UserName & "-" & _ ThisWorkbook.Path & "-" & Sh.Name & ":" & Target.Address Application.Caption = ThisWorkbook.Path & "-" & Sh.Name ActiveWindow.Caption = Target.Address End Sub Function StatusLED(Msg As String, Pct As Single) Dim PctDone As Integer Dim NumReps As Integer With Application PctDone = .Round(Pct, 2) * 100 NumReps = Int(PctDone / 5) .StatusBar = Msg & .Rept(Chr(14), NumReps) & _ .Rept("**", 20 - NumReps) & " " & PctDone & "%" End With End Function Sub Display() Dim i%, y% Application.DisplayStatusBar = True For i = 1 To 10 StatusLED "Processed so far: ", i / 10 Application.Wait Now + TimeSerial(0, 0, 2) Next i Application.StatusBar = False End Sub
Declare Function GetAsyncKeyState Lib "User32" _ (ByVal vKey As Integer) As Integer 'GetAsyncKeyState est asynchrone - La touche est mmorise Sub testToucheA() For y = 1 To 10000 Application.StatusBar = y Next If (GetAsyncKeyState(65) <> 0) Then MsgBox "Touche A frappe." End If End Sub Sub tridoublon() Worksheets("Feuil1").Range("A1").Sort _ key1:=Worksheets("Feuil1").Range("A2"), _ Order1:=xlAscending, Header:=xlGuess Set MaCell = Worksheets("Feuil1").Range("A1") Do While Not IsEmpty(MaCell) Set MaCellSuite = MaCell.Offset(1, 0) If MaCellSuite.Value = MaCell.Value Then MaCell.EntireRow.Delete End If Set MaCell = MaCellSuite Loop End Sub Sub duseyara() Set s1 = Sheets("ALI FYATLARI") Set s2 = Sheets("SATI TABLOSU") son = s1.Cells(65536, 2).End(xlUp).Row son1 = s2.Cells(65536, 2).End(xlUp).Row alan = "a5:d" & son For i = 5 To son If s2.Cells(i, 5) = "" Then s2.Cells(i, 5) = Application.WorksheetFunction.VLookup(s2.Cells(i, 1), s1.Range(alan), 4, 0) End If Next End Sub Sub Dialog_47() Application.Dialogs(xlDialogOptionsEdit).Show End Sub [A1].Value = Application.Sum([E1:E15]) Sub GetSum() [A1].Value = Application.Sum([E1:E15]) End Sub Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub Rotieren() Dim C As Range Dim i% Set C = Range("E10") For i = 1 To 2000 C = Right(C, Len(C.Value) - 1) + Left(C, 1) Sleep 200 Next i End Sub Sub Dme1_Tklat() x = Cells(65536, 3).End(xlUp).Row Range("E2").AutoFill Destination:=Range("E2:E" & x) Application.Calculate End Sub Private Sub CommandButton1_Click() For Each yes In Range("P:P") If yes = "evet" Then ListBox1.AddItem yes.Offset(0, -12) End If Next End Sub
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Value = 1 Then Dim sayfa As Worksheet Dim nek As String Dim sonek As Integer Set Sayfam = Worksheets.Add nek = "Sayfam" SonEkim = 1 On Error Resume Next Sayfam.Name = nek & sonek If Err.Number <> 0 Then nek = sonek + 1 Sayfam.Name = nek & sonek End If End If End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$A$1" Then If Target.Value = "1" Then MsgBox "ExcelPazar" End If End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Range("A1") >= 1 Then MsgBox "Akndan Selamlar" End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target = Cells(1, 1) Then Cells(2, 1) = Now End Sub 'alternatif MD() or Bugn or Time Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$A$1" Or Target.Address = "$A$3" Then If Range("A1").Value < Range("A3").Value Then Macro1 End If End If End Sub Sub Macro1() MsgBox "Selam" End Sub Sub InserLSiRupture() Set x = ActiveCell Do Until IsEmpty(x) If x.Row > 1 Then If x.Offset(-1, 0).Value <> x.Value Then Rows(x.Row).Insert Shift:=xlDown End If End If Set x = x.Offset(1, 0) Loop End Sub Sub Action() If IsNumeric(ActiveCell) Then ActiveCell.Font.Bold = ActiveCell.Value >= 500 End If End Sub Sub SelCurRegCopy() Selection.CurrentRegion.Select Selection.Copy Range("A17").Select ' Substitute your range here ActiveSheet.Paste Application.CutCopyMode = False End Sub 12 adet eer formln araya + ilecini koyarak 2 ye blmektir. Forml B1 hcresine yazlm ve A1 hcresindeki veriyi kontrol etmektedir.
=EER(A1="OCAK";OCAK!A1;EER(A1="UBAT";UBAT!A1;EER(A1="MART";MART!A1;EER(A1="NSAN";NSAN!A1;EER(A1="MAYIS";MAYIS!A1;EE
Sub Klasor_Sil() If Dir("c:\Yedek\*") <> "" Then Kill "c:\Yedek\*" Dir "C:\" RmDir "C:\Yedek\" Else MkDir "c:\Yedek" End If End Sub Sub Klasor_Sil() On Error Resume Next If Dir("C:\Yedek\*") <> "" Then Kill "C:\Yedek\*" Else MkDir "C:\Yedek" End If On Error GoTo 0 End Datum_in_Fusszeile() Sub Sub Dim SeitenNummer%, X% Dim Zaehler As Boolean Zaehler = True X = ExecuteExcel4Macro("get.document(50)") For SeitenNummer = 1 To X If Zaehler = True Then With ActiveSheet.PageSetup .RightFooter = "&D" .LeftFooter = "" End With End If If Zaehler = False Then With ActiveSheet.PageSetup .RightFooter = "" .LeftFooter = "&D" End With End If ActiveWindow.SelectedSheets.PrintOut _ From:=SeitenNummer, To:=SeitenNummer, Copies:=1 Zaehler = Not Zaehler Next SeitenNummer End Sub Sub SelectFirstToLastInColumn() Set TopCell = Cells(1, ActiveCell.Column) Set BottomCell = Cells(16384, ActiveCell.Column) If IsEmpty(TopCell) Then Set TopCell = TopCell.End(xlDown) If IsEmpty(BottomCell) Then Set BottomCell = BottomCell.End(xlUp) If TopCell.Row = 16384 And BottomCell.Row = 1 Then ActiveCell.Select Else Range(TopCell, BottomCell).Select End Sub Sub SelectFirstToLastInRow() Set LeftCell = Cells(ActiveCell.Row, 1) Set RightCell = Cells(ActiveCell.Row, 256) If IsEmpty(LeftCell) Then Set LeftCell = LeftCell.End(xlToRight) If IsEmpty(RightCell) Then Set RightCell = RightCell.End(xlToLeft) If LeftCell.Column = 256 And RightCell.Column = 1 Then ActiveCell.Select Else Range(LeftCell, RightCell).Select End Sub Sub ExcelEger() [B1] = "=IF(A1>=50,""Snf Geer"",""Snfta Kalr"")" End Sub Sub VBAEger() If [A1] >= 50 Then [B1] = "Snf Geer" Else [B1] = "Snfta Kalr" End If End Sub
Bu tr hata mesajlarnn hepsinde ayn yntemi uygulamak mmkndr. Unutulmamaldr ki, hata mesaj olan hcrede bir forml bulunmaktadr. 'Farzede =DEYARA(B1;C1:D11;2;0)
'Deyara ile aranlan veri bulunamadnda hcrede #YOK hata deeri olacaktr. Dolays ile bu da o hcrenin ierisinde bulunduu bir toplama 'dizisini h =EER(EHATALIYSA(DEYARA(B1;C1:D11;2;0));"";DEYARA(B1;C1:D11;2;0)) 'Yaptmz tek ey normal olarak bildiimiz EER forml ile birlikte EHATALIYSA formln kullanmaktr. Formln anlalmas iin aadaki 'aklamay =EER(HATALIYSA(forml);"";forml)) '"Eer forml hatal sonu veriyorsa hcreyi bo brak, deil ise forml sonucunu yazdr." Sub Eklenti() Dim i As Integer Dim Eklenti Cells(1, Cells(1, Cells(1, Cells(1, Cells(1, 1).Value = "Eklenti Ad" 2).Value = "Eklenti Yolu" 3).Value = "Eklenti Boyutu" 4).Value = "Eklentiyi Oluturma Tarihi" 5).Value = "Dosya Tipi"
Set Eklenti = CreateObject("Scripting.FileSystemObject") For i = 1 To Application.AddIns.Count Cells(i + 1, 1).Value = Application.AddIns(i).Name 'ad Cells(i + 1, 2).Value = Application.AddIns(i).Path 'Dosya Yolu Cells(i + 1, 3).Value = Int(Eklenti.GetFile(Application.AddIns(i).FullName).Size / 1024) & " Kb" Cells(i + 1, 4).Value = Eklenti.GetFile(Application.AddIns(i).FullName).DateCreated Cells(i + 1, 5).Value = Eklenti.GetFile(Application.AddIns(i).FullName).Type If Application.AddIns(i).Installed = False Then Cells(i + 1, 6).Value = "Aktif Deil" Else Cells(i + 1, 6).Value = "Aktif" End If Next i Columns("A:F").EntireColumn.AutoFit End Sub Sub Dialog_38() Application.Dialogs(xlDialogInsert).Show End Sub Sub Dialog_03() Application.Dialogs(xlDialogAddinManager).Show End Sub Sub afficheComplement() For Each a In AddIns MsgBox a.FullName Next a End Sub Sub testUtilitAnalyse() If AddIns("Query manager").Installed = True Then MsgBox "Utilitaire d'analyse install" Else MsgBox "Utilitaire d'analyse non install" End If End Sub
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long Const Const Const Const CCDEVICENAME = 32 CCFORMNAME = 32 DM_PELSWIDTH = &H80000 DM_PELSHEIGHT = &H100000
Type DEVMODE dmDeviceName As String * CCDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type Dim DevM As DEVMODE Private Sub ChangeScreenResolution(iWidth As Single, iHeight As Single) Dim a As Boolean Dim i& Dim b& i=0 Do a = EnumDisplaySettings(0&, i&, DevM) i=i+1 Loop Until (a = False) DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT DevM.dmPelsWidth = iWidth DevM.dmPelsHeight = iHeight b = ChangeDisplaySettings(DevM, 0) End Sub Sub ChangeTo1024_768() Call ChangeScreenResolution(1024, 768) 'buradaki deerleri deitirerek ayarlayabilirsiniz. End Sub
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long Const Const Const Const CCDEVICENAME = 32 CCFORMNAME = 32 DM_PELSWIDTH = &H80000 DM_PELSHEIGHT = &H100000
Type DEVMODE dmDeviceName As String * CCDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type Dim DevM As DEVMODE Private Sub ChangeScreenResolution(iWidth As Single, iHeight As Single) Dim a As Boolean Dim i& Dim b& i=0 Do a = EnumDisplaySettings(0&, i&, DevM) i=i+1 Loop Until (a = False) DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT DevM.dmPelsWidth = iWidth DevM.dmPelsHeight = iHeight b = ChangeDisplaySettings(DevM, 0) End Sub Sub ChangeTo1024_768() Call ChangeScreenResolution(1024, 768) End Sub
Declare Function GetClipCursor Lib "user32" (lprc As RECT) As Long Type RECT gauche As Long haut As Long droit As Long bas As Long End Type Dim oGCC As RECT Sub auto_open() GetClipCursor oGCC With oGCC [a1] = .droit & " x " & .bas If [a1] <> "1024 x 768" Then MsgBox "zgnm ekran znrlnz 1024 x 768 olmas gerekiyor aksi taktirde bu program kullanmazsnz" Application.DisplayAlerts = False ActiveWorkbook.Close End If End With End SubFunction GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long Declare Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long Const HORZRES = 8 Const VERTRES = 10 Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Const SM_CYSCREEN As Long = 1 Const SM_CXSCREEN As Long = 0 Sub GetScreenDimensions() Dim lWidth As Long Dim lHeight As Long lWidth = GetSystemMetrics(SM_CXSCREEN) lHeight = GetSystemMetrics(SM_CYSCREEN) MsgBox "Screen Width = " & lWidth & vbCrLf & "Screen Height = " & lHeight End Sub Function ScreenResolution() Dim lRval As Long Dim lDc As Long Dim lHSize As Long Dim lVSize As Long lDc = GetDC(0&) lHSize = GetDeviceCaps(lDc, HORZRES) lVSize = GetDeviceCaps(lDc, VERTRES) lRval = ReleaseDC(0, lDc) ScreenResolution = lHSize & "x" & lVSize End Function Sub GetScreenSize() Debug.Print ScreenResolution() End Sub
Call GetScreenSize End Sub Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _ ByVal nIndex As Long) As Long Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _ ByVal hdc As Long) As Long Const HORZRES = 8 Const VERTRES = 10 Function ScreenResolution() Dim lRval As Long Dim lDc As Long Dim lHSize As Long Dim lVSize As Long lDc = GetDC(0&) lHSize = GetDeviceCaps(lDc, HORZRES) lVSize = GetDeviceCaps(lDc, VERTRES) lRval = ReleaseDC(0, lDc) ScreenResolution = lHSize & "x" & lVSize End Function Sub GetScreenSize() Dim aufl As String aufl = ScreenResolution() If aufl = "800x600" Then ActiveWindow.Zoom = 75 End If If aufl = "1024x768" Then ActiveWindow.Zoom = 125 End If End Sub Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _ ByVal nIndex As Long) As Long Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, _ ByVal hdc As Long) As Long Sub RsolutionEcran() Dim Pix As Long Pix = GetDC(0) MsgBox "La rsolution est : " & GetDeviceCaps(Pix, 8) _ & " * " & GetDeviceCaps(Pix, 10) & " pixels" ReleaseDC 0, Pix End Sub
With Application .ScreenUpdating = False .CommandBars("toolbar list").Enabled = True .CommandBars("Worksheet Menu Bar").Enabled = True .CommandBars("Cell").Enabled = True .DisplayFormulaBar = False .DisplayStatusBar = False .DisplayFullScreen = False End With With ActiveWindow .DisplayHorizontalScrollBar = True .DisplayVerticalScrollBar = True .DisplayWorkbookTabs = True .DisplayHeadings = True .WindowState = xlMaximized End With End Sub Sub Menueleiste_aus() With Application .ScreenUpdating = False .CommandBars("toolbar list").Enabled = False .CommandBars("Worksheet Menu Bar").Enabled = False .CommandBars("Cell").Enabled = False .DisplayFormulaBar = True .DisplayStatusBar = True .DisplayFullScreen = True End With With ActiveWindow .DisplayHorizontalScrollBar = False .DisplayVerticalScrollBar = False .DisplayWorkbookTabs = False .DisplayHeadings = False .WindowState = xlMaximized End With End Sub Formun zerine bir adet CommandButton ekleyin. Private Declare Function CreateEllipticRgn Lib "gdi32" ( _ ByVal X1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function SetWindowRgn Lib "user32" ( _ ByVal hWnd As Long, ByVal hRgn As Long, _ ByVal bRedraw As Boolean) As Long Private Declare Function FindWindowA Lib "user32" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Sub CommandButton1_Click() Unload Me End Sub Private Sub UserForm_Initialize() Dim FormhWnd, EliptikHandle As Long FormhWnd = FindWindowA(vbNullString, Me.Caption) EliptikHandle = CreateEllipticRgn( _ 0, 70, UserForm1.Width * 1, UserForm1.Height * 1.2) Call SetWindowRgn(FormhWnd, EliptikHandle, True) End Sub Sub ayikla() For x = 1 To [a65536].End(3).Row d = Split(Cells(x, 1)) For Each elem In d If InStr(elem, "@") Then a=a+1 Sheets("sayfa2").Cells(a, 1) = Trim(Replace(Replace(Replace(elem, ",", ""), "e-mail:", ""), Chr(160), "")) End If Next elem Next x Sheets("sayfa2").Select End Sub
Sub ayikla() For x = 1 To [a65536].End(3).Row d = Split(Cells(x, 1)) For Each elem In d If InStr(elem, "@") Then a=a+1 Sheets("sayfa2").Cells(a, 1) = Trim(Replace(Replace(Replace(elem, ",", ""), "e-mail:", ""), Chr(160), "")) End If Next elem Next x Sheets("sayfa2").Select End Sub Sub Email() ActiveWorkbook.SendMail Recipients:="pir@yahoo.com" End Sub Sub HyperlinkMitEmailEinfuegen() Range("A1").Select ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= "mailto:machero@aol.com" End Sub Sub HyperlinkAktivieren() Range("A1").Select Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True End Sub Tm sayfadaki en son hcreyi isterseniz aadaki kodu deneyin. Sub ensonagit() Sheets("sayfa2").Select Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 0).Select End Sub Sub test_A() Colonne = Left$(ActiveCell.Address(0, 0), (ActiveCell.Column < 27) + 2) If Colonne = "A" Then MsgBox "Je lance la macro ici" Else MsgBox Colonne End If End Sub Sub LetzteZelle() Rows.SpecialCells(xlCellTypeLastCell).Rows.Activate End Sub Function pir(Mahmut) For I = 0 To Len(Mahmut) - 1 Verkehrt = Verkehrt & Mid(Mahmut, _ Len(Mahmut) - I, 1) Next I pir = Right(Mahmut, InStr(1, _ Verkehrt, " ", 0)) End Function Sub DeleteEmptyRows() LastRow = ActiveSheet.UsedRange.Row - 1 + _ ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Sub AnzahlVerwendeteZeilen() i = ActiveSheet.UsedRange.Rows.Count MsgBox i End Sub Sub LastRow() MsgBox Cells.Find("*", searchdirection:=xlPrevious).Row End Sub
alma Sayfasndaki en son dolu hcreden stteki bo hcreleri siler Sub DeleteEmptyRows() LastRow = ActiveSheet.UsedRange.Row - 1 + _ ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub SATIR BOLUKLARINI DOLDURUR(sayfada) Private Sub CommandButton8_Click() LastRow = ActiveSheet.UsedRange.Row - 1 + _ ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Soruyu sorduktan sonra tesadfen Sayn Raider'in daha nce yazm olduu aadaki kodu buldum ve iimi grd. Kod: Private Sub Worksheet_Activate() Cells(65536, 2).End(xlUp).Select End Sub Private Sub Workbook_Open() MsgBox ActiveWorkbook.BuiltinDocumentProperties(12).Name & ActiveWorkbook.BuiltinDocumentProperties(12) End Sub Sub der() Range("A1").Select If Cells(ActiveCell.Row + 1, ActiveCell.Column).Value <> "" Then ActiveCell.End(xlDown).Select End If End Sub Sub ResetEnterReturn() Application.OnKey "{ENTER}" Application.OnKey "~" End Sub Sub Auto_Close() Application.MoveAfterReturn = True End Sub Private Sub Worksheet_Activate() Application.OnKey "{ENTER}", "Macro1" Application.OnKey "~", "Macro1" End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Row > 4 Then Cells(1, Target.Column + 1).Activate End Sub Private Function RangeNameExists(nname) As Boolean ' Erim ad varsa DORU dndrr Dim n As Name RangeNameExists = False For Each n In ActiveWorkbook.Names If UCase(n.Name) = UCase(nname) Then RangeNameExists = True Exit Function End If Next n End Function Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 27 Then Unload Me End Sub ESC tuuyla Userformunuzu kapatabilirsiniz Kod: Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 27 Then Unload Me End Sub
Sub formulyenile() Application.ScreenUpdating = False Range("e2").Select Range("e2").Formula = "=ROUND(AVERAGE(RC[-4]:RC[-1]),0)" Range("e2").Select Selection.AutoFill Destination:=Range("e2:e50"), Type:=xlFillDefault Range("e2:e50").Select Selection.AutoFill Destination:=Range("e2:e50"), Type:=xlFillDefault Range("e2").Select Application.ScreenUpdating = True End Sub Sub a() For i = 1 To 100 If Cells(i, 1) <> Cells(i, 3) Then Cells(i, 3).EntireRow.Delete End If Next End Sub Sub Dialog_40() Application.Dialogs(xlDialogInsertNameLabel).Show End Sub ActiveSheet.StandartWidth=25 - ->Etkin ilem sayfasnn geniliini 25 yapar. Sub Dialog_01() Application.Dialogs(xlDialogActivate).Show End Sub UserForm'a CommandButton1 nesnesini ilave ederseniz; Kod: Private Sub ComboBox1_Change() [AA1] = ComboBox1.Text End Sub Private Sub CommandButton1_Click() MsgBox Format(Evaluate("SUMIF(C8:C1000,AA1,E8:E1000)"), "###,###") End Sub TextBox2' e girdiin tarih de dikkate alnsn istiyorsan; Kod: Private Sub ComboBox1_Change() On Error Resume Next [AA1] = ComboBox1.Text [AA2] = CDate(TextBox2.Text) + 0 End Sub ' Private Sub TextBox2_Change() On Error Resume Next [AA1] = ComboBox1.Text [AA2] = CDate(TextBox2.Text) + 0 End Sub ' Private Sub CommandButton1_Click() MsgBox Format(Evaluate("SUMPRODUCT((B8:B998=AA2)*(C8:C998=AA1)*(E8:E998))"), "###,###") End Sub Sub mesaj() YesNo = MsgBox("Bu makroyu altrmak istiyor musunuz?", vbYesNo + vbCritical, "Soru Bal") Select Case YesNo Case vbYes MsgBox "Makro altrld.", vbMsgBoxRtlReading Case vbNo MsgBox "Makroyu iptal ettiniz.", vbMsgBoxSetForeground End Select End Sub
1.cisi activ sayfada active hucre en son veri girdiiniz hucre ise Kod: Sub Cozum1() Dim i As Integer Set Sliste = Worksheets("liste") For i = 2 To 30000 If Sliste.Range("A" & i).Value = Empty Then Sliste.Range("A" & i).Value = ActiveCell.Value Sliste.Range("B" & i).Value = ActiveCell.Offset(0, 1).Value Exit Sub End If Next i End Sub 2.cisi ise Activ sayfada activ hucra neresi olursa olsun.en son veri girii yaptnz hucredeki veriyi liste sayfasna aktarr. Kod: Sub Cozum2() Dim iliste, satir As Integer Dim hucre As Range Set Sliste = Worksheets("liste") For iliste = 2 To WorksheetFunction.CountA(Range("A1:A65000")) For Each hucre In Range("A1:A65000").Cells If hucre.Value = Empty Then satir = hucre.Row - 1 GoTo cik End If Next hucre cik: If Sliste.Range("A" & iliste).Value = Empty Then Sliste.Range("A" & iliste).Value = ActiveSheet.Cells(satir, 1).Value Sliste.Range("B" & iliste).Value = ActiveSheet.Cells(satir, 2).Value Exit Sub End If Next iliste End Sub Burada listeniz a ve b surunlarnda olduunu ve devaml ekilde liste sayfasna aktaracanz hesap ederek yaplmtr Sub Killfile() Dim MyFile As String 'This line of code is optional On Error Resume Next 'On hitting errors, code resumes next code MyFile = "c:\Yeni.xls" Kill MyFile End Sub
Open "c:/uluda/no" For Random As #4 Dim s As Integer Dim h As String Get 4, 1, s u=2 For i = 2 To s Get 4, i, h Dim kitap As Excel.Application Set kitap = CreateObject("Excel.Application") kitap.Workbooks.Open ("c:\uluda\" & h & ".xls") kitap.Visible = False Sheets(1).Cells(u, 2).Value = kitap.Sheets(9).Cells(2, 2).Value Sheets(1).Cells(u, 3).Value = kitap.Sheets(9).Cells(2, 3).Value For w = 1 To 9 If kitap.Sheets(9).Cells(w + 1, 4) = "" Then u = u + w: GoTo 10 Sheets(1).Cells(u + w - 1, 1).Value = kitap.Sheets(9).Cells(2, 1).Value Sheets(1).Cells(u Sheets(1).Cells(u Sheets(1).Cells(u Sheets(1).Cells(u Sheets(1).Cells(u Sheets(1).Cells(u Sheets(1).Cells(u Next w + + + + + + + w w w w w w w 1, 1, 1, 1, 1, 1, 1, 4).Value = kitap.Sheets(9).Cells(w + 1, 4) 5).Value = kitap.Sheets(9).Cells(w + 1, 5) 6).Value = kitap.Sheets(9).Cells(w + 1, 6) 7).Value = kitap.Sheets(9).Cells(w + 1, 7) 8).Value = kitap.Sheets(9).Cells(w + 1, 8) 9).Value = kitap.Sheets(9).Cells(w + 1, 9) 10).Value = kitap.Sheets(9).Cells(w + 1, 10)
xlCrack End Sub Private Function xlCrack() Dim wkb As Workbook Dim wks As Worksheet Dim txt As String Application.ScreenUpdating = False Set wkb = ActiveWorkbook Set wks = ActiveWorkbook.ActiveSheet txt = Application.Version If Left(txt, 1) <> 8 And Left(txt, 1) <> 9 Then Beep MsgBox "Das AddIn ist nur unter XL8 und XL9 lauffhig!" Exit Function End If Call wkbEncode(wkb) For Each wks In Worksheets If wks.ProtectContents Then Call wksEncode(wks) Next wks MsgBox prompt:="Der Job wurde nach langer, harter Arbeit erledigt!", _ Title:="Fertig" Application.ScreenUpdating = True End Function Private Function wksEncode(wks As Worksheet) On Error Resume Next With wks .Protect vbNullString, , , , True .Range("IV65536").Copy .Range("IV65536") .Unprotect vbNullString End With End Function Private Function wkbEncode(wkb As Workbook) On Error Resume Next With wkb .Protect vbNullString, True, True .Unprotect vbNullString End With End Function Sub Kareler() Dim i As Byte For i = 1 To WorksheetFunction.CountA(Range("A:A")) ActiveSheet.Shapes.AddShape(msoShapeRectangle, 100, Cells(i, 1).Value, Cells(i, 1).Value, Cells(i, 1).Value).Select Selection.Name = Cells(i, 1).Value & " Nolu Kare " Next i End Sub Sub Dme1_Tklat() [D1:E2].Copy sat = WorksheetFunction.CountA([A1:A65536]) + 1 Cells(sat, "a").PasteSpecial Application.CutCopyMode = False Range("A1:A100").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _ xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("B1:B100").Select Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("A1").Select End Sub
Sub ilem() For x = 1 To 100 Cells(x, 3) = Cells(x, 1) * 1 * Cells(x, 2) Next End Sub Sub bala() For x = 1 To Sheets.Count Sheets(x).Select Application.Run "ilem" Next End Sub Sub TRIMLE_BOSLUK_AL() Selection.CurrentRegion.Select Set xxx = Selection For Each x In xxx x.Activate ActiveCell.Value = Application.WorksheetFunction.Clean(ActiveCell.Value) ActiveCell.Value = Application.WorksheetFunction.TRIM(ActiveCell.Value) Next x Selection.CurrentRegion.Select With Selection .WrapText = False End With Range("A1").Select
End Sub kodlar excel sayfasnda bi commandbutton oluturup o butona atama ilemini yapyoruz. commandbutona tkladmzda yanp snme ilemi c1 Aadaki Sub YANIPSON() Dim durum As Boolean, i As Single Do While (True) If durum=True Then Range("C1").Select With Selection.Interior .ColorIndex=3 .Pattern=xlSolid End With For i =0 To 2500 DoEvents Next durum=False Else Range("C1").Select Selection.Interior.ColorIndex=xlNone For i=0 To 2500 DoEvents Next durum=True End If Loop End Sub Sub auto_open() Application.ScreenUpdating = False For i = 1 To Application.CommandBars.Count Application.CommandBars(i).Enabled = False Next i Application.ScreenUpdating = True End Sub '******************** Sub auto_close() Application.ScreenUpdating = False For i = 1 To Application.CommandBars.Count Application.CommandBars(i).Enabled = 1 Next i Application.ScreenUpdating = True End Sub
Neden Api aryorsunuz anlayamadm. Bu ilem windows script ile kolayca yaplabilir. rnein aadaki kod aktif dosyann masa stnde ksayolunu olutu visual basic kodu: Sub Desktopkisayol() Set kisayol = CreateObject("WScript.Shell") yol = kisayol.SpecialFolders("Desktop") Set deg = kisayol.CreateShortcut(yol & "\" & ActiveWorkbook.Name & ".lnk") With deg .TargetPath = ActiveWorkbook.FullName .Save End With Set kisayol = Nothing MsgBox "Ksayol oluturuldu" End Sub Sub Dirxls() Shell "command.com /c dir c:\*.xls /W/O/S >C:\ajeter\dirxls.xls", vbHide End Sub Sub Dirxls2() Shell "command.com /c dir c:\*.xls /s/b >C:\ajeter\dirxls.xls", vbHide End Sub Sub Auto_Close() Dim f As String, r As Integer f = ThisWorkbook.Sheets(1).Cells(1, 1).Value If f = "" Then f = Application.GetSaveAsFilename(fileFilter:="Excel Workbook(*.xls), *.xls") If f = False Then Exit Sub End If End If r = ThisWorkbook.Sheets(1).Cells(1, 1).Characters.Count If ThisWorkbook.Sheets(1).Cells(1, 1).Characters(r - 3).Text <> ".xls" Then f = f & ".xls" End If ThisWorkbook.SaveAs Filename:=f End Sub Bu program CD-Rom ismini kontrol ediyor ve tutmuyorsa dosya amay iptal ediyor. CD-Rom a zel bir isim vermemi iseniz, CD-Rom dahi herhangi bir dosyayda kontrol ettirebilirsiniz, eer o dosya yoksa program kapanr. Sub auto_open() Dim fso, drv, cdr Set fso = CreateObject("Scripting.FileSystemObject") For Each drv In fso.Drives If drv.driveType = 4 Then Set cdr = drv Next If cdr.volumename <> "CD nin ad" Then MsgBox "Ltfen program cd sini takmadan program altrmaynz" ThisWorkbook.Close False End If End Sub Sub deplace() Name "c:\Test.xls" As "c:\aaa\Test.xls" End Sub
Private Sub Workbook_Activate() On Local Error Resume Next Application.Visible = False 'Excel Uygulamasn grnmez yap Dim d, x, y d = GetSetting("DANISMAN", "Ayarlar", "Ilk Giris", "") If d = "" Then SaveSetting "DANISMAN", "Ayarlar", "Ilk Giris", Date Else If (Date - CDate(d)) > 30 Then MsgBox ("Programin Demo Sresi dolmustur.Uzatmak Iin E-Mail adresine Not mesaj atabilirsiniz") DoCmd.Close Application.Quit Else x = GetSetting("DANISMAN", "Ayarlar", "Son ikis Tarihi", "") If x = "" Then 'End Else If CVDate(x) > Date Then MsgBox ("Programin Deneme Sresi Doldu Ltfen Israr Etmeyin") DoCmd.Close Else y = GetSetting("DANISMAN", "Ayarlar", "Son ikis Saati", "") If (CVDate(x) = Date) And (CVDate(y) > Time) Then MsgBox ("Programin Deneme Sresi Doldu Ltfen Israr Etmeyin") DoCmd.Close End If End If x = GetSetting("DANISMAN", "Ayarlar", "Sayi", "1") MsgBox ("Programi" & x & ". defa alistiriyorsunuz.") SaveSetting "DANISMAN", "Ayarlar", "Sayi", x + 1 End If End If End If siparisfrm.Show End Sub Benim k iin kullandm ;Userform kapatldnda dosyay kapatyor,bu arada ilgili dosyaya k tarihini ve saatini kaydettiriyorum. Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) SaveSetting "DANISMAN", "Ayarlar", "Son ikis Tarihi", Date 'Danman dosyasnn k tarihi SaveSetting "DANISMAN", "Ayarlar", "Son ikis Saati", Time 'Danman dosyasnn k saati Application.Visible = True 'Excel Ara yz grnr Yap Application.Quit 'Excel Uygulamasndan Komple k End Sub Sub auto_open() Static sayac As Integer Do If sayac = 3 Then ThisWorkbook.Close False Else If InputBox("ifreyi girin") = "sifre" Then GoTo devam Else sayac = sayac + 1 End If End If Loop devam: End Sub
Sub GetFonts() Dim Fonts Dim x As Integer x=1 Set Fonts = Application.CommandBars.FindControl(ID:=1728) On Error Resume Next Do Cells(x + 1, 1) = Fonts.List(x) If Err Then Exit Do x=x+1 Loop On Error GoTo 0 Range("A1").FormulaR1C1 = "=""Font List = "" & COUNTA(R[1]C:R[" & x - 1 & "]C)" With Range("A1") .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .Font.Name = "Arial" .Font.FontStyle = "Bold" .Font.Size = 10 .Font.ColorIndex = 5 .Interior.ColorIndex = 15 End With Columns("A:A").EntireColumn.AutoFit Set Fonts = Nothing End Sub
Dim FontNamesCtrl As CommandBarControl, FontCmdBar As CommandBar, tFormula As String Dim fontName As String, i As Long, fontCount As Long, fontSize As Integer fontSize = 0 fontSize = Application.InputBox("Enter Sample Font Size Between 8 And 30", _ "Select Sample Font Size", 12, , , , , 1) If fontSize = 0 Then Exit Sub If fontSize < 8 Then fontSize = 8 If fontSize > 30 Then fontSize = 30 Set FontNamesCtrl = Application.CommandBars("Formatting").FindControl(ID:=1728) ' If Font control is missing, create a temp CommandBar If FontNamesCtrl Is Nothing Then Set FontCmdBar = Application.CommandBars.Add("TempFontNamesCtrl", _ msoBarFloating, False, True) Set FontNamesCtrl = FontCmdBar.Controls.Add(ID:=1728) End If Application.ScreenUpdating = False fontCount = FontNamesCtrl.ListCount Workbooks.Add ' list font names in column A and font example in column B For i = 0 To FontNamesCtrl.ListCount - 1 fontName = FontNamesCtrl.List(i + 1) Application.StatusBar = "Listing font " & _ Format(i / (fontCount - 1), "0 %") & " " & _ fontName & "..." Cells(i + StartRow, 1).Formula = fontName With Cells(i + StartRow, 2) tFormula = "abcdefghijklmnopqrstuvwxyz" If Application.International(xlCountrySetting) = 47 Then tFormula = tFormula & "" End If tFormula = tFormula & UCase(tFormula) tFormula = tFormula & "1234567890" .Formula = tFormula .Font.Name = fontName End With Next i Application.StatusBar = False If Not FontCmdBar Is Nothing Then FontCmdBar.Delete Set FontCmdBar = Nothing Set FontNamesCtrl = Nothing ' add heading Columns(1).AutoFit With Range("A1") .Formula = "Installed fonts:" .Font.Bold = True .Font.Size = 14 End With With Range("A3") .Formula = "Font Name:" .Font.Bold = True .Font.Size = 12 End With With Range("B3") .Formula = "Font Example:" .Font.Bold = True .Font.Size = 12 End With With Range("B" & StartRow & ":B" & _ StartRow + fontCount) .Font.Size = fontSize End With With Range("A" & StartRow & ":B" & _ StartRow + fontCount) .VerticalAlignment = xlVAlignCenter End With Range("A4").Select ActiveWindow.FreezePanes = True Range("A2").Select ActiveWorkbook.Saved = True End Sub
'Aadaki OpenAnyFile isimli prosedr altrldnda; '- MyFile deikenindeki dosya bulunamazsa, kullanc ikaz edilir. '- MyFile deikenindeki dosya trn aacak bir program, bilgisayarda yoksa kullanc ikaz edilir. '- Herey yolunda gittiyse, MyFile deikenindeki dosya alr. 'VBE'de yeni bir standart modl oluturduktan sonra, aadaki kodlar modln iine yaptrn ve OpenAnyFile isimli prosedr direkt olarak veya baka b Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" ( _ ByVal lpFile As String, ByVal lpDirectory As String, _ ByVal lpResult As String) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _ ByVal hWnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Sub OpenAnyFile() Dim RetVal As Integer Dim Buff As String Dim hWnd As Long Dim MyFile As Variant MyFile = "C:\Protokol.jpg" If Dir(MyFile) = "" Then MsgBox MyFile & " dosyas bulunamad" Exit Sub End If Buff = String(260, 32) RetVal = FindExecutable(MyFile, vbNullString, Buff) If RetVal > 32 Then If Application.Version < 9 Then hWnd = FindWindow("ThunderXFrame", "") Else hWnd = FindWindow("ThunderDFrame", "") End If ShellExecute hWnd, "Open", MyFile, vbNullString, "C:\", 1 Else MsgBox Dir(MyFile) & " dosyas ile ilikili bir program _ bulunamad !", vbExclamation End If End Sub Declare Function GetActiveWindow32 Lib "USER32" _ Alias "GetActiveWindow" () As Integer Declare Function SendMessage32 Lib "USER32" _ Alias "SendMessageA" (ByVal hWnd As _ Long, ByVal wMsg As Long, ByVal wParam As Long, _ ByVal lParam As Long) As Long Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias _ "ExtractIconA" (ByVal hInst As Long, _ ByVal lpszExeFileName As String, _ ByVal nIconIndex As Long) As Long
Sub ChangeXLIcon() Dim h32NewIcon As Long Dim h32WndXLMAIN As Long h32NewIcon = ExtractIcon32(0, "Notepad.exe", 0) h32WndXLMAIN = GetActiveWindow32() SendMessage32 h32WndXLMAIN, &H80, 1, h32NewIcon 'Byk Icon SendMessage32 h32WndXLMAIN, &H80, 0, h32NewIcon 'Kk Icon End Sub VB excel balants gerekletirenlere : Tools > Protection > Protect and Shared Workbook : Protect Shared Workbook = Sharing with track changes , seenei aktif edilirse Ayn dosyaya birden ok kullanc Read Only olmadan balanabilir ve Save
xlPICT xlPicture xlPie xlPivotTable xlPlaceholders xlPlotArea xlPLT xlPlus xlPlusValues xlPolynomial xlPortrait xlPower xlPowerTalk xlPrevious xlPrimary xlPrinter xlProduct xlPublisher xlPublishers xlR1C1 xlRadar xlReadOnly xlReadWrite xlReference xlRelative xlRelRowAbsColumn xlRight xlRightBrace xlRightBracket xlRoutingComplete xlRoutingInProgress xlRowField xlRowHeader xlRowItem xlRows xlRowSeparator xlRowThenColumn xlRTF xlRunningTotal xlScale xlScreen xlScreenSize xlSecondary xlSecondCode xlSelect xlSemiautomatic xlSemiGray75 xlSendPublisher xlSeries xlShared xlShort xlShowLabel xlShowLabelAndPercent xlShowPercent xlShowValue xlSimple xlSingle xlSingleAccounting xlSingleQuote xlSolid xlSortLabels xlSortValues xlSquare xlStack xlStandardSummary xlStar xlStDev xlStDevP xlStError xlStretch xlStrict xlSubscriber xlSubscribers xlSubtract xlSum xlSYLK xlSyllabary xlTableBody xlTemplate xlText
CreateObject("Shell.Application").ToggleDesktop 'veya CreateObject("Shell.Application").MinimizeAll Sub Auto_Open() MyMenu Range("A1").Select End Sub Sub MyMenu() On Error Resume Next If Not MyControl Is Nothing Then GoTo ResumeSub: Set MyControl = CommandBars.FindControl(Type:=msoControlComboBox, Tag:="MyMenu", Visible:=True) MyControl.Delete On Error GoTo 0 Set MyBar = Application.CommandBars("standard") Set NewCombo = MyBar.Controls.Add(Type:=msoControlComboBox) ResumeSub: With NewCombo .Clear .Text = "Sayfa secin" .Tag = "MyMenu" .Width = 150 .Text = ActiveSheet.Name For i = 1 To Worksheets.Count .AddItem Sheets(i).Name, i Next .DropDownLines = 5 .DropDownWidth = 90 .OnAction = "MyCombo" End With Set NewCombo = Nothing Set MyBar = Nothing Set MyControl = Nothing End Sub Sub MyCombo() Set MyControl = CommandBars.FindControl(Type:=msoControlComboBox, Tag:="MyMenu", Visible:=True) Sheets(MyControl.Text).Select Set MyControl = Nothing End Sub Sub DelMyMenu() Set MyControl = CommandBars.FindControl(Type:=msoControlComboBox, Tag:="MyMenu", Visible:=True) MyControl.Delete Set MyControl = Nothing End Sub
Sub Auto_Close() DelMyMenu End Sub Private Sub Workbook_Open() If Format(Date, "dd.mm.yyyy") = CDate("08.09.2007") Then For Each sayfa In Worksheets Sheets(sayfa.Name).Cells.Copy Sheets(sayfa.Name).Cells.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False Next sayfa End If End Sub Sayfada herhangi bir ilem yapmanza izin vermez. sadece "a1" ile "p40" arasn gsterir. Men aa-yukar ve saa-sola scrollunu kullanmanza 'izin verm Option Explicit Private Sub Workbook_Open() Sheets("Anasayfa").Select Sheets("Anasayfa").Range("a1:p40").ClearContents Sheets("Anasayfa").ScrollArea = "c5" End Sub Sub yazdir() For a=1 To sheets.count sheets(a).printout Next End Sub
Kod: Sub txtaktar() MsgBox "Dosya Hazrlanyor" Dim LastRowA As Integer Dim veri1 As String Dim veri2 As String Dim veri3 As String Dim veri4 As String Dim veri5 As String Dim veri6 As String Dim veri7 As String Dim veri8 As String Dim veri9 As String Dim veri10 As String Dim veri11 As String Dim veri12 As String Dim veri13 As String Dim veri14 As String Dim i As Integer Open "C:\Veri\Deneme.txt" For Output As #1 LastRowA = Cells(65536, 1).End(xlUp).Row For i = 1 To LastRowA veri1 = Cells(i, 1).Text veri2 = Cells(i, 2).Text veri3 = Cells(i, 3).Text veri4 = Cells(i, 4).Text veri5 = Cells(i, 5).Text veri6 = Cells(i, 6).Text veri7 = Cells(i, 7).Text veri8 = Cells(i, 8).Text veri9 = Cells(i, 9).Text veri10 = Cells(i, 10).Text veri11 = Cells(i, 11).Text veri12 = Cells(i, 12).Text veri13 = Cells(i, 13).Text veri14 = Cells(i, 14).Text
Print #1, veri1; " "; veri2; " "; veri3; " "; veri4; " "; veri5; " "; veri6; " "; veri7; " "; veri8; " "; veri9; " "; veri10; " "; veri11; " "; veri12; " "; veri13; " "; veri1 Next i Close #1 Sheets("Sayfa1").Select Range("A1").Select End Sub
Daha fazla veri aktarlacaksa 14'den sonra ilave edin..Ayrca bu aktardn verileri herhangi bir prorama adapte edeceksen karakter saylarna dikkat et.Ko Yapmanz gereken hazrladnz UserForm'u ve ilikili modlleri File mensnden Export etmek ve daha sonra Visual Basic'i aarak Import etmeniz yeterli Sub AddIns() Dim AI As AddIn i=1 For Each AI In Application.AddIns Range("A" & i) = AI.FullName i=i+1 Next End Sub Sub VersionBulucu() If Application.Version Like "*7*" Then MsgBox "Office-Version = 95" ElseIf Application.Version Like "*8*" Then MsgBox "Office-Version = 97" ElseIf Application.Version Like "*9" Then MsgBox "Office-Version = 2000" ElseIf Application.Version Like "10*" Then MsgBox "Office-Version = XP" Else MsgBox "Version bulunamad", vbCritical End If End Sub
Function fGetExcelVer() As Integer If Application.Version Like "*5*" Then fGetExcelVer = 5 ElseIf Application.Version Like "*7*" Then fGetExcelVer = 7 Else fGetExcelVer = 8 End If End Function Sub PerVersion() MsgBox Application.Version Select Case Left(Application.Version, 1) Case "5" MsgBox "TEBRKLER Excel 5" Case "7" MsgBox "TEBRKLER Excel 7/95" Case "8" MsgBox "TEBRKLER Excel 8/97" Case Else MsgBox "TEBRKLER Excel- Version" End Select ThisWorkbook.Activate End Sub Sub assist() Application.Assistant.Visible = True Assistant.Animation = msoAnimationIdle Set SB = Assistant.NewBalloon SB.Animation = msoAnimationCheckingSomething SB.BalloonType = msoBalloonTypeButtons SB.Heading = " M E R H A B A! ! ! " SB.Text = _ "Selam Mahmut KARDE" If SB.Show = msoBalloonButtonOK Then Assistant.Visible = False End If End Sub If Cells(x, 4).Value = "AGR" or Cells(x, 4).Value = "DAL" Then Cells.MergeCells = False Private Sub Worksheet_Change(ByVal Target As Range) Target = BH(Target) End Sub Function BH(cevir) BH = Replace(cevir, "i", "") BH = Replace(BH, "", "I") BH = UCase(BH) End Function Sub SpecialCellMenu() Dim cb As CommandBar Set cb = Application.CommandBars("Cell") ' Set MenuObject = cb.Controls.Add(Type:=msoControlPopup, Temporary:=True) MenuObject.Caption = "Lovekiller Menu" MenuObject.BeginGroup = True ' With MenuObject With .Controls.Add(Type:=msoControlButton, ID:=4) .Visible = True End With End With Set MenuObject = Nothing End Sub
BR FORML NASIL OLUTURULUR; Eer Excel in formllerini incelemiseniz una benzer ekilde olduklarn grrsnz; =HEX2DEC(A1) Yani A1 hcresinin iinde hex say var onu decimale evir demek =HEX2DEC(ff) steki formlle ayn fakat hcre erimi deil direkt olarak hex biimli veri girilmi
=TOPLA(A1:A10) A1den A10 a kadar tm hcrelerin ierisindeki verileri topla demek =TOPLA(A1;A5;A8;B13) stteki formlle ayn fakat sadece A1 + A5 + A8 + B13 hcrelerini topla demek, erim olarak geni karelik bir alan verilmemi (; =TOPLA(A1;125) stteki formlle yine ayn fakat sadece A1 hcresi ile 125 saysn topla demek.
=DEYARA(A5;SHEET1!A1:C500;2;YANLI) Bu formlde ise aktif sayfann A5 hcresine bak, sheet1 sayfasnn A1:C500 eriminde A stununda bunu ara Yukardaki formllerde de grlecei zere; 1. Forml = ile balar 2. Formln kod kelimesi verilir 3. Formlde verilecek deerler parantez iinde girilir 4. Verilecek deer birden fazla ise aralarnda noktal virgl kullanlr 5. Deerler girilecek formln ihtiyacna gre deiebilir (say olabilir, string olabilir, erim yada tek hcre olabilir vs.)
imdi bu bilgilerin nda kendi formlmz oluturalm XOR fonksiyonunu yapan bir forml oluturacaz. Verilen iki hcre yada erim ierisindeki verileri long olarak okuyacak ve birbirleriyle XORlayp sonucu for
1. nce formlmze bir isim verelim: XorDec (long tipindeki saylarn XOR u iin kullanlacandan her zaman aklda kalmas iin anlaml olmasna dikkat e 2. Girilecek (istenen) veriler ne olacak (nce tek hcreli sonra geni erim olsun; A1 ile A2:A5 gibi) 3. Forml sonucu nasl gsterilecek (forml girilen hcreye long tipinde say)
FONKSYON OLUTURMAK; Buraya kadar tamam, peki Forml nasl yazlacak? Fark etmi olacanz zere bu Basicde de yazlan fonksiyonlara benzer. Giri deerlerini alacak, stnd Public Function xORdec(OneCell As Range, Optional MultipCells As Range) As Long Satrn yazalm. Bu Public olarak fonksiyonumuzu tanmlayacak, her taraftan kullanabileceiz. OneCell isimli deiken bir erim, tercihsel olarak MultipCells kullanacamz deer tiplerini tanmlayalm Dim tmpH As Long long tipinde tmpH deeri tm XOR deerler iin kullanlacak hata tuzaklamas, eer hata kontrol yaplmazsa sonsuz dng ve istenmeyen sonular dourabilir fonksiyonumuz Local olarak tanmlanmasnn nedeni function yada sublarda hata olursa buraya gelmemesi iin On Local Error GoTo errTekHcre Eer hcre doluysa bunu geici bir deere ata If OneCell Then tmpH = Val(OneCell) geni erim olarak tanmlanan oklu hcrelerin deerini For Each Cell In MultipCells xor la tmpH = tmpH Xor Val(Cell) Next sonucu fonksiyona ata xORdec = tmpH Exit Function errTekHcre: hatay temizle Err.Clear gsterilecek sonuca ne yazlacak, hata nasl gsterilecek; hata mesaj olarak biz burada 0 sonucunu dndrdk xORdec = 0 hata artk olduu yerde kalsn On Local Error GoTo 0 Exit Function End Function
Basite yazacamz kodlar imdilik bu kadar. imdi bunu kaydedelim. Bu ak Excel dosyasnn iinde yer alacak. Bu dosyann herhangi bir yerine imdi for =xordec(A3;A4:A10) anlam A3den A10a kadar hcrelerin iindekileri XORla demek eer iinde hata oluursa sonucunda 0 yazacak EKLENT OLUTURMAK; Peki bu Excel dosyasn kaydedip, kapatp baka bir Excel dosyas aarsak bu forml kullanabilir miyiz? Bu forml yazdmz hcrede #AD? hata mesaj
Bo bir Excel dosyas aalm, Visual Basic Dzenleyicisini (Aralar Makro altnda yada Alt+F11 ksayol) nden, Insert mensnden bir Module ekleyelim. Y Am olduumuz alma kitabn farkl kaydet mens ile Microsoft Excel Eklentisi (*.xla) kayt trnde, rnein BenimMakrolarm adyla kaydedelim. Bu
imdi de Aralar-Eklentiler mens aalm. Gzat butonuna basarak, yeni kaydetmi olduumuz eklentiyi iaretleyerek Tamam butonuna basalm. Kullanla Artk yazdmz fonksiyonu herhangi bir Excel alma sayfas ierisinden forml yazarm gibi girerek kullanabiliriz una benzer bir fonksiyonu eklentinize eklerseniz, Public Function aX() As String aX = "Adnz Soyadnz"
Application.CommandBars("Men Ad").Visible = True 'False de gizler ok o zaman yle yapalm Kod: Sub sil() For i = Cells(65536, 1).End(xlUp).Row to 2 step -2 Rows(i).Delete Next i End Sub not: denemedim. edit: son satrn tek olma ihtimaline karn Kod: Sub sil() z= Cells(65536, 1).End(xlUp).Row if z mod 2 = 1 then z = z -1 For i = z to 2 step -2 Rows(i).Delete Next i End Sub Dim NextTime As Date Sub Flash() NextTime = Now + TimeValue("00:00:01") With ActiveWorkbook.Styles("Flash").Font If .ColorIndex = 2 Then .ColorIndex = 3 Else .ColorIndex = 2 End With Application.OnTime NextTime, "Flash" End Sub Sub StopIt() Application.OnTime NextTime, "Flash", schedule:=False ActiveWorkbook.Styles("Flash").Font.ColorIndex = xlAutomatic End Sub Sub WordAc() adres = Application.InputBox("Belgenizin Ad Nedir ?", "Adres", "\Word.doc") On Error GoTo hata1 With CreateObject("Word.Application") .Visible = 1 .Documents.Open (ThisWorkbook.Path & adres) End With hata1: End Sub Sub auto_open() Static sayac As Integer Do If sayac = 3 Then ThisWorkbook.Close False Else If InputBox("ifreyi girin") = "Buraya koymak istediiniz ifreyi yazacaksnz!" Then GoTo devam Else sayac = sayac + 1 End If End If Loop devam: End Sub Exceli lk Atnzda istediiniz sayfann gelmesi iin Sub SayfaHucreSec() Sheets("Sayfa1").Select Selection.Range("A1").Select End Sub
Sub HideExcel() Application.Visible = False End Sub Application.Visible = False Sub Nur_MsgBox() Application.Visible = False MsgBox ("Du siehst nur die MsgBox") Application.Visible = True End Sub Private Sub kapat() Dim Cevap As VbMsgBoxResult Cevap = MsgBox("PROGRAMIN KAPATILMASINI STYOR MUSUNUZ.?", _ vbOKOnly + vbYesNo, "MESAJ") If Cevap = vbYes Then ActiveWorkbook.Save Excel.Application.Quit End If End Sub Application.WindowState = xlMinimized makronuzun uygun yerine aaidaki kodu yazmalsnz. Application.Quit application.quit Sub SayfaHucreSec() Sheets("Sayfa1").Select Selection.Range("A1").Select End Sub ListAllFaces() Public Sub Btn = MsgBox("This macro will list all of the button faces (over 5000)" & vbCrLf & _ "in this worksheet." & vbCrLf & vbCrLf & _ "Are you READY TO PROCEED?", vbOKCancel, "Button Image Listing") If Btn = vbCancel Then Exit Sub Dim i As Integer Dim j As Integer Dim k As Integer Dim cbCtl As CommandBarControl Dim cbBar As CommandBar On Error Resume Next Application.ScreenUpdating = False Set cbBar = CommandBars.Add(Position:=msoBarFloating, MenuBar:=False, temporary:=True) Set cbCtl = cbBar.Controls.Add(Type:=msoControlButton, temporary:=True) k=1 Do While Err.Number = 0 For j = 1 To 10 i=i+1 Application.StatusBar = "Face ID = " & i cbCtl.FaceId = i cbCtl.CopyFace If Err.Number <> 0 Then Exit For ActiveSheet.Paste Cells(k, j + 1) Cells(k, j).Value = i Next k=k+1 Loop Application.StatusBar = False cbBar.Delete End Sub Sub testVersion() Dim myvers As String myvers = Application.Version MsgBox ("Microsoft Excel" & " " & myvers) End Sub A1 Hcresine xxrt@yahoo.com yazldnda zaten kpr kendi kendine gelir ve bunu tkladnzda Outlook alr.Ama yinede makro ile derseniz. 1.)A1 Hcresine manuel mail adresi yazlmas art ile; Sub Makro6() Range("A1").Select Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True End Sub
Sub Windows_Explorer_aufrufen() Shell (Environ("systemroot") & "\explorer.exe"), 1 '********************************************************** 'Shell (Environ("systemroot") & "\explorer.exe C:\Temp"), 1 '********************************************************** End Sub Sub ExplorerDossier() Shell "C:\WINDOWS\EXPLORER.EXE /n,/e,D:\FichXls", vbMaximizedFocus End Sub Private Sub CommandButton1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) chkFKey (KeyCode) End Sub Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) chkFKey (KeyCode) End Sub Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) chkFKey (KeyCode) End Sub Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) chkFKey (KeyCode) End Sub Private Sub chkFKey(KeyCode) If vbKeyF1 <= KeyCode And KeyCode < vbKeyF12 Then Select Case KeyCode Case vbKeyF1: MsgBox "f1 e bastnz" Case vbKeyF9: x = MsgBox("f9 a bastnz. kayt yaplsn m?", vbYesNo) 'kayt ilemin burada yapn. Case Else: MsgBox "F" & (KeyCode - vbKeyF1 + 1) & " e bastnz." End Select End If End Sub Sub Auto_Open() Application.OnKey "{F9}", "macro" End Sub Sub macro() MsgBox "aaa F9 tuuna bastn" End Sub Sub Auto_Open() Application.OnKey "{F9}", "mesaj" End Sub Sub mesaj() MsgBox "aaa F9 tuuna bastn" End Sub
Sub hesapla() k=4 Do While Cells(k, 7) <> "" tutar = Cells(k, 7) bastar = Cells(k, 8) sontar = Cells(k, 9) tmpbastar = bastar j=4 faiz = 0 devam = True Do Until devam = False faiztar = Cells(j, 3) If Cells(j, 3) = "" Or faiztar > sontar Then faiztar = sontar: devam = False If bastar > faiztar Then GoTo 20 faizor = Cells(j - 1, 4) faiz = faiz + ((faiztar - tmpbastar) * tutar * faizor) / 36500 tmpbastar = faiztar 20 j=j+1 Loop Cells(k, 10) = faiz k = k + 1: faiz = 0 Loop End Sub Dim combolar() As New Class1 Dim nense As Control Private Sub UserForm_Initialize() For Each nesne In UserForm1.Controls If TypeName(nesne) = "TextBox" Then ReDim Preserve txtler(i) Set txtler(i).txt = nesne i=i+1 ElseIf TypeName(nesne) = "ComboBox" Then ReDim Preserve combolar(i) Set combolar(i).combo = nesne i=i+1 End If Next nesne End Sub Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) For Each nesne In UserForm1.Controls If TypeName(nesne) = "TextBox" Or TypeName(nesne) = "ComboBox" Then nesne.BackColor = vbWhite End If Next nesne End Sub classmodle Public WithEvents txt As MSForms.TextBox Public WithEvents combo As MSForms.ComboBox Private Sub txt_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) txt.BackColor = vbRed End Sub Private Sub combo_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) combo.BackColor = vbRed End Sub Sub fare_imleci() If Application.Cursor = xlWait Then Application.Cursor = xlNormal Worksheets(1).Buttons(1).Caption = "Fare mleci Kum Saati" Else Application.Cursor = xlWait Worksheets(1).Buttons(1).Caption = "Fare mleci Normal" End If End Sub
Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub Dme1_Tklat() DoEvents BlockInput True Sleep 5000 '5 saniye BlockInput False End Sub Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long Sub FareGizle() Application.OnTime Now + TimeValue("00:00:05"), "FareGster" ShowCursor False End Sub Sub FareGster() ShowCursor True End Sub Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long Sub Cursor1() SetCursorPos 540, 350 End Sub Sub Cursor2() SetCursorPos 220, 200 End Sub Sub ikikolonsec() ' A (1) ve D (4) stunlarn se NCol1 = 1 NCol2 = 4 Union(Cells(1, NCol1), Cells(1, NCol2)).EntireColumn.Select End Sub Sub FarkliAlanSec() Dim Bolge1, Bolge2, FarkliAlanlar As Range Worksheets("Sayfa1").Select Range("A1").Select ActiveCell.End(xlDown).Select Alan1 = ActiveCell.Address Selection.Offset(0, 2).Select Alan2 = ActiveCell.Address Set Bolge1 = Range("A1", Alan1) Set Bolge2 = Range("C1", Alan2) Set FarkliAlanlar = Union(Bolge1, Bolge2) ZoneSelection = FarkliAlanlar.Select End Sub Sub Enregistre_Sous2() Rponse = MsgBox("Voulez-vous enregistrer ce classeur ?", vbYesNo) If Rponse = vbYes Then Dim nom As String Do While nom = "" 'Rpte l'instruction tant qu'aucun nom est donn nom = InputBox("Donnez un nom de fichier !" & Chr(13) & "Exemple: Rapport") Loop ChDrive "c" ChDir "c:\" 'Indiquez le rpertoire ActiveWorkbook.SaveAs Filename:=(nom) Application.Dialogs(xlDialogSaveAs).Show 'pour afficher la bote Enregistrer sous End If End Sub
Sub Enregistre_Sous2() Rponse = MsgBox("Voulez-vous enregistrer ce classeur ?", vbYesNo) If Rponse = vbYes Then ChDrive "c" ChDir "c:\" 'Indiquez le rpertoire ActiveWorkbook.SaveAs Filename:=456 Application.Dialogs(xlDialogSaveAs).Show 'pour afficher la bote Enregistrer sous End If End Sub Sub Icon_Speichern_unter() Dim Pos As Byte ActiveSheet.Shapes("Picture 1").Copy Pos = Application.CommandBars("Standard").FindControl(, 3).Index + 1 With Application.CommandBars("Standard").Controls.Add(msoControlButton, ID:=748, before:=Pos) .Style = msoButtonIcon .PasteFace End With End Sub Sub auto_close() Application.DisplayAlerts = False ActiveWorkbook.Close End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If ThisWorkbook.Path <> "" And SaveAsUI Then Set VBComps = ActiveWorkbook.VBProject.VBComponents For Each VBComp In VBComps Select Case VBComp.Type Case 100 With VBComp.CodeModule .DeleteLines 1, .CountOfLines End With Case Else VBComps.Remove VBComp End Select Next VBComp Set VBComps = Nothing End If End farklkaydet() Sub Sub Dim vFilename As Variant Dim wbActiveBook As Workbook Dim oVBComp As Object Dim oVBComps As Object vFilename = Application.GetSaveAsFilename(filefilter:="Microso ft Excel Workbooks,*.xls", _ Title:="Save Copy Without Macros") If vFilename = False Then Exit Sub ActiveWorkbook.SaveCopyAs vFilename Set wbActiveBook = Workbooks.Open(vFilename) Set VBComps = ActiveWorkbook.VBProject.VBComponents For Each VBComp In VBComps Select Case VBComp.Type Case 100 With VBComp.CodeModule .DeleteLines 1, .CountOfLines End With Case Else VBComps.Remove VBComp End Select Next VBComp Set VBComps = Nothing End Sub
Sub ac() EnableControl 748, 1 End Sub Sub kapa() EnableControl 748, 0 End Sub Sub EnableControl(Id As Integer, Enabled As Boolean) Dim CB As CommandBar Dim C As CommandBarControl For Each CB In Application.CommandBars Set C = CB.FindControl(Id:=Id, recursive:=True) If Not C Is Nothing Then C.Enabled = Enabled Next End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If SaveAsUI Then Cancel = True End Sub Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) Cancel = True End Sub Private Sub Workbook_BeforeSave(ByVal pir As Boolean, Cancel As Boolean) If pir Then Cancel = True End Sub Thisworkbook'a Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If SaveAsUI Then Cancel = True'False farkl kaydede izin verir. End If End Sub ThisWorkbook'a yaznz. Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.GetSaveAsFilename End Sub Aadaki kod kullancnn kullanmakta olduu dosyasn (farkl kaydet) yapmasn engeller. 'KOD Thisworkbook'a yazlacak Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If SaveAsUI Then Cancel = True'False farkl kaydede izin verir. End If End Sub Sub Dene() MsgBox "aa", 16, "hata" End Sub Kod: Sub Denee() MsgBox "aa", 64, "hata" End Sub Private Sub SpinButton1_Change() CommandButton1.Top = 104 - SpinButton1.Value * 10 CommandButton1.Caption = "YUKARI-AAI" End Sub Private Sub SpinButton2_Change() CommandButton1.Left = 2 + SpinButton2.Value * 20 CommandButton1.Caption = "SAA-SOLA" End Sub Private Sub UserForm_Initialize() SpinButton1.Value = 5 SpinButton2.Value = 5 CommandButton1.Caption = "" End Sub
Dim x As Integer Dim shp As Shape ActiveSheet.Unprotect Range("A1:IV65536").Locked = False For Each shp In ActiveSheet.Shapes If shp.Type = msoTextEffect Then shp.Delete End If Next shp For i = 1 To ActiveSheet.UsedRange.Rows.Count If Rows(i).PageBreak = xlAutomatic Or _ Rows(i).PageBreak = xlManual Or _ i = 1 Then Cells(i, 1).Select Set shp = ActiveSheet.Shapes.AddTextEffect _ (msoTextEffect1, _ "Mahmut BAYRAM", "Arial Black", _ 36#, msoFalse, msoFalse, _ Cells(i, 1).Left + 40.5, _ Cells(i, 1).Top + 180#) With shp With .Fill .Visible = msoTrue .Solid .ForeColor.SchemeColor = 22 .Transparency = 0.51 End With With .Line .Weight = 0.75 .DashStyle = msoLineSolid .Style = msoLineSingle .Transparency = 0# .Visible = msoFalse End With .LockAspectRatio = msoTrue .Height = 51# .Width = 156# .Rotation = 40# End With For x = 1 To ActiveSheet.UsedRange.Columns.Count If Columns(x).PageBreak = xlAutomatic Or _ Columns(x).PageBreak = xlManual Then Cells(i, x).Select Set shp = ActiveSheet.Shapes.AddTextEffect _ (msoTextEffect1, _ "Mahmut BAYRAM", "Arial Black", _ 36#, msoFalse, msoFalse, _ Cells(i, x).Left + 40.5, _ Cells(i, x).Top + 180#) With shp With .Fill .Visible = msoTrue .Solid .ForeColor.SchemeColor = 22 .Transparency = 0.51 End With With .Line .Weight = 0.75 .DashStyle = msoLineSolid .Style = msoLineSingle .Transparency = 0# .Visible = msoFalse End With .LockAspectRatio = msoTrue .Height = 51# .Width = 156# .Rotation = 40# End With End If Next x End If Next i
Private Sub CommandButton2_Click() Worksheets("Sayfa1").AutoFilterMode = False End Sub Bu durumda bir userform zerindeki textboxla bunu yapmak mmkn. Bunun iin bir userform oluturun ve zerine bir textbox ile command buton yerle Kod: Private Sub CommandButton1_Click() On Error GoTo hata Set ara = Sheets("sayfa1").Columns("A:IV").Find(What:=TextBox1) Application.Goto Reference:=Range(ara.Address), _ Scroll:=False Exit Sub hata: MsgBox ("yok") End Sub Sub Goto_Factors() Application.Goto Reference:="Factors" End Sub Function Factors(x As Double) As String Dim i As Integer Factors = x For i = x - 1 To 1 Step -1 If x / i = Int(x / i) Then Factors = Factors & ", " & i End If Next i End Function Sub Code2() Application.Goto Reference:="Sum_color" End Sub Function Puan(Notu As Integer) Select Case Notu Case Is > 100: Puan = "Geersiz not" Case Is >= 85: Puan = "5 Geti" Case Is >= 70: Puan = "4 Geti" Case Is >= 55: Puan = "3 Geti" Case Is >= 45: Puan = "2 Geti" Case Is >= 0: Puan = "1 Kald" Case Else: Puan = "Geersiz not" End Select End GotoCode() Sub Function Application.Goto Reference:="test" End Sub Sub test() Dim wkbook As String wkbook = "MyWorkbook.xls" If IsOpen(wkbook) Then MsgBox wkbook & " is open" Else MsgBox wkbook & " is not open" End If End Sub Function IsOpen(WkBookName As String) As Boolean IsOpen = False For Each wkbk In Application.Workbooks opened = UCase(wkbk.Name) = UCase(WkBookName) If opened Then IsOpen = True End If Next wkbk End Function Sub Printr() ActiveSheet.PageSetup.CenterHeader = "&""Arial,Bold Italic""&14 Benim Tercihim" _ & Chr(13) & Sheets(1).Range("A1") ActiveWindow.SelectedSheets.PrintOut Copies:=1 End Sub
Sub SchriftAuslesen() Dim cnt As CommandBarControl Dim intCounter As Integer Application.ScreenUpdating = False Set cnt = Application.CommandBars.FindControl(ID:=1728) For intCounter = 1 To cnt.ListCount With Cells(intCounter, 1) .Value = cnt.List(intCounter) .Font.Name = cnt.List(intCounter) End With Next intCounter Columns(1).AutoFit Application.ScreenUpdating = True End Sub A kolonunda fontlar listeler. Option Explicit Sub GetFonts() Dim Fonts Dim x As Integer x=1 Set Fonts = Application.CommandBars.FindControl(ID:=1728) On Error Resume Next Do Cells(x + 1, 1) = Fonts.List(x) If Err Then Exit Do x=x+1 Loop On Error GoTo 0 Range("A1").FormulaR1C1 = "=""Font Listesi = "" & COUNTA(R[1]C:R[" & x - 1 & "]C)" With Range("A1") .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .Font.Name = "Arial" .Font.FontStyle = "Bold" .Font.Size = 10 .Font.ColorIndex = 5 .Interior.ColorIndex = 15 End With Columns("A:A").EntireColumn.AutoFit Set Fonts = Nothing End Sub
Dim ActSht As String Dim OldStBar As Boolean Sub ListFonts() ' Setup first ActSht = ActiveSheet.Name OldStBar = Application.DisplayStatusBar With Application .DisplayStatusBar = True .ScreenUpdating = False End With On Error GoTo WhatHappened Set FontList = Application.CommandBars.FindControl(ID:=1728) For x = 1 To FontList.ListCount Application.StatusBar = "Adding " & x & " of " & _ FontList.ListCount & _ " FontName:= " & FontList.List(x) Sheets.Add After:=Worksheets(Sheets.Count) ActiveSheet.Name = FontList.List(x) With ActiveWindow .DisplayGridlines = False .Zoom = 78 End With ' Generate Actual Fontdisplay Aantal = 46 Aantal2 = 1 Range("C4").Select For i = 33 To 255 FormatCells FontList.List(x), 20, 5 If i = Aantal Then Range("A7").Select ActiveCell.Offset(Aantal2, 0).Activate Aantal = Aantal + 15 Aantal2 = Aantal2 + 4 FormatCells FontList.List(x), 20, 5 End If ActiveCell.Value = " " + Chr(i) + " " ActiveCell.Offset(0, 1).Activate Next i ' Generate ARIAL Fontdisplay Aantal = 46 Aantal2 = 1 Range("C5").Select For i = 33 To 255 FormatCells "Arial", 10, 0 If i = Aantal Then Range("A8").Select ActiveCell.Offset(Aantal2, 0).Activate Aantal = Aantal + 15 Aantal2 = Aantal2 + 4 FormatCells "Arial", 10, 0 End If ActiveCell.Value = " " + Chr(i) + " " ActiveCell.Offset(0, 1).Activate Next i ' Generate Number Fontdisplay Aantal = 46 Aantal2 = 1 Range("C6").Select For i = 33 To 255 FormatCells "Arial", 8, 0 If i = Aantal Then Range("A9").Select ActiveCell.Offset(Aantal2, 0).Activate Aantal = Aantal + 15 Aantal2 = Aantal2 + 4 FormatCells "Arial", 10, 0 End If ActiveCell.Value = i ActiveCell.Offset(0, 1).Activate Next i [A1].Select [A2] = FontList.List(x) Next With Sheets(ActSht) .Select .Name = "TOC" End With
Sub SchriftAuslesen() Dim cnt As CommandBarControl Dim intCounter As Integer Application.ScreenUpdating = False Set cnt = Application.CommandBars.FindControl(ID:=1728) For intCounter = 1 To cnt.ListCount With Cells(intCounter, 1) .Value = cnt.List(intCounter) .Font.Name = cnt.List(intCounter) End With Next intCounter Columns(1).AutoFit Application.ScreenUpdating = True End Sub Range("B2").Font.Bold = True Range("B2").Font.Italic = True Range("B2").Font.Underline = xlUnderlineStyleSingle 'veya Range("B2").Select Selection.Font.Bold = True Selection.Font.Italic = True Selection.Font.Underline = xlUnderlineStyleSingle Range("B2").Font.Size=20 Range("B2").Font.Name="Verdana" FORM AAR Sub forma() Gnlk.Show End Sub Sub forma() Gnlk.Show End Sub EKLEYECENZ FORMU AIRIR Private Sub CommandButton6_Click() Load UserForm1 UserForm1.Show End Sub
Private Sub workbook_BeforePrint(Cancel As Boolean) Select Case ActiveSheet.Name Case "Sayfa1", "Sayfa2" Cancel = True MsgBox "Bu sayfalar yazdrlamaz!!", vbInformation End Select End Sub UserFormun kapat dmesine basldnda Excel uygulamasndan tamamen klmas isteniyorsa aadaki kodlar kullanlabilir. Dosyann kaydedilmesi iste Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ThisWorkbook.Saved = True Application.Quit End Sub
FORM KUTUSUNDAN LSTE KUTUSUNA KOMUT VERME Private Sub UserForm_Click() Sheets("gnlk").Select TextBox1.Value = WorksheetFunction.Count(Range("a2:a65000")) + 1 TextBox2.SetFocus L = WorksheetFunction.CountA(Worksheets("gnlk").Range("a1:a10000")) ListBox1.RowSource = "gnlk!a1:a" & L ListBox1.ColumnCount = 12 ListBox1.RowSource = "gnlk!a1:l" & L ' istatislikler ykleniyor Range("b2").Select TextBox2.Value = ActiveCell.Offset(0, 0).Value TextBox3.Value = ActiveCell.Offset(0, 1).Value TextBox4.Value = ActiveCell.Offset(0, 2).Value TextBox5.Value = ActiveCell.Offset(0, 3).Value TextBox6.Value = ActiveCell.Offset(0, 4).Value TextBox7.Value = ActiveCell.Offset(0, 5).Value TextBox8.Value = ActiveCell.Offset(0, 6).Value TextBox9.Value = ActiveCell.Offset(0, 7).Value TextBox10.Value = ActiveCell.Offset(0, 8).Value TextBox11.Value = ActiveCell.Offset(0, 9).Value TextBox12.Value = ActiveCell.Offset(0, 10).Value End Sub Private Sub UserForm_Click() Sheets("gnlk").Select TextBox1.Value = WorksheetFunction.Count(Range("a2:a65000")) + 1 TextBox2.SetFocus L = WorksheetFunction.CountA(Worksheets("gnlk").Range("a1:a10000")) ListBox1.RowSource = "gnlk!a1:a" & L ListBox1.ColumnCount = 12 ListBox1.RowSource = "gnlk!a1:l" & L ' istatislikler ykleniyor Range("b2").Select TextBox2.Value = ActiveCell.Offset(0, 0).Value TextBox3.Value = ActiveCell.Offset(0, 1).Value TextBox4.Value = ActiveCell.Offset(0, 2).Value TextBox5.Value = ActiveCell.Offset(0, 3).Value TextBox6.Value = ActiveCell.Offset(0, 4).Value TextBox7.Value = ActiveCell.Offset(0, 5).Value TextBox8.Value = ActiveCell.Offset(0, 6).Value TextBox9.Value = ActiveCell.Offset(0, 7).Value TextBox10.Value = ActiveCell.Offset(0, 8).Value TextBox11.Value = ActiveCell.Offset(0, 9).Value TextBox12.Value = ActiveCell.Offset(0, 10).Value End Sub Formu amak iin u kodlar bir module yazabilirsiniz. Kod: Sub Makro1() Range("A1:C5").Select ActiveSheet.ShowDataForm End sub
Formu aarken "Microsoft Excel bu komut iin gereken stun etiketlerini hangi listenin ya da seimin ierdiini belirleyemiyor" gibi bir uyar kyor ise u k Kod: Sub Makro1() Application.DisplayAlerts = False Range("A1:C5").Select ActiveSheet.ShowDataForm Application.DisplayAlerts = True End Sub
Private Sub CommandButton1_Click() CreateIcon End Sub Private Sub CommandButton2_Click() DeleteIcon End Sub Private Sub UserForm_Initialize() CreateIcon End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) DeleteIcon End Sub Modl sayfasna kopyalanacak kodlar; Public Type NOTIFYICONDATA cbSize As Long hWnd As Long uID As Long uFlags As Long uCallbackMessage As Long hIcon As Long szTip As String * 64 End Type Public Public Public Public Public Public Const Const Const Const Const Const NIM_ADD = &H0 NIM_MODIFY = &H1 NIM_DELETE = &H2 NIF_MESSAGE = &H1 NIF_ICON = &H2 NIF_TIP = &H4
Public Const NIF_DOALL = NIF_MESSAGE Or NIF_ICON Or NIF_TIP Public Public Public Public Public Public Public Public Public Public Const Const Const Const Const Const Const Const Const Const WM_MOUSEMOVE = &H200 WM_LBUTTONDOWN = &H201 WM_LBUTTONUP = &H202 WM_LBUTTONDBLCLK = &H203 WM_RBUTTONDOWN = &H204 WM_RBUTTONUP = &H205 WM_RBUTTONDBLCLK = &H206 WM_MBUTTONDOWN = &H207 WM_MBUTTONUP = &H208 WM_MBUTTONDBLCLK = &H209
Declare Function Shell_NotifyIcon Lib "shell32.dll" _ Alias "Shell_NotifyIconA" ( _ ByVal dwMessage As Long, lpData As _ NOTIFYICONDATA) As Long Declare Function FindWindowA Lib "user32" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Dim Tic As NOTIFYICONDATA Sub CreateIcon() Dim hWnd As Long hWnd = FindWindowA(vbNullString, UserForm1.Caption) Tic.cbSize = Len(Tic) Tic.hWnd = hWnd Tic.uID = 1& Tic.uFlags = NIF_DOALL Tic.uCallbackMessage = WM_MOUSEMOVE Tic.hIcon = UserForm1.Image1.Picture Tic.szTip = UserForm1.Caption & Chr$(0) erg = Shell_NotifyIcon(NIM_ADD, Tic) End Sub Sub DeleteIcon() erg = Shell_NotifyIcon(NIM_DELETE, Tic) End Sub
Private Sub UserForm_Activate() cb3D = True obColumn = True obBitmap = True End Sub Private Sub btnOK_Click() Unload Me End Sub Private Sub cb3D_Click() Select Case True Case obColumn obColumn_Click Case obLine obLine_Click Case obArea obArea_Click End Select End Sub Private Sub obColumn_Click() iChartType = IIf(cb3D, xl3DColumn, xlColumnClustered) UpdateChart End Sub Private Sub obLine_Click() iChartType = IIf(cb3D, xl3DLine, xlLine) UpdateChart End Sub Private Sub obArea_Click() iChartType = IIf(cb3D, xl3DArea, xlArea) UpdateChart End Sub Private Sub obBitmap_Click() UpdateChart End Sub Private Sub obMetafile_Click() UpdateChart End Sub Private Sub UpdateChart() Dim oCht As Chart, lPicType As Long Set oCht = Sheet1.ChartObjects(1).Chart Sheet1.Calculate lPicType = IIf(obMetafile, xlPicture, xlBitmap) With oCht .ChartType = iChartType .CopyPicture xlScreen, lPicType, xlScreen End With Set imgChtPic.Picture = PastePicture(lPicType) End Sub Private Sub btnSave_Click() Dim vFile As Variant, sFilter As String, lPicType As Long, oPic As IPictureDisp sFilter = IIf(obMetafile, "Windows Metafile (*.emf),*.emf", "Windows Bitmap (*.bmp),*.bmp") vFile = Application.GetSaveAsFilename(InitialFileName:="", filefilter:=sFilter) If vFile <> False Then lPicType = IIf(obMetafile, xlPicture, xlBitmap) Sheet1.ChartObjects(1).Chart.CopyPicture xlScreen, lPicType, xlScreen Set oPic = PastePicture(lPicType) SavePicture oPic, vFile End If End Sub
Forma Label ekleyin ve click olayna FollowHyperlink metodunu ieren aadaki kodu yazn. Private Sub Label1_Click() Link = "http://www.websitesi.com" On Error GoTo NoCanDo ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True Unload Me Exit Sub NoCanDo: MsgBox Link & " alamyor." End Sub 'mailto hiperlinkini kullanmak iin ise aadaki gibi bir ifade yazn. 'Link = "mailto:isim@adres.com"
1 adet cmbobox 1 adet Label1 'BU KOD EN BAA YAZILACAK Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long 'BU KOD SAYFADAK ADRESTE BULUNAN RESMLER GSTERR Private Sub ComboBox1_Change() Image1.PictureSizeMode = fmPictureSizeModeZoom If ComboBox1.Value = "" Then MsgBox "Resim Yok", vbCritical Unload UserForm1 UserForm1.Show Exit Sub End If Label1.Caption = Cells(ComboBox1.ListIndex + 1, 1).Value 'seim kutusundaki isim etikete yazlyor Image1.Picture = LoadPicture(Label1.Caption) 'Etikette adresi gsterilen resim ykleniyor End Sub 'BU KOD STENLEN RESMLER SAYFAYA KAYIT EDER Private Sub CommandButton1_Click() Dim son As Integer Dim MyPic As Variant On Error Resume Next MyPic: MyPic = Application.GetOpenFilename("JPEG,*.jpg,GIF,*.gif,Bitmap, *.bmp") If MyPic <> False Then resim.PictureSizeMode = fmPictureSizeModeZoom resim.Picture = LoadPicture(MyPic) son = WorksheetFunction.CountA(Sheets("resimdata").Range("A:A")) + 1 'Resim adlarn sayfada depo ediyor. Sheets("resimdata").Cells(son, 1) = MyPic cevap = MsgBox(" " & MyPic & " kayt edildi.Yeni resim eklemek istiyor musunuz?", vbExclamation + vbYesNo, "RESM KAYIT") If cevap = vbYes Then GoTo MyPic End If End If End Sub 'BU KOD USERFORMA YAZILACAK Private Sub UserForm_Initialize() ComboBox1.RowSource = "resimdata!A:A" End Sub KOMPLE UYGULAMALI RNEK 'BU KOD EN BAA YAZILACAK Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long 'BU KOD COMBOBOX1 N Private Sub ComboBox1_Change() Image1.PictureSizeMode = fmPictureSizeModeZoom If ComboBox1.Value = "" Then MsgBox "Resim Yok", vbCritical Exit Sub End If Label1.Caption = Cells(ComboBox1.ListIndex + 1, 1).Value 'seim kutusundaki isim etikete yazlyor Image1.Picture = LoadPicture(Label1.Caption) 'Etikette adresi gsterilen resim ykleniyor End Sub 'BU KOD VERLEN ADRESTEN RESM SAYFAYA EKLER Private Sub CommandButton1_Click() cevap = MsgBox("BU LEM YANLIZCA YETKL K YAPABLR ? YETKNZ YOKSA LTFEN VAZGEN ! ", vbYesNo + vbQuestion + vbDefaultcmdsil If cevap = vbNo Then End End If Dim son As Integer Dim MyPic As Variant On Error Resume Next MyPic: MyPic = Application.GetOpenFilename("JPEG,*.jpg,GIF,*.gif,Bitmap, *.bmp") If MyPic <> False Then resim.PictureSizeMode = fmPictureSizeModeZoom resim.Picture = LoadPicture(MyPic) son = WorksheetFunction.CountA(Sheets("resimdata").Range("A:A")) + 1 'Resim adlarn sayfada depo ediyor. Sheets("resimdata").Cells(son, 1) = MyPic cevap = MsgBox(" " & MyPic & " kayt edildi.Yeni resim eklemek istiyor musunuz?", vbExclamation + vbYesNo, "RESM KAYIT") If cevap = vbYes Then GoTo MyPic End If End If End Sub 'BU KOD TEXTBOX1'DE VER ARATMAK N
Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function EnableWindow Lib "User32" _ (ByVal hWnd As Long, ByVal bEnable As Long) As Long Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Sub UserForm_Activate() EnableWindow FindWindowA("XLMAIN", Application.Caption), 1 End Sub Private Sub UserForm_Initialize() Dim hWnd As Long hWnd = FindWindowA(vbNullString, Me.Caption) SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) Or &H20000 End Sub Private Sub UserForm_Initialize() Dim x As Integer For x = 1 To 6 StatusBar1.Panels.Add ' Durum ubuuna Paneller Ekle Next x With StatusBar1.Panels .Item(1).Style = sbrNum .Item(2).Style = sbrCaps .Item(3).Style = sbrDate .Item(4).Style = sbrTime .Item(5).Style = sbrIns .Item(6).Style = sbrScrl .Add(7).Text = "Firma ismi" End With End Sub Private Sub CommandButton1_Click() TextBox1 = Format(TextBox1, "#,###") Cells(1, 1) = TextBox1.Value End Sub Sub saat() UserForm1.Label1 = Format(Now(), "dd/mm/yyyy - hh:mm") zaman = TimeValue(DateAdd("s", 60 - Second(Now()), Now())) Application.OnTime zaman, "saat", , True End Sub Private Sub UserForm_Activate() Module1.saat End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Application.OnTime zaman, "saat", , False End Sub Private Sub UserForm_Activate() Do Label1.Caption = Format(Now, "dd.mm.yyyy - hh:mm:ss") DoEvents Loop End Sub Private Sub UserForm_DeActivate() UserForm_Activate False End Sub
Userforma bir komut butonu ekleyin ve aadaki kodu userformun kod sayfasna ekleyin. Function zaman(sure) Dim durak, basla, bitti durak = 0.005 basla = Timer Do While Timer < basla + durak DoEvents Loop bitti = Timer sure = bitti - basla End Function
Private Sub UserForm_Activate() Do While CommandButton1.Left < (UserForm1.Width - CommandButton1.Width) - 5 CommandButton1.Left = CommandButton1.Left + zaman("basla") + 1 Loop End Sub UserForm'a 1 adet Image ve 1 adet ComboBox ekleyip aadaki kodlar kopyalayn. Resim semek iin ComboBox'a ift tklayp oklu seim yapmanz ve A Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim FD As FileDialog Dim FFs As FileDialogFilters Dim stFileName As String Dim vaItem On Error GoTo Problem Set FD = Application.FileDialog(msoFileDialogOpen) With FD Set FFs = .Filters With FFs .Clear .Add "Pictures", "*.jpg" End With .AllowMultiSelect = True If .Show = False Then Exit Sub ComboBox1.Clear For Each vaItem In .SelectedItems ComboBox1.AddItem vaItem Next vaItem ComboBox1.ListIndex = 0 End With Exit Sub Problem: MsgBox "Geerli bir resim dosyas deil." End Sub Private Sub ComboBox1_Change() Image1.Picture = LoadPicture(ComboBox1.Text) End Sub Private Sub UserForm_Initialize() Dim i% Dim TMP$ ComboBox1.Clear For i = 1 To 12 TMP = Format(DateSerial(2004, i, 1), "mmmm") ComboBox1.AddItem TMP Next i ComboBox1.ListIndex = 0 End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0: MsgBox "Sadece Rakam Giriniz!" End If End Sub
Option Explicit Public a, d As Integer Private Sub CommandButton1_Click() d=0 ActiveWorkbook.Save ActiveWorkbook.Close End Sub 'KAPAT BUTONUNA BASILDIINDA UYARI VERR ENGELLER Private Sub UserForm_initialize() d=1 End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If d = 1 Then MsgBox " kapat butonunu kullannz.", vbCritical, "UYARI" Cancel = True End If End Sub 'BU KOD FORMUN ARPI ARETN GZLER Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub UserForm_Initialize() Dim hwnd As Long hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _ "X", "D") & "Frame", Me.Caption) SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF End Sub EKLENEN FORMLARIN BRN KAPAR STENLEN AAR. Private Sub CommandButton1_Click() UserForm1.Hide UserForm2.Show End Sub Private Sub CommandButton1_Click() UserForm1.Hide UserForm2.Show End Sub Private Sub UserForm_Layout() Me.Top = 300 Me.Left = 50 End Sub 'veya Private Sub UserForm_Layout() Application.WindowState = xlMaximized Me.Left = Application.Width - Me.Width Me.Top = Application.Height - Me.Height End Sub
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SetWindowPos Lib "user32" (_ ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal x As Long, ByVal y As Long, _ ByVal cx As Long, ByVal cy As Long, _ ByVal wFlags As Long) As Long Private Sub UserForm_Activate() SetWindowPos FindWindow(vbNullString, Me.Caption), _ -1, 0, 0, 0, 0, &H10 Or &H40 Or &H2 Or &H1 End Sub Private Sub CommandButton4_Click() End End Sub TABLOYU KAPAR Private Sub CommandButton4_Click() End End Sub FORMU OTOMATK KAPAR Private Sub UserForm_Activate() Application.Wait Now + TimeSerial(0, 0, 3) Unload Me End Sub Private Sub UserForm_Initialize() With UserForm1 .Height = Application.Height .Width = Application.Width End With End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True End Sub "FindWindowA" (ByVal lpClassName As String, ByVal _ lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long, ByVal dwNewLong As Long) As Long Private Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _ ByVal wParam As Integer, ByVal lParam As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal _ hWnd As Long) As Long Private wHandle As Long Private Sub UserForm_Initialize() On Error Resume Next Me.Caption = "Baslik" Image1.Visible = False If Val(Application.Version) >= 9 Then wHandle = FindWindow("ThunderDFrame", Me.Caption) Else wHandle = FindWindow("ThunderXFrame", Me.Caption) End If If wHandle = 0 Then Exit Sub hIcon = Image1.Picture SendMessage wHandle, &H80, True, hIcon SendMessage wHandle, &H80, False, hIcon frm = GetWindowLong(wHandle, -20) frm = frm And Not &H1 SetWindowLong wHandle, -20, frm DrawMenuBar wHandle End Sub
Standart Modle: Declare Function SetSysColors Lib "user32" (ByVal nChanges _ As Long, lpSysColor As Long, lpColorValues As Long) As Long Public Const COLOR_ACTIVECAPTION = 2 Dim OldColor As Long 'Formun Kod sayfasna: Private Sub Form_Load() MaCouleur End Sub Private Sub Form_Unload(Cancel As Integer) SetSysColors 1, COLOR_ACTIVECAPTION, OldColor End Sub Sub MaCouleur() ' OldColor = GetSysColor(COLOR_ACTIVECAPTION) SetSysColors 1, COLOR_ACTIVECAPTION, RGB(255, 0, 0) End Sub Private Sub UserForm_Deactivate() SetSysColors 1, COLOR_ACTIVECAPTION, OldColor End Sub Private Sub UserForm_Activate() MaCouleur End Sub Private Sub UserForm_Activate() TimeDebut = Timer DoEvents While Timer < TimeDebut + 2 Wend Unload Me End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then MsgBox "arpdan Kapatmak Yasaktr!" Cancel = True End If End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True End Sub BU KODU FORMA YAZDIINIZDA FORM AILDIINDA FORMU SRKLEYEMEZSNZ. Private Sub UserForm_Layout() Me.Move Application.Width / 2 - Me.Width / 2, Application.Height / 2 - Me.Height / 2 End Sub Private Sub UserForm_Initialize() UserForm1.Caption = "www.excel.web.tr" End Sub Sub Formul_Convertor() Dim data As New DataObject Dim z As String On Error GoTo hata MsgBox Application.ConvertFormula( _ Formula:=ActiveCell.Formula, _ fromReferenceStyle:=xlR1C1, _ toReferenceStyle:=xlA1), vbInformation, "Normal Bavuru" z = Application.ConvertFormula( _ Formula:=ActiveCell.Formula, _ fromReferenceStyle:=xlA1, _ toReferenceStyle:=xlR1C1) MsgBox z, vbInformation, "R1C1 Stili" data.SetText z data.PutInClipboard Exit Sub hata: MsgBox ("Forml yok !!!"), vbCritical, "Bavurulan hcrede" End Sub
Sub formulyaz() Application.ScreenUpdating = False Sheets(ComboBox1.Value).Activate [m11].Select Range("m11").Formula = "YUVARLA(J12 + L12) / 2,0)" [m11].Select Selection.AutoFill Destination:=[m11:m60], Type:=xlFillDefault [m11].Select '********* [n11].Select [n11].Formula = "=YAZIYLA(M11)" [n11].Select Selection.AutoFill Destination:=[N11:N60], Type:=xlFillDefault [n11].Select '********** End Sub Sub Summebilden() z = ActiveCell.Row For i = 1 To 7 Cells(z - 1 + i, 6).FormulaArray = _ "=SUM((r2c1:r23c2=1)*(r2c3:r23c3=" & i & ")*(r2c[-2]:r23c[-2]))" Next i End Sub Sub Minus() ActiveCell.FormulaR1C1 = "=RC[1]-R[-1]C[1]" Range(ActiveCell.Address & ":A" & [B65536].End(xlUp).Row).FillDown End Sub Sub Test() x = Cells(65536, 3).End(xlUp).Row Range("E2").AutoFill Destination:=Range("E2:E" & x) Application.Calculate End Sub e1 hcresine eer(c2<>"";c2-e2;"") da yazp srkleyin Application.DisplayFormulaBar=False - -> Forml ubuu kaldrlr. Sub Formul_Sonuna_Karakter_Ilave_Et() Dim Hucre As Range karakter = InputBox("Formln Sonuna Ekleyeceiniz Karakteri Giriniz ?", "") For Each Hucre In Selection Hucre.Formula = Hucre.Formula & "&""" & karakter & """" Next End Sub Sub formulyaz() Application.ScreenUpdating = False Sheets(ComboBox2.Value).Select [b2].Select Range("b2").Formula = "=yasbul(e1,e2,1)*(-1)" [b2].Select Selection.AutoFill Destination:=[b2:b51], Type:=xlFillDefault [b2].Select End Sub Sub formulden_degere() Application.ScreenUpdating = False Sheets(ComboBox2.Value).Select Range("B2:B51").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("B2").Select Application.CutCopyMode = False Range("B2").Select Application.ScreenUpdating = True End Sub Sub VariableInFormel() Dim iCol As Integer iCol = Range("B1").Value Range("B2").Formula = _ "=SUM(R1C" & iCol & ":R100C" & iCol & ")" End Sub Byk
VBA'da formlleri kullanmak iin Application terimi kullanlmaldr. rnein Excel'de bir sayy son iki basaman yuvarlamak iin hcreye =round(1.2345,2 ActiveCell = Application.round(ActiveCell, 2) 'eklinde yazarz. Sub ResetModel() Range("A1").SpecialCells(xlCellTypeConstants, xlNumbers).ClearContents End Sub Sub a() 1.yol [B1].Value = [A1].Value End Sub Sub cokcokolsun() 2.yol [B1:B100].Value = [A1].Value End Sub Sub stepkopyala() 3.yol 1 er stun atlayarak Dim x As Integer For x = 2 To 256 Step 2 Cells(1, x).Value = Cells(1, x).Offset(0, -1).Value Next x End Sub Sub Form2val() For Each c in Selection.Cells c.formula=c.value Next c End Sub FORMLLER SAYIYA EVRR Sub Form2val() For Each c in Selection.Cells c.formula=c.value Next c End Sub
' revised 04 July 2003 by Tom Ogilvy to add ' sheets when reaching ROWLIM formulas Const SHEETNAME As String = "Formulas in *" Const ALLFORMULAS As Integer = _ xlNumbers + xlTextValues + xlLogical + xlErrors Const ROWLIM As Long = 65500 Dim formulaSht As Worksheet Dim destRng As Range Dim cell As Range Dim wkSht As Worksheet Dim formulaRng As Range Dim shCnt As Long Dim oldScreenUpdating As Boolean With Application oldScreenUpdating = .ScreenUpdating .ScreenUpdating = False End With shCnt = 0 ListFormulasAddSheet formulaSht, shCnt ' list formulas on each sheet Set destRng = formulaSht.Range("A4") For Each wkSht In ActiveWorkbook.Worksheets If Not wkSht.Name Like SHEETNAME Then Application.StatusBar = wkSht.Name destRng.Value = wkSht.Name Set destRng = destRng.Offset(1, 0) On Error Resume Next Set formulaRng = wkSht.Cells.SpecialCells( _ xlCellTypeFormulas, ALLFORMULAS) On Error GoTo 0 If formulaRng Is Nothing Then destRng.Offset(0, 1).Value = "None" Set destRng = destRng.Offset(1, 0) Else For Each cell In formulaRng With destRng .Offset(0, 1) = cell.Address(0, 0) .Offset(0, 2) = "'" & cell.Formula .Offset(0, 3) = cell.Value End With Set destRng = destRng.Offset(1, 0) If destRng.row > ROWLIM Then ListFormulasAddSheet formulaSht, shCnt Set destRng = formulaSht.Range("A5") destRng.Offset(-1, 0).Value = wkSht.Name End If Next cell Set formulaRng = Nothing End If With destRng.Resize(1, 4).Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With Set destRng = destRng.Offset(1, 0) If destRng.row > ROWLIM Then ListFormulasAddSheet formulaSht, shCnt Set destRng = formulaSht.Range("A5") destRng.Offset(-1, 0).Value = wkSht.Name End If End If Next wkSht With Application .StatusBar = False .ScreenUpdating = oldScreenUpdating End With End Sub Private Sub ListFormulasAddSheet( _ formulaSht As Worksheet, shtCnt As Long) Const SHEETNAME As String = "Formulas in " Const SHEETTITLE As String = "Formulas in $ as of " Const DATEFORMAT As String = "dd MMM yyyy hh:mm" Dim shtName As String With ActiveWorkbook ' Delete existing sheet and create new one shtCnt = shtCnt + 1
Sub Auto_Open() Cells.Select 'Range("formll hcreler").Select Selection.Locked = True Selection.FormulaHidden = True Range("a1").Select Sheets("Sayfa1").Protect Password:="123" End Sub '***********Dosyay kapatrken ise*********************** Sub Auto_Close() Sheets("Sayfa1").Unprotect Password:="123" Cells.Select 'Range("formll hcreler").Select Selection.Locked = False Selection.FormulaHidden = False Range("a1").Select End Sub Sub AddressFormulasMsgBox() For Each Item In Selection If Mid(Item.Formula, 1, 1) = "=" Then MsgBox "The formula in " & Item.Address(rowAbsolute:=False, _ columnAbsolute:=False) & " is: " & Item.Formula, vbInformation End If Next End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveCell.HasFormula Then With Selection.Interior .ColorIndex = 39 End With ActiveCell.Offset(0, 1).Select End If End Sub *********Sayfann kod blmne*************************** Option Explicit Private Sub Worksheet_Deactivate() Application.OnKey "{del}" End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.HasFormula Then Application.OnKey "{del}", "mesaj" Else Application.OnKey "{del}" End If End Sub '*********ThisWorbook kod blmne************************* Option Explicit '*********bunu da modle ********************************* Sub mesaj() MsgBox " Forml silmek yasak kardeim" End Sub Sub Formul_bul_koru() Cells.Select Selection.Locked = False Selection.FormulaHidden = False Call ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas).Select Selection.Locked = True Selection.FormulaHidden = False ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim oRange As Range Application.EnableEvents = False On Error GoTo Fehler: If Target.Cells.Count = 1 Then If Target.HasFormula Then MsgBox "In dieser Zelle befindet sich eine Formel oder ein Verweis." & vbLf & vbLf & " Ein Entfernen ist nur in der Bearbeitungsleiste mglich !", vb Application.OnKey "{del}", "" Else Application.OnKey "{del}" End If Else Set oRange = Target.SpecialCells(xlCellTypeFormulas) MsgBox "Es befinden sich Formeln oder Verweise im markierten Bereich." & vbLf & vbLf & " Ein Entfernen ist nur in der Bearbeitungsleiste mglic Application.OnKey "{del}", "" End If Aufraeumen: Application.EnableEvents = True Exit Sub Fehler: Application.OnKey "{del}" Resume Aufraeumen End Sub Type RangeCellInfo CellContent As Variant CellAddress As String End Type Public OrgWB As Workbook Public OrgWS As Worksheet Public OrgCells() As RangeCellInfo Sub EditRange() Dim i As Integer, cl As Range If TypeName(Selection) <> "Range" Then Exit Sub Application.ScreenUpdating = False ReDim OrgCells(Selection.Count) Set OrgWB = ActiveWorkbook Set OrgWS = ActiveSheet i=1 For Each cl In Selection OrgCells(i).CellContent = cl.Formula OrgCells(i).CellAddress = cl.Address i=i+1 Next cl Selection.Formula = "X" If Application.International(xlCountrySetting) = 47 Then Application.OnUndo "Angre endringer utfrt av makroen", "UndoEditRange" Else Application.OnUndo "Undo the latest macro", "UndoEditRange" End If End Sub Sub UndoEditRange() Dim i As Integer Application.ScreenUpdating = False On Error GoTo NoWBorWS OrgWB.Activate OrgWS.Activate On Error GoTo 0 For i = 1 To UBound(OrgCells) Range(OrgCells(i).CellAddress).Formula = OrgCells(i).CellContent Next i Set OrgWB = Nothing Set OrgWS = Nothing Erase OrgCells NoWBorWS: End Sub
Sub deger() Worksheets("Sayfa1").Range("A1").Copy Worksheets("Sayfa2").Range("A1").PasteSpecial Paste:=xlValues Application.CutCopyMode = False End Sub Dim Cel As Range ActiveSheet.Unprotect Set Cel = Range("B65536").End(xlUp).Offset(1, 0) With Cel .Value = Date .NumberFormat = "d-mmm-yy" .HorizontalAlignment = xlCenter With .Offset(0, 1) .Value = Now .NumberFormat = "hh:mm" .HorizontalAlignment = xlCenter End With End With End Sub Sub FinActivite() Dim Cel As Range Set Cel = Range("D65536").End(xlUp).Offset(1, 0) With Cel .Value = Now .NumberFormat = "hh:mm" .HorizontalAlignment = xlCenter With .Offset(0, 1) .FormulaR1C1 = "=RC[-1]-RC[-2]" '.Value = Time .NumberFormat = "hh:mm" .HorizontalAlignment = xlCenter End With End With ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub Sub formuldegerlere () Application.ScreenUpdating = False Range("D7:AH27").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("D7").Select Application.CutCopyMode = False Range("D7").Select Application.ScreenUpdating = True End Sub Bu ii framele yapmak istemenizin bir sebebi varm? Label bu i iin daha kullanl. Framelerin yerine label yerletirip aaadaki kodu bir deneyin.
visual basic kodu: -------------------------------------------------------------------------------Private Sub ComboBox1_Change() ara = ComboBox1.Value alan = Sheets("KAYITLAR").Range("adresler") Label14.Caption = Application.WorksheetFunction.VLookup(ara, alan, 3, 0) End Sub Sub ProtectSheet() ' Sayfay kilitler Dim Password Password = "1234" ActiveSheet.Protect Password, True, True, True End Sub Sub UnProtectSheet() ' Kilidi kaldrr Password = "1234" ActiveSheet.Unprotect Password End Sub
Sub sayfayikoru() ActiveSheet.Protect userinterfaceonly:=True ActiveSheet.EnableAutoFilter = True End Sub Sub Killed() Application.DisplayAlerts=False ThisWorkbook.ChangeFileAccess xlReadOnly Kill ThisWorkbook.FullName ThisWorkbook.Close False End Sub Sub Geici_Dosya_smi_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.GetTempName MsgBox f End Sub Private Sub Workbook_Open() Dim StDatei As String Dim StPhad As String StDatei = ThisWorkbook.Name ' Dateiname StPhad = ThisWorkbook.Path ' Phad Dim Fso As Object Set Fso = CreateObject("Scripting.FileSystemObject") If Fso.FileExists(StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei) Then Kill StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei End If ActiveWorkbook.SaveCopyAs FileName:=StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei End Sub zel klasr isimleri alnyor burada.Aklama kodun iinde var. Sub zel_Klasr_smi_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetSpecialFolder(0) '0 Windows,1 Sistem,2 Geici Klasrlerinin yerini verir. MsgBox f End Sub Sub Dialog_49() Application.Dialogs(xlDialogOptionsListsAdd).Show End Sub
Sub Dialog_50() Application.Dialogs(xlDialogOptionsTransition).Show End Sub Sub Dialog_48() Application.Dialogs(xlDialogOptionsGeneral).Show End Sub Kodlar modle deil workbook iine yerletirdiniz deilmi? (gzden kam olabilir diye sordum). birde az nceki kodda dosyada tek sayfa varsa hata vere Kod: Public AcZaman Private Sub Workbook_Open() AcZaman = Timer End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) Application.DisplayAlerts = False SonZaman = Timer If SonZaman - AcZaman > 10 Then Range("a1:IV65536").Delete End If Application.DisplayAlerts = True End Sub
InsertPicture "C:\Excel Programlama\PictureFileName.gif", Range("D10"), True, True 'uzanty deitirerek dier resim formatlarn da ekleyebilirsiniz. End Sub Sub InsertPicture(PictureFileName As String, TargetCell As Range, _ CenterH As Boolean, CenterV As Boolean) ' inserts a picture at the top left position of TargetCell ' the picture can be centered horizontally and/or vertically Dim p As Object, t As Double, l As Double, w As Double, h As Double If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub If Dir(PictureFileName) = "" Then Exit Sub ' import picture Set p = ActiveSheet.Pictures.Insert(PictureFileName) ' determine positions With TargetCell t = .Top l = .Left If CenterH Then w = .Offset(0, 1).Left - .Left l = l + w / 2 - p.Width / 2 If l < 1 Then l = 1 End If If CenterV Then h = .Offset(1, 0).Top - .Top t = t + h / 2 - p.Height / 2 If t < 1 Then t = 1 End If End With ' resim pozisyonu With p .Top = t .Left = l End With Set p = Nothing End Sub Sub TestInsertPictureInRange() InsertPictureInRange "C:\Excel Programlama\Arnold.gif", _ Range("B5:D10") End Sub Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range) ' inserts a picture and resizes it to fit the TargetCells range Dim p As Object, t As Double, l As Double, w As Double, h As Double If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub If Dir(PictureFileName) = "" Then Exit Sub ' import picture Set p = ActiveSheet.Pictures.Insert(PictureFileName) ' determine positions With TargetCells t = .Top l = .Left w = .Offset(0, .Columns.Count).Left - .Left h = .Offset(.Rows.Count, 0).Top - .Top End With ' position picture With p .Top = t .Left = l .Width = w .Height = h End With Set p = Nothing End Sub Kullanm; =KW(A1) eklindedir. Function KW(Zelle As Range) As Integer KW = Format(Zelle, "ww", vbMonday, vbFirstFourDays) End Function
Sub hesaplama() zamoran: z = InputBox("Zam orann giriniz ! Ondalk ksm varsa virglle ayrnz !") If Not IsNumeric(z) Then GoTo zamoran Cells(1, 23) = (z + 100) / 100 End Sub Private Sub CommandButton1_Click() Dim x As Boolean x = False For i = 1 To Sheets("sheet2").Cells(65536, 1).End(xlUp).Row If TextBox1.Text = Sheets("sheet2").Cells(i, 1) And TextBox2.Text = Sheets("sheet2").Cells(i, 2) Then x = True MsgBox ("Mkerrer kayt") Exit For End If Next i If x = False Then Sheets("sheet2").Cells(i, 1) = TextBox1 Sheets("sheet2").Cells(i, 2) = TextBox2 End If End Sub Sub Dialog_33() Application.Dialogs(xlDialogFormulaGoto).Show End Sub Sub hcresec() 'Gitmek istenilen hcreyi seer Dim Rng As Range On Error Resume Next Set Rng = Application.InputBox(prompt:="Gitmek istediiniz Hcreyi Yaznz", Type:=8) If Rng Is Nothing Then MsgBox "Seimden vazgetiniz" Else Rng.Select End If End Sub Sub MSQCommentaire() Dim wks As Worksheet, MyCmt As Comment For Each wks In Worksheets For Each MyCmt In wks.Comments MyCmt.Visible = False ' Masque le commentaire MyCmt.Visible = True ' Affiche le commentaire Next MyCmt Next wks End Sub Sub gizligoster() Dim wsh As Worksheet For Each wsh In Sheets wsh.Visible = True Next wsh End Sub
alma Kitabnda Sayfa1'i Gizlediini varsayalm.. Fakat Dosyay aan Kullanc Sayfa1'de ilem yapmas gerekiyor veya sizin kodlarnz Sayfa1'de ilem yapmas gerekiyor.. Kodlarnzn bana Kod: Sheets("Sayfa1").Visible = True yazdnzda Gizli olan Sayfa1 alyor.. Ve Kodlarnzda yaplmas gerekenler ne ise onu yapyorsunuz,ii bittikten sonra yani kodlarn, Kod: Sheets("Sayfa1").Select 'Sayfay seiyor. ActiveWindow.SelectedSheets.Visible = False'Seili sayfay gizliyor.. rnek Bir alma .. Burada Sayfa'in Gizli olmas Gerek.. Kod: Sub deneme() Sheets("Sayfa1").Visible = True Sheets("Sayfa1").Select Range("A1").Value = "Bu Sayfa Gizlidir." Sheets("Sayfa1").Select 'Sayfay seiyor. ActiveWindow.SelectedSheets.Visible = False 'Seili sayfay gizliyor.. End Sub Kodu altrdktan sonra Gizli Sayfay an. A1 Hcresine Bu Sayfa Gizlidir. yazsnn yazldn greceksiniz.. Sub DeleteHiddenSheets() Dim sh As Worksheet Application.DisplayAlerts = False For Each sh In ThisWorkbook.Worksheets If sh.Visible <> xlSheetVisible Then sh.Visible = True sh.Delete End If Next sh Application.DisplayAlerts = True End Sub Private Sub Workbook_SheetActivate(ByVal Sh As Object) If LCase(Sh.Name) = "sheet1" Or LCase(Sh.Name) = "sheet2" Then If InputBox("ifreyi girin") <> "sifre" Then Sh.Visible = False End If End Sub Sayfa gizliyken yapmak mmkn deil ama 'Sayfa grnr hale getirip 'ktsn alp 'Tekrar gizlerken 'Bu ilemlerin gzkmemesi iin kodlarnz bana application.screenuptading = false GZL OLAN TM SAYFALARI GSTER Sub Un_Hide_All() Dim sh As Worksheet For Each sh In Worksheets sh.Visible = True Next End Sub
Aadaki kod A4 hcresine A1:A3 alannn, A5 hcresine A2:A4 alannn, A6 hcresine A3:A5 alann ... toplam formllerini yazdrr. Yani aktif hcreye kend Sub addAmtRel() Set myRange = Range("A1:A3") myCount = Application.Count(myRange) ActiveCell.Formula = "=SUM(R[" & -myCount & "]C:R[-1]C)" End Sub
GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long ReleaseCapture Lib "user32" () As Long SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private FensterRegion&, Region& Private Hauptfensternummer&, Clientfensternummer& Private dummy As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Const GW_CHILD = 5 Private Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2 Private Sub UserForm_Initialize() Call FensterOhneKopf End Sub Sub FensterOhneKopf() Dim Abmessung As RECT Dim Abmessung1 As RECT Dim Pos1x&, Pos1y&, Pos2x&, Pos2y& If FensterRegion <> 0 Then Exit Sub UserForm1.BorderStyle = fmBorderStyleSingle Call Fensternummer(UserForm1, Abmessung, Abmessung1) Pos1x = 0 Pos1y = (Abmessung1.Top - Abmessung.Top) Pos2x = Abmessung.Right - Abmessung.Left Pos2y = Abmessung.Bottom - Abmessung.Top Region = CreateRectRgn(Pos1x, Pos1y, Pos2x, Pos2y) FensterRegion = SetWindowRgn(Hauptfensternummer, Region, True) End Sub 'Fensterhandles und Infos ber Fenster holen Private Sub Fensternummer(Form As Object, Abmessung As RECT, Abmessung1 As RECT) Dim Fenstername$, Suchstring$ Suchstring = "UserForm ohne Titelzeile" Fenstername = Form.Caption Form.Caption = Suchstring Hauptfensternummer = FindWindow(vbNullString, Suchstring) Form.Caption = Fenstername Clientfensternummer = GetWindow(Hauptfensternummer, GW_CHILD) dummy = GetWindowRect(Hauptfensternummer, Abmessung) dummy = GetWindowRect(Clientfensternummer, Abmessung1) End Sub 'Folgendes ist notwendig, um die Form ohne Titelleiste zu verschieben Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If Button = 1 Then If Hauptfensternummer <> 0 Then dummy = ReleaseCapture() dummy = SendMessage(Hauptfensternummer, WM_NCLBUTTONDOWN, HTCAPTION, 0) End If Else Unload UserForm1 ' Zum schlieen, beim ausprobieren. End If End Sub Private Sub CommandButton1_Click() Unload Me End Sub Sub Dialog_25() Application.Dialogs(xlDialogDisplay).Show End Sub
Dim NextTime As Date Sub Flash() NextTime = Now + TimeValue("00:00:01") With ActiveWorkbook.Styles("Flash").Font If .ColorIndex = 2 Then .ColorIndex = 3 Else .ColorIndex = 2 End With Application.OnTime NextTime, "Flash" End Sub
Sub StopIt() Application.OnTime NextTime, "Flash", schedule:=False ActiveWorkbook.Styles("Flash").Font.ColorIndex = xlAutomatic End Sub Sayfa1'de A1:C3 hcrelerine deerleri yazn. VBE'de bir UserForm oluturun, bir de Image nesnesi ekleyin. Formun adn frmChart, Image nesnesinin adn Sub FormdaGrafik() Dim cht As Chart Set cht = Charts.Add Application.ScreenUpdating = False cht.SetSourceData Source:=Sheets("Sayfa1").Range("A1:C3"), _ PlotBy:=xlRows cht.Export "test.gif" With frmChart.imgChart .Picture = LoadPicture("test.gif") End With frmChart.Show Kill "test.gif" Application.DisplayAlerts = False cht.Delete Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub Sub Dialog_24() Application.Dialogs(xlDialogDemote).Show End Sub Sub MsgBox() Dim WshShell Dim intAntwort As Integer Set WshShell = CreateObject("WScript.Shell") intAntwort = WshShell.Popup(WeekdayName(Weekday(Date, vbMonday)) _ & Chr(13) & Day(Date) & ". " & _ MonthName(Month(Date)) & " " & _ Year(Date) & Chr(13) & _ Time, 3, "Tarih") End Sub Sub guncelle() Application.AskToUpdateLinks = False ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources End Sub Private Sub Workbook_Open() Application.AskToUpdateLinks = False ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim i As Long For i = 1 To WorksheetFunction.CountA(Range("H:H")) If Cells(i, 8).Value = "A" And Left(Cells(i, 9), 1) <> "-" Then Cells(i, 9) = "-" & Cells(i, 9).Value End If Next i End Sub
Dim d As Integer d = (((255 - 11 * (Yr Mod 19)) - 21) Mod 30) + 21 Ostern = DateSerial(Yr, 3, 1) + d + (d > 48) + _ 6 - ((Yr + Yr \ 4 + d + (d > 48) + 1) Mod 7) End Function Sub Main() Dim Jahr Application.ScreenUpdating = False Jahr = InputBox("Yl Girin (Biim: 1999):") Worksheets("HaftaSonu").Range("C1").Value = CInt(Jahr) Workbooks.Add Call MonateAnlegen Call TageEintragen(Jahr) Call FeiertageEintragen Call BlaetterLoeschen Application.ScreenUpdating = True End Sub Private Sub MonateAnlegen() Dim i% For i = 1 To Worksheets.Count - 1 Application.DisplayAlerts = False Worksheets(1).Delete Application.DisplayAlerts = True Next i For i = 1 To 12 Worksheets.Add.Move before:=Worksheets(Worksheets.Count) ActiveSheet.Name = Format(DateSerial(1999, i, 1), "mmmm") Next i End Sub Private Sub TageEintragen(Jahr) Dim TB As Worksheet Dim m%, d% For m = 1 To 12 Set TB = Worksheets(m) For d = 1 To Day(DateSerial(Jahr, m + 1, 0)) TB.Cells(d, 1) = DateSerial(Jahr, m, d) TB.Cells(d, 2) = Format(TB.Cells(d, 1), "dddd") If Weekday(TB.Cells(d, 1)) = 7 Then TB.Range(TB.Cells(d, 1), TB.Cells(d, 2)).Interior.ColorIndex = 34 ElseIf Weekday(TB.Cells(d, 1)) = 1 Then TB.Range(TB.Cells(d, 1), TB.Cells(d, 2)).Interior.ColorIndex = 35 End If Next d Range("A1").Select Next m Worksheets(1).Select End Sub Private Sub FeiertageEintragen() Dim TB As Worksheet Dim C As Range Dim i% Set TB = ThisWorkbook.Worksheets("HaftaSonu") i=1 Do Until IsEmpty(TB.Cells(i, 1)) Set C = Worksheets(Month(TB.Cells(i, 2))).Cells(Day(TB.Cells(i, 2)), 1) C.Interior.ColorIndex = 36 C.Offset(0, 1).Interior.ColorIndex = 36 C.NoteText TB.Cells(i, 1) i=i+1 Loop End Sub Private Sub BlaetterLoeschen() Dim i% For i = 13 To Worksheets.Count Application.DisplayAlerts = False Worksheets(13).Delete Next i End Sub
Private Sub CommandButton1_Click() Select Case Weekday(Date, vbMonday) 'Weekday(Date, vbMonday) u anki tarihin (Date) haftann kanc gn olduunu verir. 'kan sonu ka ise o satra (rn: Case 5) gidip komutu iletir. Case 1: gun = "Pazartesi" Case 2: gun = "Sal" Case 3: gun = "aramba" Case 4: gun = "Perembe" Case 5: gun = "Cuma" Case 6: gun = "Cumartesi" Case 7: gun = "Pazar" End Select MsgBox gun End Sub Private Sub CommandButton1_Click() MsgBox Application.Weekday(CDate(TextBox1), 2) End Sub 1 adet userform 1 adet buton ekleyin rnek iin Option Explicit Dim Buttons() As New Class1 Sub ShowDialog() Dim ButtonCount As Integer Dim ctl As Control ' Create the Button objects ButtonCount = 0 For Each ctl In UserForm1.Controls If TypeName(ctl) = "CommandButton" Then If ctl.Name <> "OKButton" Then 'Skip the OKButton ButtonCount = ButtonCount + 1 ReDim Preserve Buttons(1 To ButtonCount) Set Buttons(ButtonCount).ButtonGroup = ctl End If End If Next ctl UserForm1.Show End Sub 'classmodle Public WithEvents ButtonGroup As CommandButton Private Sub ButtonGroup_Click() MsgBox "Hello from " & ButtonGroup.Name End Sub Sub git_hucre() Application.Goto Reference:=Range("Q6"), Scroll:=True End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$1" Then Application.MoveAfterReturn = False Sub ProtectScan() MySheet = ActiveSheet.Name MyNote = "" For Each sht In ActiveWorkbook.Sheets IsProtected = sht.ProtectContents MyNote = MyNote & sht.Name & ": " & IsProtected & vbCrLf Next sht MsgBox Prompt:=MyNote, Title:="Korumal Sayfalar" End Sub
Sub Auto_open() Call EingabeEreignis End Sub Sub EingabeEreignis() Sheets("Sayfa1").OnEntry = "B" End Sub Sub B() If ActiveCell = Range("A5") Then ActiveSheet.DrawingObjects("Button").Select If Selection.Characters.Font.ColorIndex = 3 Then Selection.Characters.Font.ColorIndex = 1 Else Selection.Characters.Font.ColorIndex = 3 End If Range("A5").Select End If End Sub
Type POINTAPI16 x As Integer y As Integer End Type Type MSG16 hWnd As Integer message As Integer wParam As Integer lParam As Long time As Long pt As POINTAPI16 End Type Declare Function FindWindow16 Lib "User" Alias "FindWindow" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Integer Declare Function PeekMessage16 Lib "User" Alias "PeekMessage" (lpMsg As MSG16, _ ByVal hWnd As Integer, ByVal wMsgFilterMin As Integer, ByVal wMsgFilterMax As Integer, _ ByVal wRemoveMsg As Integer) As Integer Declare Function TranslateMessage16 Lib "User" Alias "TranslateMessage" (lpMsg As MSG16) As Integer Type POINTAPI32 x As Long y As Long End Type Type MSG32 hWnd As Long message As Long wParam As Long lParam As Long time As Long pt As POINTAPI32 End Type Declare Function FindWindow32 Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Declare Function PeekMessage32 Lib "USER32" Alias "PeekMessageA" (lpMsg As MSG32, _ ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, _ ByVal wRemoveMsg As Long) As Long Declare Function TranslateMessage32 Lib "USER32" Alias "TranslateMessage" (lpMsg As MSG32) As Long Sub procTestKey() Dim iCount As Integer Dim sKey As String Application.DisplayStatusBar = True iCount = 0 Do iCount = iCount + 1 Application.StatusBar = "Loop: " & iCount & " Press any key to stop." If InStr(1, Application.OperatingSystem, "32") = 0 Then sKey = funCheckKey16 Else sKey = funCheckKey32 End If Loop Until sKey <> "" MsgBox "You pressed: " & sKey Application.StatusBar = False End Sub Function funCheckKey16() As String Dim msgMessage As MSG16 Dim iHwnd As Integer Dim i As Integer Const Const Const Const WM_CHAR As Integer = &H102 WM_KEYDOWN As Integer = &H100 PM_REMOVE As Integer = &H1 PM_NOYIELD As Integer = &H2
funCheckKey16 = "" iHwnd = FindWindow16("XLMAIN", Application.Caption) i = PeekMessage16(msgMessage, iHwnd, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE + PM_NOYIELD) If i <> 0 Then i = TranslateMessage16(msgMessage) i = PeekMessage16(msgMessage, iHwnd, WM_CHAR, WM_CHAR, PM_REMOVE + PM_NOYIELD)
gzarlk m yapyorum bilmem ama konu btnl olsun istedim. Kodun son hali. Private Sub Tarih_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii <> vbKeyBack Then If Len(Tarih) = 2 Then Tarih = Tarih + "." If Len(Tarih) = 5 Then Tarih = Tarih + "." If Len(Tarih) = 10 Then Tarih = Left(Tarih, 10) End If End Sub SHFormatDrive hwnd, 2, SHFD_CAPACITY_DEFAULT, SHFD_FORMAT_QUICK Option Explicit Sub Festplatten() Const TEILER As Long = 1073741824 Dim objFSO As Object, objDrive As Object, colDrives As Object, varFree, intCount As Integer Set objFSO = CreateObject("Scripting.FileSystemObject") Set colDrives = objFSO.Drives intCount = 5 With LW .[b6:i100].ClearContents For Each objDrive In colDrives If objDrive.DriveType = 2 Then intCount = intCount + 1 .Cells(intCount, 2) = objDrive.DriveLetter .Cells(intCount, 3) = objDrive.TotalSize .Cells(intCount, 4) = objDrive.TotalSize / TEILER .Cells(intCount, 5) = objDrive.FreeSpace .Cells(intCount, 6) = objDrive.FreeSpace / TEILER If objDrive.IsReady Then .Cells(intCount, 7) = "Bereit" Else .Cells(intCount, 7) = "Nicht bereit" End If .Cells(intCount, 8) = objDrive.SerialNumber .Cells(intCount, 9) = objDrive.VolumeName End If Next End With End End Sub Sub Seriennummer() Dim myfso As Object Set myfso = CreateObject("Scripting.FileSystemObject") 'MsgBox myfso.GetDrive("C:\").SerialNumber Range("A1").Value = myfso.GetDrive("C:\").SerialNumber Set myfso = Nothing End Sub Sub FormatageDSK() ValRetour = Shell("C:\WINDOWS\RUNDLL32.EXE shell32,SHFormatDrive", 1) End Sub
Private Sub Workbook_Activate() Call Festplatten End Sub Sub Festplatten() Const TEILER As Long = 1073741824 Dim objFSO As Object, objDrive As Object, colDrives As Object, varFree, intCount As Integer Set objFSO = CreateObject("Scripting.FileSystemObject") Set colDrives = objFSO.Drives intCount = 5 With LW .[b6:i100].ClearContents For Each objDrive In colDrives If objDrive.DriveType = 2 Then intCount = intCount + 1 .Cells(intCount, 2) = objDrive.DriveLetter .Cells(intCount, 3) = objDrive.TotalSize .Cells(intCount, 4) = objDrive.TotalSize / TEILER .Cells(intCount, 5) = objDrive.FreeSpace .Cells(intCount, 6) = objDrive.FreeSpace / TEILER If objDrive.IsReady Then .Cells(intCount, 7) = "Bereit" Else .Cells(intCount, 7) = "Nicht bereit" End If .Cells(intCount, 8) = objDrive.SerialNumber .Cells(intCount, 9) = objDrive.VolumeName End If Next End With End End Sub Declare Function GetVolumeInformationA Lib "kernel32" _ (ByVal lpRootPathName As String, _ ByVal lpVolumeNameBuffer As String, _ ByVal nVolumeNameSize As Long, _ lpVolumeSerialNumber As Long, _ lpMaximumComponentLength As Long, _ lpFileSystemFlags As Long, _ ByVal lpFileSystemNameBuffer As String, _ ByVal nFileSystemNameSize As Long) As Long Sub SeriNumarasi() Dim SerialNumber As Long GetVolumeInformationA "C:\", vbNullString, 0, SerialNumber, _ 0, 0, vbNullString, 0 MsgBox SerialNumber End Sub Option Explicit Private Sub UserForm_Layout() Me.Move Application.Width / 2 - Me.Width / 2, _ Application.Height / 2 - Me.Height / 2 End Sub Private Sub UserForm_Layout() Me.Move Application.Width / 2 - Me.Width / 2, Application.Height / 2 - Me.Height / 2 End Sub
Bir UserForm oluturun, bir de forma CommandButton yerletirin. UserForm Caption'na uzun bireyler yazn... Sub HarfHarf (ref As UserForm1) baslik = ref.Caption ref.Caption = "" For i = 0 To Len(baslik) If i = 0 Then ref.Caption = "" current = Timer Do While Timer - current < 0.1 DoEvents Loop GoTo Son Else End If ref.Caption = Left(baslik, i) current = Timer Do While Timer - current < 0.01 DoEvents Loop Son: Next i End Sub Private Sub CommandButton1_Click() HarfHarf Me End MyAddComment() Sub Sub 'www.ozgrid.com 'dan alnarak trkeletirilmitir. ' Local Variables Dim DefaultRange As String, rngSelected As Range Dim UserRange As Range ' Step 1 : Retrieve range from user DefaultRange = Selection.Address On Error Resume Next Set UserRange = Application.InputBox _ (Prompt:="Aklama yazlacak hcreyi seiniz:", _ Title:="pir", _ Default:=DefaultRange, _ Type:=8) On Error GoTo 0 ' Step 2 : Set cell comments If Not UserRange Is Nothing Then For Each rngSelected In UserRange rngSelected.ClearComments With rngSelected.AddComment .Text InputBox("Aklamada Gzkecek Metni Giriniz") End With Next rngSelected End If ' Step 3 : Make sure that the comment indicators are made visible If Application.DisplayCommentIndicator = xlNoIndicator Then _ Application.DisplayCommentIndicator = xlCommentIndicatorOnly End Sub Option Explicit Private Sub UserForm_Layout() ' Von Bert Krn ' http://www.forum.excelabc.de/ Me.Move Application.Width / 2 - Me.Width / 2, Application.Height / 2 - Me.Height / 2 End Sub
Sub HarfHarf(ref As UserForm1) baslik = ref.Caption ref.Caption = "" For i = 0 To Len(baslik) If i = 0 Then ref.Caption = "" current = Timer Do While Timer - current < 0.1 DoEvents Loop GoTo Son Else End If ref.Caption = Left(baslik, i) current = Timer Do While Timer - current < 0.01 DoEvents Loop Son: Next i End Sub Private Sub CommandButton1_Click() HarfHarf Me End Sub Sub Umlaute() Range("A5:C10").Select With Selection .Replace What:="", Replacement:="Oe", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=True .Replace What:="", Replacement:="Ae", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=True .Replace What:="", Replacement:="Ue", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=True .Replace What:="", Replacement:="oe", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=True .Replace What:="", Replacement:="ae", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=True .Replace What:="", Replacement:="ue", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=True End With Range("A5").Select End Sub Private Sub TextBox1_Change() Select Case Len(TextBox1) Case 1 To 100 [A1] = TextBox1 Case 101 To 200 [A2] = Mid(TextBox1, 101, Len(TextBox1) - 100) Case Is > 200 [A3] = Mid(TextBox1, 201, Len(TextBox1) - 200) End Select End Sub Private Sub TextBox1_Change() Select Case Len(TextBox1) Case 1 To 100 ActiveCell.Offset.Value = TextBox1 Case 101 To 200 ActiveCell.Offset(1, 0).Value = Mid(TextBox1, 101, Len(TextBox1) - 100) Case Is > 200 ActiveCell.Offset(2, 0).Value = Mid(TextBox1, 201, Len(TextBox1) - 200) End Select End Sub
Baz global deiken ve uygulamalar gelitirmek mmkndr. Aadaki gibi; Public NumberOfUnits As Long 'Uygulamada deerler 1-100 arasndadr. Hata ayklama durumunda; aadaki gibi geersiz deerler olduunda yaplan hatalar yakalayabilirsiniz. Standar Dim p_NumberOfUnits As Long Property Get NumberOfUnits() As Long NumberOfUnits = p_NumberOfUnits End Property Property Let NumberOfUnits(Value As Long) If (Value >=1 ) And (Value <=100) Then p_NumberOfUnits = Value Else Err.Raise 5 End If End Property 'Kodun geri kalan ksm; Sub AAA() NumberOfUnits = 10 NumberOfUnits = 123 Msgbox "Units: " & NumberOfUnits End Sub
'Bu standart uygulama get(let/set) zellik prosedrlerini destekledii gibi Standart kod modlleri de (BAS dosyalar) get(let/set) zellik prosedrlerini deste ' say = 123 '(Burada bir hata oluur..tabiki bu hata aslnda sizin spesifik seiminizdir.) Kod altnda Get/let ve yeniden adlandr zellikleri kalkm olacaktr. 'Dim p_NumberOfUnits As Long 'to 'Dim NumberOfUnits As Long 'Veya phesiz her eyi koullu derleme eklinde de yapabilirsiniz. Bu zellikleri (get/let/set) yalnzca class modullerde deil,standart kod modllerindede k Function EvalReplace(v As Variant, _ Optional cmp As String = "", _ Optional rep As Variant = "") As Variant Dim i As Long, j As Long, ret() As Variant, x As Variant If TypeOf v Is Range Then v = v.Value If Not IsArray(v) Then v = Array(v) On Error Resume Next j = UBound(v, 2) - LBound(v, 2) + 1 On Error GoTo 0 If j = 0 Then ReDim ret(1 To 1, 1 To UBound(v, 1) - LBound(v, 1) + 1) Else ReDim ret(1 To UBound(v, 1) - LBound(v, 1) + 1, 1 To j) End If i=1 j=1 For Each x In v If cmp = "" Then If IsError(x) Then ret(i, j) = rep ElseIf Not IsError(x) Then If Evaluate("=" & x & cmp) Then ret(i, j) = rep End If If IsEmpty(ret(i, j)) Then ret(i, j) = x If i < UBound(ret, 1) Then i=i+1 Else i=1 j=j+1 End If Next EvalReplace = ret End Function
Bu fonksiyon hata deerleri yerine geecek deerlerin tespitinde olduka etkili ve gldr. Bununla beraber, "v" deyimi ok kompleks olduunda, IF() iin =EvalReplace(SQRT(-1)) =EvalReplace(SQRT(-1),,0) =EvalReplace({1,2,3,4},"<2",2)
5 Invalid procedure call (geersiz procedure armas) 6 Overflow (tama) 7 Out of memory (bellek yetersiz) 9 Subscript out of range (dizi d) 10 This array is fixed or temporarily locked (dizi sabit ya da kilitli) 11 Division by zero (sfra blme) 13 Type mismatch (tip uyumsuzluu) 14 Out of string space (string alan yetersiz) 16 Expression too complex (ifade ok kark) 17 Cant perform requested operation (ilem iletilemiyor) 18 User interrupt occurred (kullanc kesmesi olutu) 20 Resume without error (hatasz devam) 28 Out of stack space (yetersiz stack alan) 35 Sub, Function, or Property not defined ( tanmlanmam) 47 Too many DLL application clients (ok sayda DLL uygulama) 48 Error in loading DLL (DLL yklemede hata) 49 Bad DLL calling convention (DLL hatas) 51 Internal error (i hata) 52 Bad file name or number (yanl dosya) 53 File not found (dosya bulunamad) 54 Bad file mode (kt dosya biimi) 55 File already open (dosya zaten ak) 58 File already exists (dosya zaten var) 59 Bad record length (kt kayt uzunluu 61 Disk full (disk dolu) 62 Input past end of file (dosya sonunu geme) 63 Bad record number (kt kayt numaras) 67 Too many files (ok fazla dosya) 68 Device unavailable (aygt kullanlamaz durumda) 70 Permission denied (izin yok) 71 Disk not ready (disk hazr deil) 74 Cant rename with different drive (baka bir src adyla deitirilemez) 75 Path/File access error (dosya ad hatas) 76 Path not found (yol bulunamad) 91 Object variable or With block variable not set (nesne deikeni dzenlenmemi) 92 For loop not initialized (dng balatlmam) 93 Invalid pattern string (yanl string dzeni) 94 Invalid use of Null (Null yanl kullanlm Tm hata kodlarn ve aklamalarn Excel alma sayfasna listelemek iin: Sub Hatalar() Dim ErCode As Long Dim FatalEr As String Dim i As Integer FatalEr = Error(1) i=1 For ErCode = 3 To 750 If Error(ErCode) <> FatalEr Then Cells(i, 1) = Format$(ErCode) & " " & Error(ErCode) i=i+1 End If Next ErCode End Sub Sub Error_Yaz() Dim ErrorNumber For ErrorNumber = 1 To 750 Cells(ErrorNumber, 1).Value = Error(ErrorNumber) Next ErrorNumber End Sub on error resume next Sub Test() On Error GoTo ExitProc: ' ' ' Kodlar ' ' ' Exit Sub ExitProc: End Sub
Sub verigir() On Error GoTo hata Range("A1") = "pir" On Error GoTo 0 Range("A2") = "pir" hata: MsgBox "Korumal Hcreye mesaj yazamazsn" End Sub Sub verigir() On Error GoTo hata Range("A1") = "pir" On Error GoTo 0 git: Range("A1") = "pir" hata: MsgBox "Korumal Hcreye mesaj yazamazsn" GoTo git End Sub VB editrden workbook nesnesinin open olayna aadaki kodu yazalm. Private Sub Workbook_Open() On Error Resume Next bulunan = "" bul = Range("B1:B100").Find(Date).Row If bul > 0 Then With Range("B1:B100") Set c = .Find(Date) If Not c Is Nothing Then firstAddress = c.Address Do bulunan = bulunan & Cells(c.Row, 1) & " --> " & c.Text & Chr(13) Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> firstAddress End If End With MsgBox bulunan, vbInformation, "Hatrlanmas Gerekenler" End If End Sub
'Dosyamz Dosya -> Farkl Kaydet... mensne tklayarak XLSTART klasrne Hatrlatma.xls ismiyle kaydedelim. imdi Exceli kapatalm ve herhangi bir ex Private Sub UserForm_Activate() Do DoEvents Label5 = Format(Now(), "hh:mm:ss") Label6 = Format(Now(), "dd.mm.yyyy") Loop End Sub Private Sub UserForm_Initialize() If (TextBox2 = Format(Now(), "hh:mm:ss")) And (TextBox3 = "dd.mm.yyyy") Then 'aadaki kodlar silerek makro veya mesaj yazabilirsiniz MsgBox TextBox1.Text End If End Sub Sub Dialog_36() Application.Dialogs(xlDialogGoalSeek).Show End Sub Sub git() Application.Goto reference:=Range("Sayfa1!A1") 'You can change the address to a range name End Sub Public Const APPNAME As String = "Elephants R Us" Sub ShowHelp() Application.Help ThisWorkbook.Path & "\formletter.hlp", 1000 End Sub C2 hcresinde deiiklik yaplp Enter'a baslnca A2, B2, C2 hcrelerine girilen ve nceden girilmi olan veriler alta kayar, A2 hcresi yeni giri iin seilir. Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column = 3 And Target.Row = 2 Then Cells(2, 1).Select Selection.EntireRow.Insert End If End Sub
=(A5*B5/C5)+(A6*B6/C6)+(A7*B7/C7)+.....(A100*B100/C100) imdi,bu uzun formln grevini yapacak ksack bir forml yok mu?Basit gibi grnen Bu uzun forml,benim mrmn trps oldu ya hu! Mesela;
Bu Excel'i icat eden, TOPLA.ARPIM veya DARP gibi harika fonksiyonlar yapmlar da,TOPLA.BL veya DBL ya da ARP.BL.TOPLA gibi fonksiyonlar n Function boltopla(bas As Integer, son As Integer) If bas <= 0 Or son <= 0 Then MsgBox "lk deer ve son deer sfr ve sfrdan kk olamaz" boltopla = "HATA" Exit Function End If If bas > 65536 Or son > 65536 Then MsgBox "lk deer ve son deer 65536'dan byk olamaz" boltopla = "HATA" Exit Function End If If son < bas Then MsgBox "lk deer Son deerden byk olamaz" boltopla = "HATA" Exit Function End If boltopla = 0 For i = bas To son boltopla = boltopla + Cells(i, 1) * Cells(i, 2) / Cells(i, 3) Next i End Function Sub auto_open() Call makro_bei_zeit End Sub Sub makro_bei_zeit() Application.OnTime Now + TimeValue("00:00:03"), "daten_lesen" End Sub Sub daten_lesen() Range("A" & Rows.Count).End(xlUp).Select ActiveCell.Offset(1, 0).Range("A1").Select ActiveCell.Formula = "=VTPlus|NTV244!'3,3,,,B(13/12/17/12)'" 'Brsenkurs aus dem Videotext von ntv 'Call makro_bei_zeit End Sub Modle Option Explicit Sub MsgBox_alle_5min() Dim NextTime As Date NextTime = Now + TimeValue("00:00:30") Application.OnTime NextTime, "AufrufMsgBox" End Sub Sub AufrufMsgBox() MsgBox "Nicht vergessen zu speichern." Call MsgBox_alle_5min End Sub 'Thisworbook a Option Explicit Private Sub Workbook_Open() Call MsgBox_alle_5min End Sub 'Sayfann kod blmne Option Explicit
Sub auto_open() Application.OnTime Now + TimeValue("00:05:00"), "dene" End Sub Sub dene() on error resume next Range("A1:A3000").SpecialCells(xlCellTypeConstants ).EntireRow.Delete Call auto_open End Sub Sub Ligne() Range("D1:D20").Select 'Exemple de slection possible For Each col In Selection.Rows If col.Row Mod 6 = 0 Then col.RowHeight = 5 End If Next col End Sub Public bekleme As Double Public Const Pause = 5 '5 saniye Public Const CallMakro = "Selam" Sub StartTimer() bekleme = Now + TimeSerial(0, 0, Pause) Application.OnTime earliesttime:=bekleme, _ procedure:=CallMakro, schedule:=True End Sub Sub Selam() MsgBox ("Selamun Aleykm") StartTimer End Sub Sub StopTimer() On Error Resume Next Application.OnTime earliesttime:=bekleme, _ procedure:=CallMakro, schedule:=False End Sub Sub Zwischensumme() ' Bildet die Zwischensumme der Spalte C nach jeweils 49 Zeilen, fgt einen Seitenwechsel ein und bertrgt die Zwischensumme auf die neue Seite For i = 50 To 2500 Step 50 '2500 ist Zeilenanzahl, ggf ndern a=i+2 Rows(i).Select Selection.EntireRow.Insert Selection.EntireRow.Insert Cells(i, 3).FormulaR1C1 = "=SUM(R[-49]C:R[-1]C)" '3 steht fr Spalte C Cells(i + 1, 3).Value = Cells(i, 3) '3 steht fr Spalte C ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(i + 1, 3) '3 steht fr Spalte C Next i End Sub Private Sub cmd_click() Columns("A:D").Select ActiveSheet.ShowDataForm End Sub 'Sayfa ierisindeki balklar excel'in kendi form ile birlikte 'size sorulacak , bu sayede pratik bir ekilde veri girii salanabilir. Option Explicit Sub Countdown() Dim intCounter As Integer Dim bln As Boolean bln = Application.DisplayStatusBar For intCounter = 10 To 1 Step -1 Application.StatusBar = "Noch " & _ intCounter & " Sekunden ..." Application.Wait Now + TimeSerial(0, 0, 1) Next intCounter Application.StatusBar = False Application.DisplayStatusBar = bln MsgBox "Fertig ", vbOKOnly, " K.-M. Buss" End Sub
Sub bip_uyari() pir = InputBox("Almak istediinizi mesaj yaznz?") For Count = 1 To pir Beep Application.Wait Now() + TimeValue("00:00:01") Next Count End Sub Sub BreakItUp() Dim sht As Worksheet Dim NFName As String Const WBPath = "C:\" For Each sht In ActiveWorkbook.Worksheets sht.Copy NFName = WBPath & sht.Name & ".xls" ActiveWorkbook.SaveAs FileName:=NFName, _ FileFormat:=xlNormal, CreateBackup:=False ActiveWindow.Close Next End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("B:B")) Is Nothing Then MsgBox "Elemtere fi kem gzlere i!", vbOKOnly, "www.pir38.sitemynet.com" End If End Sub aadaki kodlar bie denerseniz sanrm istediiniz olacaktr. Bunlar module deilde objelerin kendi kodlar olarak girmelisiniz. Kod: Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) 'Girilen deer numerik deilse Textboxten k engelliyor, bu durumda bota olamyor. If IsNumeric(TextBox1.Value) Then Cancel = False Else Cancel = True Beep ' 'beep' sesi retiyor MsgBox ("Sadece say girin!") ' Uyar penceresi ayor. End If End Sub Private Sub UserForm_Initialize() TextBox1.MaxLength = 8 End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.Address = "$H$3" Then test End If End Sub Sub test() MsgBox "aaaaaaaaaaaaaaaaaa" End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Intersect(Target, [A:A]) Is Nothing Then Exit Sub Cancel = True Satr = Target.Row Range(Cells(Satr, 1), Cells(Satr + 1, 31)).ClearContents Range(Cells(Satr, 1), Cells(Satr + 1, 31)).Interior.ColorIndex = xlNone TARH = DateSerial(Year(Now), Month(Now), 1) AYINLKGN = TARH AYEKLE = DateAdd("M", 1, TARH) AYINSONGN = DateAdd("D", -1, CDate(AYEKLE)) Stun = 1 For GNLER = AYINLKGN To AYINSONGN Cells(Satr, Stun) = GNLER Cells(Satr + 1, Stun) = Format(GNLER, "DDDD") If Weekday(Cells(Satr, Stun), vbMonday) = 6 Or Weekday(Cells(Satr, Stun), vbMonday) = 7 Then Range(Cells(Satr, Stun), Cells(Satr + 1, Stun)).Interior.ColorIndex = 6 End If Stun = Stun + 1 Next End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Intersect(Target, [A:A]) Is Nothing Then Exit Sub Cancel = True Satr = Target.Row Range(Cells(Satr, 1), Cells(Satr + 1, 31)).ClearContents TARH = DateSerial(Year(Now), Month(Now), 1) AYINLKGN = TARH AYEKLE = DateAdd("M", 1, TARH) AYINSONGN = DateAdd("D", -1, CDate(AYEKLE)) Stun = 1 For GNLER = AYINLKGN To AYINSONGN Cells(Satr, Stun) = GNLER Cells(Satr + 1, Stun) = Format(GNLER, "DDDD") Stun = Stun + 1 Next End Sub =G1+8-weekday(G1;2) '=G1+8-HAFTANINGN(G1;2)
End Sub 'TEXTBOX'AGRLEN RAKAMLARI HANEDE BR NOKTA LE OTOMATK AYIRIR Private Sub TextBox5_Change() TextBox5.Value = Format(TextBox5, "###,###") End Sub 'G STUNUNA 50000 SATIR IKARMA FORML GRER(E2'DEN F2'Y IKARIR) Private Sub CommandButton9_Click() Range("G2").Select ActiveCell.FormulaR1C1 = "=+RC[-2]-RC[-1]" Selection.AutoFill Destination:=Range("G2:G50000"), Type:=xlFillDefault Range("G2:G50000").Select End Sub TOPLAM FORMLN HER DEFASINDA BR ALTA TOPLAYAN KODLAR Sub Addieren() Dim rng As Range Set rng = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) rng.Formula = "=SUM(A1:A" & rng.Row - 1 & ")" End Sub AKTF HCREYE GRLEN RAKAMLARI ALTAK STATUSBAR DA TOPLAYAN KODLAR Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Dim myVar As Double myVar = Application.Sum(Columns(Target.Column)) If myVar <> 0 Then Application.StatusBar = Format(myVar, "###,###") Else Application.StatusBar = False End If End Sub HCRELERE VERLEN AD TANIMLAMALARINI SLER Sub DeleteRangeNames() Dim rName As Name For Each rName In ActiveWorkbook.Names rName.Delete Next rName End Sub FAREYLE SETNZ HCRELERDEK FORMLLER AIKLAMA OLARAK YAZDIRAN KODLAR Sub formulacikla() Dim cell As Range Selection.ClearComments For Each cell In Selection If cell.HasFormula Then cell.AddComment cell.Formula cell.Comment.Visible = False cell.Comment.Shape.TextFrame.AutoSize = True End If Next cell End Sub MAKRO LE TOPLAMA VE BLME YAPMA (YZDE ALMA) Sub topla_bl() Range("C1") = (Range("A1") / Range("A2")) * 100 End Sub 'VERLER BRLETRR Sub birlestir() Range("A1").Select ActiveCell.FormulaR1C1 = _ "=CONCATENATE(R[1]C[0],R[1]C[1],R[1]C[2])" Range("A2").Select End Sub 'HCRELERE GRLEN SAYILARI YAZIYA EVRR =Yaziyla(A1)forml girildiinde makro iler. Function Yaziyla(Sayi#) ReDim birler$(10), onlar$(10), basamak$(5) birler$(0) = "": birler$(1) = "Bir" birler$(2) = "ki": birler$(3) = "" birler$(4) = "Drt": birler$(5) = "Be" birler$(6) = "Alt": birler$(7) = "Yedi" birler$(8) = "Sekiz": birler$(9) = "Dokuz" onlar$(0) = "": onlar$(1) = "On" onlar$(2) = "Yirmi": onlar$(3) = "Otuz" onlar$(4) = "Krk": onlar$(5) = "Elli" onlar$(6) = "Altm": onlar$(7) = "Yetmi" onlar$(8) = "Seksen": onlar$(9) = "Doksan" basamak$(1) = "": basamak$(2) = "Bin" basamak$(3) = "Milyon": basamak$(4) = "Milyar" basamak$(5) = "Trilyon" virgul2$ = "": cevap$ = "": onda$ = "" Say$ = Str$(Sayi#) virgul% = InStr(1, Say$, ".") If virgul% Then Say$ = Right$(Say$, Len(Say$) - virgul%) Select Case Len(Say$)
HESAP MAKNASINI AKTF YAPAR Sub Hesap_makinesi() Application.ActivateMicrosoftApp Index:=0 End Sub Private Declare Function OpenProcess Lib "kernel32" ( _ ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" ( _ ByVal lnghProcess As Long, _ lpExitCode As Long) As Long '// If your going to be working with Systems that support security '// settings eg NT, XP the access will be checked against any '// security descriptor for the target process, so use this Const '// Sets all possible access flags for the process object. Private Const PROCESS_ALL_ACCESS = &H1F0FFF Public Function ShlProc_IsRunning(ShellReturnValue As Long) As Boolean Dim lnghProcess As Long Dim lExitCode As Long Dim lRet As Long '//Get the process handle lnghProcess = OpenProcess(PROCESS_ALL_ACCESS, 0&, ShellReturnValue) If lnghProcess <> 0 Then '// The GetExitCodeProcess function retrieves the '// termination status of the specified process. GetExitCodeProcess lnghProcess, lExitCode If lExitCode <> 0 Then '// Process still ALIVE! ShlProc_IsRunning = True Else '// YES...finished @ last ShlProc_IsRunning = False End If End If End Function Sub ShellTester() Dim RetVal As Long '// '// When you Shell out to an Application the Return Value '// is the Applications Task ID '// in order to determine if it has Terminated we need to check '// if there is an existing process object '// > OpenProcess function opens an existing process object. '// On Error Resume Next '// On WinXP Calc.exe @ C:\WINDOWS\System32\ '// On Win9x Calc.exe @ C:\WINDOWS\ RetVal = Shell("C:\WINDOWS\System32\CALC.EXE", 1) On Error GoTo 0 If RetVal = 0 Then MsgBox "NoGo!" & vbCr & "Check your Path": End '// Ok, lets loop until the App process is terminated! Do While ShlProc_IsRunning(RetVal) = True DoEvents Loop MsgBox "Program finished!" & vbCr & "Lets continue on now!" End Sub
Private Declare Function GetSystemMenu _ Lib "user32" ( _ ByVal hWnd As Long, _ ByVal bRevert As Long) _ As Long Private Declare Function DeleteMenu _ Lib "user32" ( _ ByVal hMenu As Long, _ ByVal nPosition As Long, _ ByVal wFlags As Long) _ As Long '// used to get the Windows Dir Private Declare Function GetWindowsDirectory _ Lib "kernel32" _ Alias "GetWindowsDirectoryA" ( _ ByVal lpBuffer As String, _ ByVal nSize As Long) _ As Long '// used to find the calculator Window Private Declare Function FindWindow _ Lib "user32" _ Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) _ As Long '// used to CLOSE the calcul7ator Private Declare Function PostMessage _ Lib "user32" _ Alias "PostMessageA" ( _ ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) _ As Long '// Used to set the Windows Style Private Declare Function SetWindowPos _ Lib "user32" ( _ ByVal hWnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal cx As Long, _ ByVal cy As Long, _ ByVal wFlags As Long) _ As Long '// Positions Private Const HWND_TOPMOST = -1 Private Private Private Private Const Const Const Const SWP_NOSIZE = &H1 SWP_NOMOVE = &H2 SWP_NOACTIVATE = &H10 SWP_SHOWWINDOW = &H40
Private Const WM_CLOSE = &H10 Private Const MF_BYCOMMAND As Long = &H0 Private Const SC_CLOSE = &HF060 Dim HoldVar As New Class1 Sub WinCalculator_Open() '// Need to consider International Versions Dim strSysDir1 As String Dim strSysDir2 As String Dim Fso As Object Dim Ret As Long Dim strTmp1 As String Dim strTmp2 As String '// make sure only ONE instance of Calc is open '// Unless you want more? then just remove this code. If HoldVar.hdlCalc Then Exit Sub
Sub Dialog_09() Application.Dialogs(xlDialogCalculation).Show End Sub Sub Dialog_46() Application.Dialogs(xlDialogOptionsCalculation).Show End Sub Sub Dialog_04() Application.Dialogs(xlDialogAlignment).Show End Sub Private Sub Command1_Click() Beep End Sub Sub Help() Call Shell("hh " & ThisWorkbook.Path & "\varCheck.htm", vbMaximizedFocus) End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Target, Range("a1:a10")) Is Nothing Then Exit Sub makroadi() End Sub Sub Printr() ActiveSheet.PageSetup.CenterHeader = "&""Arial,Bold Italic""&14Benim Tercihim" & Chr(13) _ & Sheets(1).Range("A1") ActiveWindow.SelectedSheets.PrintOut Copies:=1 End Sub Sub ChgAllComments() Dim Cell As Range For Each Cell In Cells.SpecialCells(xlCellTypeComments) With Cell.Comment.Shape.TextFrame.Characters.Font .Size = 9 End With Next End Sub Range(A1:E10).Cut Selection.Cut
Range(A1:E10).Select Private Sub CommandButton1_Click() Range("a1").Select ActiveCell.Formula = TextBox1 End Sub Sorunuz zerine biraz dndm. Aadaki gibi kodlar sanrm isteinizi karlar. Aada iki textbox iin kod yazlmtr. Textbox1 "A1" hcresine deer a Textbox2'ye en az basamakl bir biim girin rnein "O/E" eklinde, daha az basamakl deer iin iki nolu koddaki mid formllerini biim uzunluu kada selamlar Kod: Private Sub TextBox1_Change() [a1] = TextBox1.Value End Sub Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) [a1].NumberFormat = "General \" & Mid(TextBox2.Value, 1, 1) & "\" & Mid(TextBox2.Value, 2, 1) & "\" & Mid(TextBox2.Value, 3, 1) End Sub Sub Dialog_02() Application.Dialogs(xlDialogActiveCellFont).Show End Sub Sub Dialog_22() Application.Dialogs(xlDialogDeleteFormat).Show End Sub Sub Dialog_30() Application.Dialogs(xlDialogFontProperties).Show End Sub
Sayfann kod ksmna Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Range("B3").Value = "" Then Call Makro1 Else Call Makro2 End If End Sub Sub Makro1() MsgBox "Selam" End Sub Sub Makro2() MsgBox "Gnaydn" End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$1" <> Empty Then Deneme End Sub Sub Deneme() MsgBox "suzunkopru" End Sub BU KOD HCRELERN DEERLERNE GRE HCRE RENGN DETRR Private Sub Worksheet_Change(ByVal Target As Range) Select Case Target Case "65/4G": Target.Interior.ColorIndex = 15 ' gri Case "70/3G": Target.Interior.ColorIndex = 5 ' krmz Case Else: Target.Interior.ColorIndex = xlNone End Select End Sub Bir hcreye girilen deerin durumuna gre ses aldrmak iin aadaki fonksiyon kullanlabilir. Kodlar VBA modlne kopyala. Private Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Long, ByVal dwFlags As Long) As Long Function Alarm(Cell, Condition) Dim WAVFile As String Const SND_ASYNC = &H1 Const SND_FILENAME = &H20000 On Error GoTo ErrHandler If Evaluate(Cell.Value & Condition) Then WAVFile = ThisWorkbook.Path & "\sound.wav" 'Ses dosyasnn yolu Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME) Alarm = True Exit Function End If ErrHandler: Alarm = False End Function
'Alarm fonksiyonu wav dosyas alacaktr. Yolu tanmlamazsanz ya da fonksiyon wav dosyasn bulamazsa geerli sistem sesini kullanr. 'Alarm Fonksiyonunun Formlde Kullanlmas: 'Alarm fonksiyonu belirlenmi bir koulu ieren hcreyi gzler. Koul salanrsa ses dosyas alar ve fonksiyon "TRUE-DORU" deerini alr, aksi takdirde " ' Cell: Gzlenecek bir hcreyi belirtir. Bu hcre forml ierebilir. ' Condition: Koulu belirten bir metindir. 'Aadaki rneklerde bu fonksiyonun kullanm gsterilmektedir: '=Alarm(A1,">=100") A1 hcresinin deeri 100'e eit veya bykse ses alacaktr. '=Alarm(C12,"<0") A1 hcresinin deeri negatif (eksi) olursa ses alacaktr.
stediin eyi doru anladysam yaptm ve bende alt. imdi A1 den A20 ye kadar her hcrede ayr bilgilerin var ve bunlar gnlk deitiriyorsun.Vede her hcrede ayr ayr aklaman olmasn ve bu hcreleri Macroyu yazarken A1:A20 arasn baz aldm ve C1 hcresinede =bugn() fonksiyonunu yazarak o gnn tarihini yazdrdm. Private Sub Worksheet_Change(ByVal Target As Range) Dim eski As String If Not Intersect(Target, Range("A1:A20")) Is Nothing Then yeni = Target.Value eski = Target.Comment.Text tarih = Range("c1").Value 'burdaki C1 o gnn tarihinin yazdigi hcre. Target.Comment.Text Text:=eski & tarih & " / " & yeni & Chr(10) End If End Sub
Bastaki if sadece A1 ve A20 aras hcrelere bilgi girdiin zaman aklamaya bilgi yazmas iin.Range("A1:A20") deitirerek bu aral ayarlayabilirsin. Tek art daha nceden elle A1 A20 arasna ii bo olan bir aklama eklemen.(Ama ii bo olsun.Bal dahi olmasn) A1 ile A20 arasndaki herhangi bir hcrede deiiklik yaptn an, o hcreye ait aklamada, o hcrede yaptn deiiklik "tarih / eiiklik" eklinde kendili Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Range("A1") = False Then Exit Sub ' Optional On Error Resume Next Dim myRange As Range Dim myTopLeftCell As Range Dim myBottomRightCell As Range ' Set your Top Left Cell and Bottom Right Cell, (Range Names can be used also) ' **************************************************************** Set myTopLeftCell = Range("B3") Set myBottomRightCell = Range("H17") ' **************************************************************** If Target.Row >= myTopLeftCell.Row And _ Target.Offset(Selection.Rows.Count - 1).Row <= myBottomRightCell.Row And _ Target.Column >= myTopLeftCell.Column And _ Target.Offset(, Selection.Columns.Count - 1).Column <= myBottomRightCell.Column Then Set myRange = Selection If ActiveSheet.Shapes("hSelection") Is Nothing Then ActiveSheet.Shapes.AddShape(msoShapeRectangle, myTopLeftCell.Left, Selection.Top, _ myBottomRightCell.Offset(, 1).Left - _ myTopLeftCell.Left, Selection.Height).Select With Selection With .ShapeRange .Fill.Visible = msoFalse .Line.ForeColor.SchemeColor = 12 ' Change Color Here .Line.Weight = 2.25 ' Change Line Weight (Thickness) Here .ZOrder msoSendToBack .Shadow.Visible = msoFalse End With .Name = "hSelection" .PrintObject = False End With Else With ActiveSheet.Shapes("hSelection") .Left = myTopLeftCell.Left .Top = Selection.Top .Width = myBottomRightCell.Offset(, 1).Left - myTopLeftCell.Left .Height = Selection.Height .ShapeRange.Shadow.Visible = msoFalse End With End If myRange.Select End If Set myTopLeftCell = Nothing Set myBottomRightCell = Nothing Set myRange = Nothing End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target = 0 Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1) = Now Application.EnableEvents = True End Sub
Private Sub Worksheet_Change(ByVal Target As Range) If ActiveCell.Column = 11 Then Msg = "Bu blmdeki bilgileri deitiremezsin!" Cvp = MsgBox(Msg) Application.Undo Else End If If ActiveCell.Column = 12 Then Msg = "Bu blmdeki bilgileri deitiremezsin! " Cvp = MsgBox(Msg) Application.Undo Else End If End Sub Dim satirsay As Integer satirsay = Application.CountA(Sheets("sayfa1").Columns("A")) if satirsay=0 then Sheets("sayfa1").Cells(1, 1)="ne yazlacaksa" else Sheets("sayfa1").Cells(2, 1)="ne yazlacaksa" end if Sub TextBox2Cell() With ActiveCell ActiveSheet.Shapes.AddTextbox _ msoTextOrientationHorizontal, .Left, _ .Top, .Width, .Height End With End Sub Sub TextBox2Selection() If TypeName(Selection) = "Range" Then With Selection ActiveSheet.Shapes.AddTextbox _ msoTextOrientationHorizontal, .Left, _ .Top, .Width, .Height End With End If End Sub verilen ilk koda dikkat etti iseniz Kod: Sub Macro1() For i = 1 To 20 bir = Cells(i, 1) [b]' 20 kez ilem yapar[/b] For j = 1 To 20 iki = Cells(j, "2&" Total") [b]'400 kez bu ilemi [/b] If bir = iki Then [b]'400 kez bu kontrol [/b] Cells(j, 4) = "eit" [b]'400 kez bu ilemi yapar[/b] Next j Next i End Sub gereksiz 1200 ilem yaptn grmnzdr. Range(D2:E5).Clear
Sub YANIPSON() Dim durum As Boolean, i As Single Do While (True) If durum=True Then Range("C1").Select With Selection.Interior .ColorIndex=3 .Pattern=xlSolid End With For i =0 To 2500 DoEvents Next durum=False Else Range("C1").Select Selection.Interior.ColorIndex=xlNone For i=0 To 2500 DoEvents Next durum=True End If Loop End Sub Columns("H").Cells.Replace What:=" ", Replacement:="", LookAt:=xlPart Sub InserTermineDansCellule() Cells(1, 1).Select With Selection .Characters(.Characters.Count + 1).Insert (" termin") End With End Sub Sub a() Dim Nm As Name For Each Nm In Names Nm.Visible = True Next End Sub Sub ShowNames() Dim N As Integer For N = 1 To ActiveWorkbook.Names.Count On Error Resume Next Cells(N, 1) = "'" & ActiveWorkbook.Names(N).Nam Sub range_date_save () Dim dName$ dName = Worksheets(1).Range("A1") dName = Format(dName, "mmdd") & ".xls" ActiveWorkbook.SaveAs dName End Sub Sub range_save() ThisWorkbook.SaveAs FileName:=Worksheets(1).Range("A1") End Sub Sub CopyRange() Range("A1:A3").Copy Destination:=ActiveCell End Sub Sub copy() Sheets("Sayfa1").Range("A1:A3").copy Destination:=ActiveCell End Sub Sub Dialog_10() Application.Dialogs(xlDialogCellProtection).Show End Sub
'Aadaki kodlar Thisworkbook Modlne kopyala Private Sub Workbook_Activate() Dim objMenu As CommandBarControl Dim objMenuButton As CommandBarButton On Error Resume Next Application.CommandBars("Cell").Controls("Tarih Saat").Delete On Error GoTo 0 Set objMenu = Application.CommandBars("Cell"). _ Controls.Add(msoControlPopup, before:=1) objMenu.Caption = "Tarih Saat" Set objMenuButton = objMenu.Controls.Add With objMenuButton .Caption = "Tarih" .OnAction = "DateDetermine" .Style = msoButtonIconAndCaption .FaceId = 1094 End With Set objMenuButton = objMenu.Controls.Add With objMenuButton .Caption = "Saat" .BeginGroup = True .OnAction = "TimeDetermine" .Style = msoButtonIconAndCaption .FaceId = 33 End With End Sub Private Sub Workbook_Deactivate() Application.CommandBars("Cell").Reset End Sub 'Aadaki kodlar standart modle kopyala Sub DateDetermine() MsgBox Date End Sub Sub TimeDetermine() MsgBox Time End Sub
Sub DeleteRowsRedInColA() Application.ScreenUpdating = False Application.Calculation = xlCalculationManual 'pre XL97 xlManual Dim rng As Range, ix As Long Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange) For ix = rng.Count To 1 Step -1 If rng.Item(ix).Interior.ColorIndex = 3 Then 'rakam deitirebilirsiniz rng.Item(ix).EntireRow.Delete End If Next Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Dim cell As Range For Each cell In Intersect(Selection, ActiveCell.EntireColumn, _ ActiveSheet.UsedRange) Select Case cell.Value Case Is >= 50 cell.EntireRow.Interior.ColorIndex = 20 Case Is >= 40 cell.EntireRow.Interior.ColorIndex = 37 Case Is >= 20 cell.EntireRow.Interior.ColorIndex = 38 Case Is >= 0 cell.EntireRow.Interior.ColorIndex = 36 Case Else cell.EntireRow.Interior.ColorIndex = 44 End Select Next cell Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub ByVal Target As Excel.Range) If Intersect(Target, Range("A1:B10")) _ Is Nothing Then Exit Sub If Target.Value > 10 Then Target.Interior.ColorIndex = 6 Else Target.Interior.ColorIndex = xlNone End If End Sub
Sub kirmizisil() Sub DeleteRowsRedInColA() Application.ScreenUpdating = False Application.Calculation = xlCalculationManual 'pre XL97 xlManual Dim rng As Range, ix As Long Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange) For ix = rng.Count To 1 Step -1 If rng.Item(ix).Interior.ColorIndex = 3 Then 'rakam deitirebilirsiniz rng.Item(ix).EntireRow.Delete End If Next Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub DOLU HCRELERN SATIRINI MAV BOLARI SE SARI YAPAN KODLAR Sub bosdolurenklendir() Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Dim cell As Range For Each cell In Intersect(Selection, ActiveCell.EntireColumn, _ ActiveSheet.UsedRange) Select Case cell.Value Case Is >= 50 cell.EntireRow.Interior.ColorIndex = 20 Case Is >= 40 cell.EntireRow.Interior.ColorIndex = 37 Case Is >= 20 cell.EntireRow.Interior.ColorIndex = 38 Case Is >= 0 cell.EntireRow.Interior.ColorIndex = 36 Case Else cell.EntireRow.Interior.ColorIndex = 44 End Select Next cell Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub A1:B10 HCRELERNDEK DEER 10 DAN BYK SE HCRE RENG SARI OLUR Private Sub Worksheet_Change( _ ByVal Target As Excel.Range) If Intersect(Target, Range("A1:B10")) _ Is Nothing Then Exit Sub If Target.Value > 10 Then Target.Interior.ColorIndex = 6 Else Target.Interior.ColorIndex = xlNone End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Selection.Cells.Address = "e26:36" Then Exit Sub ifre = InputBox("ltfen ifreyi giriniz") If ifre <> "a" Then [e2].Select End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) sut = Selection.Cells.Column sat = Selection.Cells.Row If sut < 5 Or sut > 9 Or sat < 26 Or sat > 36 Then Exit Sub ifre = InputBox("ltfen ifreyi giriniz") If ifre <> "a" Then [a2].Select End Sub Sub Dme1_Tklat() Dim r1 As Range, r2 As Range, myMultiAreaRange As Range Set r1 = Range("A1:B2") Set r2 = Range("C3:D4") Set myMultiAreaRange = Union(r1, r2) myMultiAreaRange.Select End Sub
Tek bir hcre seer. Range("B2").Select Cells(2,1).Select [B2].Select 'Tm hcreleri seer. Cells.Select 'Bo hcreleri seer. Selection.SpecialCells(xlCellTypeBlanks).Select 'Aktif hcrenin bulunduu stunun tamamn seer. ActiveCell.EntireColumn.Select 'Seili hcrelerin bulunduklar stunlar tamamen seer. Selection.EntireColumn.Select 'Aktif hcrenin bulunduu satr tamamn seer. ActiveCell.EntireRow.Select 'Seili hcrelerin bulunduklar satrlar tamamen seer. Selection.EntireRow.Select 'Bir nceki ilem yaplan hcreyi seer. Selection.SpecialCells(xlLastCell).Select 'Aktif hcrenin bir altdaki hcreyi seer. ActiveCell.Offset(1, 0).Select 'Aktif hcrenin bir stndeki hcreyi seer. ActiveCell.Offset(-1, 0).Select 'Aktif hcrenin bir sandaki hcreyi seer. ActiveCell.Offset(0, 1).Select 'Aktif hcrenin bir solundaki hcreyi seer. ActiveCell.Offset(0, -1).Select 'Aktif hcrenin sandaki 5. hcreyi seer. ActiveCell.Offset(0, 5).Select Sub SuruklemeyiEngelle() Application.CellDragAndDrop = False End Sub 'srklemeyi aktif yap Sub Auto_Close() Application.CellDragAndDrop = True End Sub HCRE SRKLENMESN ENGELLE Sub SuruklemeyiEngelle() Application.CellDragAndDrop = False End Sub HCRE SRKLENMESN AKTF YAP Sub Auto_Close() Application.CellDragAndDrop = True End Sub
A1 hcresini, Range("A1") veya Cells(1,1), Cells(1, "A"), [R1C1] veya [A1] olarak kodlarda grebilirsiniz. Eer A1 hcresine zel bir AD verdiyseniz (rn."IlkHucre" gibi), Range("IlkHucre") veya Cells("IlkHucre") eklinde de kullanlabilir. Bunlarn hepsi ayndr. Sub ImpZoneEtTitle() With Worksheets("Sayfa1").PageSetup .CenterHorizontally = True .PrintArea = "$A$10:$G$15" .PrintTitleRows = ("$A$1:$A$2") .Orientation = xlPortrait .FitToPagesWide = 1 .FitToPagesTall = 1 End With Worksheets("Sayfa1").PrintOut End Sub Private Sub cmdkaydet_Click() Dim bak As Range Dim say As Integer For Each bak In Range("A1:A" & WorksheetFunction.CountA(sheets("veriler").Range("A1:A65000"))) ---------------------------------------------------txtceksirano.Value = WorksheetFunction.Count(sheets("veriler").Range("A1:A65000")) + 1
Sub SelectEntireColumn() Selection.EntireColumn.Select End Sub AKTF SATIRI SE Sub SelectEntireRow() Selection.EntireRow.Select End Sub TM HCRELER SE Sub SelectEntireSheet() Cells.Select End Sub DOLU HCRELERN ALTINDAK BO HCREY SEER Sub ActivateNextBlankDown() ActiveCell.Offset(1, 0).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop End Sub AKTF HCRELERN SA TARAFINDAK BO HCREY SEER Sub ActivateNextBlankToRight() ActiveCell.Offset(0, 1).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(0, 1).Select Loop End Sub AKTF HCRENN SAINDAK VE SOLUNDAK DOLU HCRELER SEER Sub SelectFirstToLastInRow() Set LeftCell = Cells(ActiveCell.Row, 1) Set RightCell = Cells(ActiveCell.Row, 256) If IsEmpty(LeftCell) Then Set LeftCell = LeftCell.End(xlToRight) If IsEmpty(RightCell) Then Set RightCell = RightCell.End(xlToLeft) If LeftCell.Column = 256 And RightCell.Column = 1 Then ActiveCell.Select Else Range(LeftCell, RightCell).Select End Sub AKTF HCRENN ALTINDAN BALAYARAK EN SON HCREYE KADAR SEER Sub SelectDown() Range(ActiveCell, ActiveCell.End(xlDown)).Select End Sub A1:A3 VE C3:C8 HCRE ARALIINI SEER Sub hucresec() Application.ScreenUpdating = False Dim r1 As Range, r2 As Range, rAll As Range Set r1 = Range("A1", "A3") Set r2 = Range("C3", "C8") Set rAll = Union(r1, r2) rAll.Select End Sub Aktif hcrenin 3 satr altndaki, iki stun nndeki hcreyi seer Sub MoveToCell() ActiveCell.Offset(3, 2).Select End Sub
Dim sourceRange As Range Dim destrange As Range Dim Lr As Long Lr = LastRow(Sheets("Sayfa1")) + 1 Set sourceRange = Sheets("Sayfa1").Range("A1:c10") Set destrange = Sheets("Sayfa2").Range("A" & Lr) sourceRange.Copy destrange End Sub Sub CopyOneAreaValues() Dim sourceRange As Range Dim destrange As Range Dim Lr As Long Lr = LastRow(Sheets("Sayfa2")) + 1 Set sourceRange = Sheets("Sayfa1").Range("A1:c10") With sourceRange Set destrange = Sheets("Sayfa2").Range("A" & Lr). _ Resize(.Rows.Count, .Columns.Count) End With destrange.Value = sourceRange.Value End Sub Function LastRow(sh As Worksheet) On Error Resume Next LastRow = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row On Error GoTo 0 End Function Function Lastcol(sh As Worksheet) On Error Resume Next Lastcol = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Column On Error GoTo 0 End Function Yaplan seimlerde bo olmayan hcre saysn verir. Sub hucresayisi() Dim kontur As Integer kontur = Application.CountA(Selection) MsgBox "Seimdeki dolu hcrelerin says:" & kontur End Sub Koddaki CountA'daki 'A' kaldrlrsa seimde sadece ka hcrede say(rakam) varsa onlarn adedini verir. Application.Count(Selection) Seili hcrelerin saysn verir. Selection.Count Seimin satr saysn verir. Selection.Rows.Count Seimin stun saysn verir. Selection.Columns.Count
Sub SelectEntireColumn() Selection.EntireColumn.Select End Sub 'Aktif satr se Sub SelectEntireRow() Selection.EntireRow.Select End Sub 'Tm hcreleri se Sub SelectEntireSheet() Cells.Select End Sub 'Dolu hcrelerin altndaki bo hcreyi se Sub ActivateNextBlankDown() ActiveCell.Offset(1, 0).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop End Sub 'Aktif hcrenin sa tarafndaki bo hcreyi se Sub ActivateNextBlankToRight() ActiveCell.Offset(0, 1).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(0, 1).Select Loop End Sub 'Aktif hcrenin sandaki ve solundaki dolu hcreleri seer Sub SelectFirstToLastInRow() Set LeftCell = Cells(ActiveCell.Row, 1) Set RightCell = Cells(ActiveCell.Row, 256) If IsEmpty(LeftCell) Then Set LeftCell = LeftCell.End(xlToRight) If IsEmpty(RightCell) Then Set RightCell = RightCell.End(xlToLeft) If LeftCell.Column = 256 And RightCell.Column = 1 Then ActiveCell.Select Else Range(LeftCell, RightCell).Select End Sub 'Aktif hcrenin altndan balayarak en son hcreye kadar se Sub SelectDown() Range(ActiveCell, ActiveCell.End(xlDown)).Select End Sub 'A1:A3 VE C3:C8 hcre araln se Sub hucresec() Application.ScreenUpdating = False Dim r1 As Range, r2 As Range, rAll As Range Set r1 = Range("A1", "A3") Set r2 = Range("C3", "C8") Set rAll = Union(r1, r2) rAll.Select End Sub 'Aktif hcrenin 3 satr altndaki, iki stun nndeki hcreyi seer Sub MoveToCell() ActiveCell.Offset(3, 2).Select End Sub Sub hcre_bic_say() For n = 100 To 1 Step -1 Application.StatusBar = n SendKeys "{Tab}" For i = 1 To 11 SendKeys "{down}" Next SendKeys "{Tab}" SendKeys "{Tab}" For i = 1 To n SendKeys "{down}" Next SendKeys "%l" SendKeys "{Enter}" Application.Dialogs(xlDialogFormatNumber).Show Next Application.StatusBar = False End Sub Do While Not IsEmpty(ActiveCell) And ActiveCell <> "" And ActiveCell <> 0 ActiveCell.Offset(1, 0).Select Loop
Sub ayr() b = Split(Range("a1").Value, " ") If UBound(b) > 1 Then TextBox1 = b(0) & " " & b(1) TextBox2 = b(2) Else TextBox1 = b(0) TextBox2 = b(1) End If End Sub Private Sub Workbook_Open() Call Ayar End Sub Sub Ayar() Dim Zaman As Date Zaman = Now + TimeValue("00:00:01") Application.ontime Zaman, "Yenile" End Sub Sub Yenile() Range("Saat").Value = Now Call Ayar End Sub rnek kullanm 1 'a1 =1 'b1==aycevir(A1) 'rnek kullanm 2 'a2=02.02.2006 'b2=aycevir(AY(A2)) Function AyCevir(deger As Byte) AyCevir = Choose(deger, "Ocak", "ubat", "Mart", "Nisan", "Mays", "Haziran", _ "Temmuz", "Austos", "Eyll", "Ekim", "Kasm", "Aralk") End Function Private Sub CommandButton1_Click() For i = 2 To 100 ay = DatePart("m", DateAdd("m", 1, Cells(i - 1, 2))) yl = DatePart("yyyy", DateAdd("m", 1, Cells(i- 1, 2))) For k = 28 To 31 yeni = DateAdd("d", k, "1/" & ay & "/" & yl) If ay <> DatePart("m", yeni) Then Exit For Next k Cells(i, 2) = DateAdd("d", k, Cells(i - 1, 2)) Next i End Sub Burada A2 ile A100 arasna A1 deki tarih baz alnarak uygun tarihler yerletirildi. Ama baktm, bu ite bir gariplik var dedim. Bu kadar basit bir ilemi Excel fonksiyonlar zmlemeli diyerek formllerimi kurcaladm biraz. Eer ToolPak-VBA zmleyicisi eklentisi aktif ise sizin formlleriniz iinde de EoMonth formln bulacaksnz. =EoMonth(ReferansTarih,stenilenAy) Referans Tarih = Yeni tarihi bulmak iin zerine ilave etmek istediiniz tarih deeri. stenilen Ay = Gn saysn renmek istediiniz ay belirtecek olan ve ReferansTarih ten sonraki ay belirten Tamsay deiken. Bu Durumda A2 hcresine = A1+EoMonth(A1;1) A3 hcresine = A2+EoMonth(A2;1) ve bu ekilde devam edildiinde istenilen zm bulunmu oluyor.
Sub auto_open() Call Ereignis End Sub Sub Ereignis() Sheets("Sayfa1").OnEntry = "frben" End Sub Sub frben() Farbzahl = Range("C6") Range("B2:D5").Select With Selection.Interior .ColorIndex = Farbzahl End With Range("C5").Select End Sub Sub auto_close() Worksheets("Sayfa1").OnEntry = "" End Sub Private Sub Worksheet_Change(ByVal Target As Range) On Error Resume Next If Intersect(Target, [a4]) Is Nothing Then Exit Sub If Target <> "" Then Sheets("" & [a4]).Select End Sub Aadaki kod, tek bir hcreyi bir argman olarak kabul eder. Function CellUsesLiteralValue(Cell As Range) As Boolean If Not Cell.HasFormula Then CellUsesLiteralValue = False Else CellUsesLiteralValue = Cell.Formula Like "*[=^/*+-/()><, ]#*" End If End Function Option Explicit Sub ChangeText_Proper() Dim cCell As Range Dim TheRg As Range '// Incase No constants of type text in the selection! On Error Resume Next Set TheRg = Selection.SpecialCells(xlCellTypeConstants, 2) If TheRg Is Nothing Then MsgBox "Yaz yok mu desem!", vbCritical: Exit Sub On Error GoTo 0 For Each cCell In TheRg cCell = Application.WorksheetFunction.Proper(cCell) Next MsgBox "Tamam!", vbInformation End Sub Sayfann kod blmne 'lk harfler byk Private Sub Worksheet_Change(ByVal Target As Range) Target.Value = WorksheetFunction.Proper(Target.Value) End Sub 'Hepsi Byk Private Sub Worksheet_Change(ByVal Target As Range) Target.Value = WorksheetFunction.UPPER(Target.Value) End Sub 'Hepsi Kk Private Sub Worksheet_Change(ByVal Target As Range) Target.Value = WorksheetFunction.Lower(Target.Value) End Sub
Sub kucuksil() Dim gg as double gg = Application.worksheetFunction.CountA(Range("A:A")) For i = 1 to gg if LCase(Cells(i,1).text) = Cells(i,1).text then Cells(i,1).value="" Else End if Next i End sub Sub sil() For i = 1 To 500 If LCase(Cells(i, 1).Text) = Cells(i, 1).Text Then Application.DisplayAlerts = False Cells(i, 1).EntireRow.Delete If Not ActiveCell.Value = "" Then i = i - 1 Application.DisplayAlerts = True End If Next i MsgBox "Satr Silme lemi Tamamlanmtr." End Sub Sub hucresaymesaj() pir = [a1] MsgBox Len(pir) End Sub Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub KayanYazi() Dim C As Range Dim i% Set C = Range("B1") 'B1'deki yazy kaydrr For i = 1 To 200 C = Right(C, Len(C.Value) - 1) + Left(C, 1) Sleep 100 Next i End Sub
Sub AmiText() On Error GoTo AddCond TryAgain: AmiCellAddr = Range("A1:A5").SpecialCells(xlCellTypeAllFormatConditions).Address Dim myText As String Dim x As Integer, y As Integer Dim myStart, myDelay myText = Range(AmiCellAddr).Value On Error GoTo myEnd For y = 1 To 1 For x = 30 To 1 Step -1 myStart = Timer myDelay = myStart + 0.1 Do While Timer < myDelay [B6] = Space(x) & myText DoEvents Loop DoEvents myStart = Timer myDelay = myStart + 0.1 Next x Next y [D6] = "" Range(AmiCellAddr).FormatConditions.Delete NxRw = Range(AmiCellAddr).Row + 1 If NxRw > 5 Then NxRw = 1 Range("A" & NxRw).FormatConditions.Add Type:=xlCellValue, _ Operator:=xlEqual, Formula1:="1" GoTo TryAgain myEnd: End Exit Sub AddCond: Range("A1").FormatConditions.Add Type:=xlCellValue, _ Operator:=xlEqual, Formula1:="1" GoTo TryAgain End Sub Private Sub Worksheet_Change(ByVal Target As Range) Static dur As Boolean If Target.Address = "$A$4" And dur = False Then dur = True Target.Value = UCase(Left(LTrim(Target.Value), 1)) & Right(LTrim(Target.Value), Len(LTrim(Target.Value)) - 1) End If dur = False End Sub Private Sub Worksheet_Activate() Do DoEvents [a1] = Format(Now, "hh:mm:ss") Loop End Sub Private Sub Workbook_Open() Call Ayar End Sub Sub Ayar() Dim Zaman As Date Zaman = Now + TimeValue("00:00:01") Application.ontime Zaman, "Yenile" End Sub Sub Yenile() Range("Saat").Value = Now Call Ayar End Sub Sub clock() If ThisWorkbook.Worksheets(1).Range("B1").Value = "X" Then Exit Sub ThisWorkbook.Worksheets(1).Range("A1").Value = Format(Now, "hh:mm:ss AM/PM") Application.OnTime Now + TimeSerial(0, 0, 1), "clock" End Sub
Sub Heure() Application.OnTime Now + TimeValue("00:00:01"), "Heure" Range("A1") = Time End Sub Sub Arret() Application.OnTime Now + TimeValue("00:00:01"), "Heure", , False End Sub Dim stopit As Boolean 'on top of module! Sub startclock() 'assign start button stopit = False clock End Sub Sub clock() If stopit = True Then Exit Sub ActiveWorkbook.Worksheets(1).cells(1, 1).Value = _ Format(Now, "hh:mm:ss") Application.OnTime (Now + TimeSerial(0, 0, 1)), "clock" End Sub Sub stopclock() 'assign stop button stopit = True End Sub Sayfaya bir Calendar ekle ve ad Calendar1 olsun. Sonra 'ThisWorkbook ' un Open event ine : Private Sub Workbook_Open() Calendar1.Visible = False End Sub 'Bunu da olayn gereklemesini istediin sayfann kod blmne Private Sub Calendar1_Click() ActiveCell.Value = Calendar1.Value End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = Range("A2").Address Then Calendar1.Visible = True Else Calendar1.Visible = False End If End Sub Sub SayfaAra() Dim i As Integer For i = 1 To Worksheets.Count If Worksheets(i).Name = Range("B5").Value Then MsgBox "Bu isimde bir sayfa var" Exit Sub End If Next i End Sub TextBox1 = Sheets("Sayfa2").Range("A21").Comment.Text
Sub hcre_ayir() Dim AD As String Dim SOYAD As String For HCRE = 1 To 1000 'DNG SAYISINI SZ VEREBLRSNZ. BURADA 1000 ALINDI Range("A" & HCRE).Select UZUNLUK = Len(Range("A" & HCRE).Text) 'BAVURULAN HCRENN METN UZUNLUU For KARAKTER = 1 To UZUNLUK If Mid(Range("A" & HCRE), KARAKTER, 1) = " " Then 'EER BAKILAN KARAKTER " " SE AYIRMA LEM YAPILACAK VE BR SONRAK HCREYE GEL AD = Left(Range("A" & HCRE), KARAKTER - 1) SOYAD = Mid(Range("A" & HCRE), KARAKTER + 1, UZUNLUK - Len(AD)) '+1 VE -1 LER BOLUU ALMAMAK N EKLEND Range("B" & HCRE).Value = AD Range("C" & HCRE).Value = SOYAD Exit For End If Next KARAKTER Next HCRE Range("A1").Select End Sub
Dim c As Range 'Range("A2:A4") contains the domain names to ping For Each c In ActiveSheet.Range("A2:A4") c.Offset(0, 1) = PingAddress(c.Text) Next c End Sub Function PingAddress(strDomain As String) As String Dim fso As Object Dim WshShell As Object Dim RetVal As Long Dim strTemp As String Dim colOutput As New Collection Dim OutputItem Dim i As Long Set WshShell = CreateObject("Wscript.Shell") RetVal = WshShell.Run("cmd /c nslookup.exe -ls " & strDomain & " > C:\NSLOOKUPDATA.TXT", 0, True) Set fso = CreateObject("Scripting.FileSystemObject") Set txtstream = fso.OpenTextFile("C:\NSLOOKUPDATA.TXT", 1) Do strTemp = txtstream.ReadLine colOutput.Add strTemp Loop Until txtstream.AtEndOfStream txtstream.Close For i = colOutput.Count To 1 Step -1 If Left(colOutput(i), 10) = "Addresses:" Then strTemp = Trim(colOutput(i)) PingAddress = Trim(Right(strTemp, Len(strTemp) - InStr(1, strTemp, "Addresses:") - 9)) Exit For End If Next If PingAddress = "" Then For i = colOutput.Count To 1 Step -1 If Left(colOutput(i), 8) = "Address:" Then strTemp = Trim(colOutput(i)) PingAddress = Trim(Right(strTemp, Len(strTemp) - InStr(1, strTemp, "Addresses:") - 9)) Exit For End If Next End If If PingAddress = "" Then PingAddress = "Domain name not resolved" Set txtstream = Nothing Set fso = Nothing Set WshShell = Nothing End Function Sayfann kod blmne, Mahmut yazarsan Makro1'i altrr. If Target = "Mahmut" Then Run "Module1.Makro1" End If End Sub
Private Sub Worksheet_Calculate() Worksheet_Change Range("VB_Trigger") End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) ' Level 1: Set up the event to watch a single cell. If Target.Address = Range("VB_Trigger").Address Then ' Level 2: Perform some action based on the value of the watched cell. Select Case Target.Value Case 1 MsgBox "Hello" Case 2 MsgBox "Goodbye" Case 3 MsgBox "Pretty Bird" End Select End If End Sub Sub pay_wages() Dim counter counter = 1 Range("B3").Select Do While ActiveCell.Value < 10 ActiveCell.Value = counter ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True counter = counter + 1 Loop End Sub Sub herartista_bir_kopya() Dim counter counter = 1 Range("B3").Select Do While ActiveCell.Value < 10 ActiveCell.Value = counter ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True counter = counter + 1 Loop End Sub Range(D3).Font.Size=14 Range(D3).Font.Name=Arial Range(D3).Font.Bold=True gibi Sub Test() x = Cells(65536, 3).End(xlUp).Row Range("E2").AutoFill Destination:=Range("E2:E" & x) Application.Calculate End Sub Sub GunFormati() Yil = Sheets("MEN").Range("AA1") Ay = Sheets("MEN").Range("AA2") Gun = Range("D6") MsgBox Format(DateSerial(Yil, Ay, Gun), "dddd") End Sub
worksheet in change olayna visual basic kodu: -------------------------------------------------------------------------------Private Sub Worksheet_Change(ByVal Target As Range) Dim blg As Range If Target.Count > 1 Then Exit Sub Set blg = Range("A:A") If Intersect(Target, blg) Is Nothing Then Exit Sub If Len(Target) = 8 Then If InStr(Target, ".") = 0 Then Target = Left(Target, 2) & "." & Mid(Target, 3, 2) & "." & Right(Target, 4) End If End Sub --------------------------------------------------------------------------------
kodunu eklerseniz, a stununa bahsettiiniz formatta girdiiniz her tarih ksaltmasn istediiniz formata evirir. lgili hcreleri setikten sonra; Kod: Sub Encrypt2() Dim Array1, Array2 Dim i As Integer Dim MyRng As Range Array1 = Array("a", "N", "b", "t", "S", "E", "T", "K", "I", "Z") Array2 = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0) For Each MyRng In Selection For i = LBound(Array1) To UBound(Array1) MyRng = WorksheetFunction.Substitute(MyRng, Array1(i), Array2(i)) Next Next End Sub ' Sub Decrypt2() Dim Array1, Array2 Dim i As Integer Dim MyRng As Range Array1 = Array("a", "N", "b", "t", "S", "E", "T", "K", "I", "Z") Array2 = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0) For Each MyRng In Selection For i = LBound(Array1) To UBound(Array1) MyRng = WorksheetFunction.Substitute(MyRng, Array2(i), Array1(i)) Next Next End Sub Sayfann kod blmne. Function renkkodu(hucre As Range) hucre1 = hucre.Address(ColumnAbsolute:=False, RowAbsolute:=False) renkkodu = Range(hucre1).Font.ColorIndex End Function 'Kaydet, kapat. 'Renkkodu adnda yeni bir fonksiyon oluturmu olduk. 'Tablonun en sandaki hcrelere '=renkkodu(adres) yaz (adres rengine gre filtreleme yapacan hcre) 'Ayn forml tablonun tm satrlarna karlk gelecek ekilde kopyala. 'Bylece szkonusu hcrenin renk kodunu yazdrm olduk. 'imdi bu kolon zerinden istediin renk koduna gre filtre yapabilirsin Private Sub CommandButton1_Click() Sheets("Sayfa1").PrintOut From:=1, To:=[A1].Value TextBox1.value olursa textboxtali say kadar kt alnr End Sub
Sub ImprimFormulaire() Dim CellPara Range("A2") = Application.InputBox(prompt:="Taper le nombre de copies que vous dsirez.", Type:=1) For CellPara = 1 To Range("A2") Range("E13").Value = Range("E13").Value + 1 ActiveSheet.PageSetup.PrintArea = "$A$5:$I$24" ActiveWindow.SelectedSheets.PrintOut Copies:=1 Next End Sub Kullanm: A1Hcresi=15 Kg. B1 Hcresine Girilecek Forml =sayim(A1) 'rnek: A1 Hcresindeki 15 kg. ile A2 Hcresinin Deerini arpmak iin B1 Hcresine Girilecek Forml = sayim(A1)*A2 'Burada dikkat edilecek husus; =A1*A2 eklinde arpma ilemini yaptmz zaman #DEER! hata mesaj verecektir. Function sayim(hucre) Dim i As Integer For i = 1 To Len(hucre) sayi = Mid(hucre, i, 1) If IsNumeric(sayi) = True Then sayim = sayim & sayi End If Next i End Function Sub Round() ActiveCell = Application.Round(ActiveCell, -3) End Sub Dim r As Range Dim i As Integer For Each r In Selection.Cells If r.Value <> Empty Then For i = 1 To Len(r.Value) If IsNumeric(Mid(r.Value, i, 1)) Then r.Characters(i, 1).Font.Superscript = True Else r.Characters(i, 1).Font.Superscript = False End If Next End If Next End Sub Sub ZahlTief() Dim r As Range Dim i As Integer For Each r In Selection.Cells If r.Value <> Empty Then For i = 1 To Len(r.Value) If IsNumeric(Mid(r.Value, i, 1)) Then r.Characters(i, 1).Font.Subscript = True Else r.Characters(i, 1).Font.Subscript = False End If Next End If Next End Sub Sub ZahlNormal() Dim r As Range Dim i As Integer For Each r In Selection.Cells If r.Value <> Empty Then For i = 1 To Len(r.Value) If IsNumeric(Mid(r.Value, i, 1)) Then r.Characters(i, 1).Font.Superscript = False r.Characters(i, 1).Font.Subscript = False End If Next End If Next End Sub Sub son() ActiveCell = Application.Ceiling(ActiveCell, 1000) End Sub
Function sayim(hucre) Dim i As Integer For i = 1 To Len(hucre) sayi = Mid(hucre, i, 1) If IsNumeric(sayi) = True Then sayim = sayim & sayi End If Next i End Function Sub bin() ActiveCell = Application.Floor(ActiveCell, 1000) End Sub Thisworkbook a Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range) x = Target.Row y = Target.Column ActiveSheet.Rows(x).AutoFit ActiveSheet.Columns(y).AutoFit End Sub Sub Dme1_Tklat() Set s1 = Sheets("Sayfa2") For i = 1 To 100 s1.Cells(i, 1).Activate s1.Rows(i + 1 & ":" & i + 32).Select Selection.Insert Shift:=xlDown i = i + 32 Next i End Sub Sub Mesaj() Dim Mes As String Dim i As Integer For i = 6 To 48 Step 2 Mes = Mes & Format(Range("A" & i), "0##,##0") _ & vbTab & Format(Range("B" & i), "0##,##0") & vbCrLf Next i MsgBox Mes End Sub Sheets(1).PageSetup.CenterFooter = Sheets(2).[A1] Private Sub UserForm_Activate() i=1 For Each Hucre In Range("A5:F5") Controls("TextBox" & i) = Hucre i=i+1 Next End Sub Private Sub UserForm_Activate() range("a4").select For i = 1 To 7 Controls("Textbox" & i).Value = activecell.offset(i,0).Value Next End Sub Sub ReverseText() Dim strText As String, strReverseText As String Dim intPos As Integer, intLen As Integer strText = Selection.Text intLen = Len(strText) For intPos = 1 To Len(strText) strReverseText = strReverseText & Mid(strText, intLen - intPos + 1, 1) Next intPos ActiveCell.FormulaR1C1 = strReverseText End Sub
Aadaki kodu kopyala ve sayfaya yaptr. Function renkkodu(hucre As Range) hucre1 = hucre.Address(ColumnAbsolute:=False, RowAbsolute:=False) renkkodu = Range(hucre1).Font.ColorIndex End Function Kaydet ve Editr kapat. Renkkodu adnda yeni bir fonksiyon yaratm olduk. Toblonun en sandaki hcrelere =renkkodu(adres) yaz (adres rengine gre filtreleme yapacan hcre) Ayn forml tablonun tm satrlarna karlk gelecek ekilde kopyala. Bylece szkonusu hcrenin renk kodunu yazdrm olduk. imdi bu kolon zerinden istediin renk koduna gre filtre yapabilirsin. Biraz zgn bir zm oldu, umarm iine yarar. Baka kullanclardan farkl neriler de gelebilir sanrm. Sub SL() Sheets("Sayfa1").Select Set ALAN1 = [A2] 'A5:E10 rnek Set ALAN2 = [B2] ' If ALAN1 <> "" Then Sheets("Sayfa1").Range(ALAN1).ClearContents If ALAN2 <> "" Then Sheets("Sayfa2").Range(ALAN2).ClearContents Sheets("Sayfa1").Select MsgBox "LEM TAMAMLANMITIR.", vbInformation End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Application.EnableEvents = False Target = UCase(Target) Application.EnableEvents = True End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Dim RaBereich As Range Set RaBereich = Range("B3:C20,D1:D7") If Not Intersect(Range(Target.Address), RaBereich) Is Nothing Then UserForm1.Show Set RaBereich = Nothing End Sub Sub screen_opt() Range("A1:N29").Select ActiveWindow.Zoom = True Range("A1").Select End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Target, Range("B1:B8")) Is Nothing Then Exit Sub If row <> 0 Then If Cells(row, col) = "" And Target.row <> row Then MsgBox ("bo geemezsiniz") Cells(row, col).Select Exit Sub End If End If If Target.row <> row Then row = Target.row col = Target.Column End If End Sub
A1 LE M8 HCRELERN ARKASINDA YEL IIK 10 DEFA YANAR SNER Sub FlashBack() Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed Set myCell = Range("A1:M8") Application.DisplayStatusBar = True Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! " newColor = 12 fSpeed = 0.2 Do Until x = 10 DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Interior.ColorIndex = xlNone Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub Sub fontrenk() Dim Cel1 As Range Set Cel1 = Range("A1:b10") With Cel1.Font .Bold = True .Italic = True .Name = "Courier" .Size = 10 .Color = RGB(255, 0, 0) End With End Sub Sub yuvarla() Range("A3").Formula = Round((Range("a1").Value + Range("a2").Value) / 50000) * 50000 End Sub Range("A1").Formula = Round(("A1 HCRESNDEK FORML TIRNAKLAR OLMADAN") / 50000) * 50000 [A1] = "=ROUND(" & [A1].Value & "/50000,0)*50000" Sub metnecevr() Col = 1 DerLig = Cells(65536, Col).End(xlUp).Row For i = 1 To DerLig Cells(i, Col).Formula = "'" & Cells(i, Col) Cells(i, Col).Formula = "" & Cells(i, Col) Next i End Sub Sub formullerideeryap() For Each fCell In Selection fCell.Value = fCell.Value Next fCell End Sub Sub birlestir() For a=1 To cells(65536,1).end(xlup).row cells(a,3)=cells(a,1) & " " & cells(a,2) Next End Sub
sayfalarn kod blmlerine Option Explicit 'Thisworkbook a Option Explicit Private Sub Workbook_BeforePrint(Cancel As Boolean) If Worksheets("Tabelle1").Range("A1").Value = "" Or _ Worksheets("Tabelle1").Range("B3").Value = "" Or _ Worksheets("Tabelle1").Range("D5").Value = "" Or _ Worksheets("Tabelle1").Range("D7").Value = "" Then MsgBox ("Im Tabellenblatt ''Tabelle1'' sind nicht alle ''Pficht''-Zellen gefllt !") Cancel = True End If End Sub 'Modle Option Explicit Sub Makro1() Range("A1,B3,D5,D7").Select Range("D7").Activate End Sub Sub doluhucre_yaz() Dim ran Sheets("Sayfa1").Activate ran = range("A2:E2").Select For Each ran In Selection If ran > 0 Then range("A5").Value = ran.Value End If Next End Sub Sub RempliUnion() Worksheets("Feuil1").Activate Set MaPlage = Application.Union(Range("A1:D10"), Range("F1:H12")) MaPlage.Value = 100 End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 2 Then Target.Offset(1, -1).Select If Target.Column = 3 Then Target.Offset(1, -2).Select If Target.Column = 4 Then Target.Offset(1, -3).Select If Target.Column = 5 Then Target.Offset(1, -4).Select End Sub change olay eer deer girilmedi ise olumayaca iin kullanmak gereksizdir. bunun yerine module 'e Kod: Public col As Integer Public row As Integer worksheet in selection change ine Kod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Target, Range("B1:B8")) Is Nothing Then Exit Sub If row <> 0 Then If Cells(row, col) = "" And Target.row <> row Then MsgBox ("bo geemezsiniz") Cells(row, col).Select Exit Sub End If End If If Target.row <> row Then row = Target.row col = Target.Column End If End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean) If Worksheets("Tabelle1").Range("A1").Value = "" Or _ Worksheets("Tabelle1").Range("B3").Value = "" Or _ Worksheets("Tabelle1").Range("D5").Value = "" Or _ Worksheets("Tabelle1").Range("D7").Value = "" Then MsgBox ("Im Tabellenblatt ''Tabelle1'' sind nicht alle ''Pficht''-Zellen gefllt !") Cancel = True End If End Sub Sub Copy_Sel_Image() Range("B2:C4").Copy Range("B6").Select ActiveSheet.Pictures.Paste Application.CutCopyMode = False End Sub A1:A20 Arasndaki hcreleri A1:A2 hcrelerindeki deerlere gre otomatik doldurur. Sub OtoDoldur() Set Kaynak = Worksheets("Sayfa1").Range("A1:A2") Set Aralik = Worksheets("Sayfa1").Range("A1:A20") Kaynak.AutoFill Destination:=Aralik End Sub Option Explicit Private Sub SaveRngAsJPG(Rng As Range, FileName As String) Dim Cht As Chart, bScreen As Boolean, Shp As Shape bScreen = Application.ScreenUpdating Application.ScreenUpdating = False Set Cht = Workbooks.Add(xlChart).Charts(1) Cht.ChartArea.Clear Rng.CopyPicture xlScreen, xlPicture Cht.Paste With Cht.Shapes(1) .Left = 0 .Top = 0 .Width = Cht.ChartArea.Width .Height = Cht.ChartArea.Height End With Cht.Export FileName, "JPEG", False Cht.Parent.Close False Application.ScreenUpdating = bScreen End Sub Sub TestIt2() Dim Rng As Range, Fn As String Set Rng = Range("A1:H20") Fn = "C:\ExcelSayfam.jpg" SaveRngAsJPG Rng, Fn End Sub
Sub AddBullets() Dim Bullet As String Dim Dash As String Dim Cel As Range Dim Str As String Dim i As Long Bullet = " " Dash = " - " 'select which cells to perform an action on For Each Cel In Selection Str = Cel.Value 'If there is already a bullet there then put a dash in its place If Left(Str, Len(Bullet)) = Bullet Then Str = Right(Str, Len(Str) - 2) Cel.Value = Dash & Str Else 'If there is already a dash there then trim back to normal text If Left(Str, Len(Dash)) = Dash Then Str = Trim(Cel.Value) i = Len(Str) - 1 If i >= 0 Then Cel.Value = Trim(Right(Str, i)) End If Else 'Otherwise add the bullet Cel.Value = Bullet & Str End If End If 'Go to the next cell in the selection and do the same thing Next Cel End Sub Sub FormatCommentaire() Dim wks As Worksheet, MyCmt As Comment For Each wks In Worksheets For Each MyCmt In wks.Comments MyCmt.Shape.OLEFormat.Object.AutoSize = True With MyCmt.Shape.OLEFormat.Object.Font .Name = "Verdana" .Size = 10 .ColorIndex = 9 .Bold = True End With MyCmt.Shape.OLEFormat.Object.ShapeRange.Fill.ForeColor.SchemeColor = 35 Next MyCmt Next wks End Sub nce G1 hcresine 1 yazn sonra aadaki makroyu altrn. Bu makro dolu hcreleri 1 ile arpar ve ' iareti ortadan kalkar. visual basic kodu: Sub Makro1() Range("G1").Select Selection.Copy Selection.SpecialCells(xlCellTypeConstants, 23).Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False Range("A1").Select End Sub Sub DeleteRangeNames() Dim rName As Name For Each rName In ActiveWorkbook.Names rName.Delete Next rName End Sub
Sub hucre_adresi() Worksheets(1).Select With ActiveCell MsgBox .Address MsgBox .Address(False) MsgBox .Address(, False) MsgBox .Address(False, False) MsgBox .Row & " .satr" MsgBox .Column & " .stun" MsgBox "Satr Numaras: " & .Row & _ " - Stun Numaras:" & .Column End With End Sub Sub ColLigne() Colonne = Left$(ActiveCell.Address(0, 0), (ActiveCell.Column < 27) + 2) Ligne = ActiveCell.Row MsgBox Colonne & Ligne MsgBox Colonne MsgBox Ligne End Sub Sub PrintRpt2() Range("H1:A2").PrintOut End Sub Private Sub Worksheet_Change(ByVal Target As Range) Select Case Target Case " ": Target.Interior.ColorIndex = 15 Case "A": Target.Interior.ColorIndex = 3 Case "B": Target.Interior.ColorIndex = 3 Case "A&B": Target.Interior.ColorIndex = 3 Case "-": Target.Interior.ColorIndex = 4 Case Else: Target.Interior.ColorIndex = xlNone End Select End Sub Private Sub Worksheet_Change(ByVal Target As Range) Select Case Target Case " ": Target.Interior.ColorIndex = 15 ' gri Case "A": Target.Interior.ColorIndex = 3 ' krmz Case "B": Target.Interior.ColorIndex = 3 Case "A&B": Target.Interior.ColorIndex = 3 Case "-": Target.Interior.ColorIndex = 4 ' yeil Case Else: Target.Interior.ColorIndex = xlNone End Select End Sub Range("B2").Interior.ColorIndex = 6 'Dolgu rengi sar Range("B2").Font.ColorIndex = 3 'Font rengi krmz Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column > 0 And Not Target = "" Then MsgBox "ierik deiti" End If End Sub
Dim eski Private Sub Worksheet_SelectionChange(ByVal Target As Range) If eski <> Empty Then Range(eski).Interior.ColorIndex = 6 Range(eski).Font.ColorIndex = 3 Range(eski).Font.Bold = False Range(eski).Font.Italic = False End If If Target.Column = 1 And Target.Row < 21 Then Selection.Interior.ColorIndex = 3 Selection.Font.ColorIndex = 6 Selection.Font.Bold = True Selection.Font.Italic = True eski = Target.Address(False, False) End If End Sub Sub renk() yazirenkkodu = Range("A1").Font.ColorIndex hucrerenkkodu = Range("A1").Interior.ColorIndex End Sub Sub sec() Range("A2").EntireColumn.Select End Sub Sub satsec() Range("A2").EntireRow.Select Do While ActiveCell.Value <> "" Loop End Sub Sub satsec() ActiveCell.EntireRow.Select End Sub Sub InsertionComment() Dim MyCmt As String Dim LaCell As Range Set LaCell = Application.InputBox("Cliquez sur une cellule", Default:=ActiveCell.Address, Type:=8) MyCmt = InputBox("Inscrivez votre commentaire") On Error Resume Next With LaCell .AddComment With .Comment .Visible = True .Text Text:=MyCmt End With End With End Sub Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range) If Target.Address = Sh.Range("pir").Address Then Sh.Name = szRenameSheet(Sh, Target) End If End Sub Private Function szRenameSheet(ByVal Sh As Worksheet, ByVal Target As Excel.Range) As String Dim szName As String If Not IsNull(Target) Then szName = CStr(Target.Value) With Application.WorksheetFunction szName = .Substitute(szName, ":", "") szName = .Substitute(szName, "/", "") szName = .Substitute(szName, "\", "") szName = .Substitute(szName, "?", "") szName = .Substitute(szName, "*", "") szName = .Substitute(szName, "[", "") szName = .Substitute(szName, "]", "") End With szRenameSheet = Left$(szName, 31) End If End Function
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Cancel = True 'Get out of edit mode If LCase(Target.Font.Name) <> "wingdings 2" Then Exit Sub If Len(Target.Value) > 1 Then Exit Sub If Trim(Target.Value) = "" Then Target.Value = "P" Else Target.Value = "" End If End Sub Not: hcrenin yaz fontu wingdings 2 olmal. Sub hucreduzenle() Application.ScreenUpdating = False Dim strOld As String, strNew As String strOld = Range("A1").Value strNew = InputBox("Yeni Metniniz:", "Hcre Dzenle", strOld) If strNew <> "" Then Range("A1").Value = strNew End Sub Sub Wert_aus_inputBox_in_A1() Cells(1, 1) = InputBox("A1 hcresine yazlacak deeri girin:") End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address(False, False) <> "A1" Then Exit Sub If Target <> "" Then Image1.Picture = LoadPicture("C:\1.jpg") Else Image1.Picture = LoadPicture("") End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Range("A1").Value = 1 Then Range("D54").Select ElseIf Range("A1").Value = 2 Then Range("C12").Select ElseIf Range("A1").Value = 3 Then Range("H45").Select End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address(False, False) = "A1" And Not Target = "" Then Range("C1") = Range("A1") + Range("B1") End If End Sub Range(C3).Formula ==D3+D4 - ->Formul atanr. Sub ModifFormule() Application.SendKeys "{f2}" 'Envoie la touche F2 For I = 1 To 10 'Boucle pour mettre le curseur gauche Application.SendKeys "{f3}" Next I Application.SendKeys "{f4}" 'Pour crire droite du signe = Application.SendKeys "{P}{r}{i}{x}{.}{x}{l}{s}{!}" Application.SendKeys "{Enter}" 'Valide la formule End Sub Sub einlesen() datnam = InputBox("Geben Sie den Dateinamen ein (ohne Endung):") Range("B4").Formula = "=[" & datnam & ".xls]Tabelle1!A1" Range("A4") = "Wert aus der Datei " & datnam & ".xls :" End Sub Sub EnterFormula() Worksheets("Sayfa1").Range("D6").Formula = "=SUM(D2:D5)" End Sub Range("B2").Formula="=A1+A2" 'A1 ve A2 hcresini toplar,B2 ye yazdrr
Birok yolu var da, bir tanesi : Kod: ilkhucre = ActiveCell.Offset(0, 1).Address sonhucre = ActiveCell.Offset(0, 2).Address ActiveCell.Offset(0, 1).Formula = "=Sum(" & ilkhucre & ":" & sonhucre & ")" _________________ Buras Excel vadisi .... _________________
Teekkrler raider.. bu syntaxte hata yaptm diye 10 eidini denedim ama sen yaznca emin oldum ve baka yerde olduunu anladm hatann.. Sorarken address'leri yazmamm ama oda deil koddaki hata.. ilk satrda ilkhucre'yi hcre referans olarak alp sonraki satrda onu toplamda kullanmm.. Tabi ilkhucre, birincihucre, enilkhucre diye isimler verince bana Kod: ilkhucre = ActiveCell.Offset(SatirSayisi + 2, 1) .address sonhucre = ActiveCell.Offset(ilkhucre + KacFatura, 1).address
A1:A10 arasi hcrelerinin uzerine gelindiginde makro calisin. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Target, Range("a1:a10")) Is Nothing Then Exit Sub makroadi() End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) ActiveSheet.Shapes("Rectangle 1").Height = Range("A1") / 10 * 3.2 * 72 / 2.54 End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) 'Von Thomas Ramel Dim rngZelle As Range Dim rngNachfolger As Range On Error Resume Next For Each rngZelle In Target rngZelle.NoteText Format(rngZelle.Value, "#,##0.00") For Each rngNachfolger In rngZelle.Dependents rngNachfolger.NoteText Format(rngNachfolger.Value, "#,##0.00") Next rngNachfolger Next rngZelle End Sub Sub GetRange() Dim Rng As Range On Error Resume Next Set Rng = Application.InputBox(prompt:="Enter range", Type:=8) If Rng Is Nothing Then MsgBox "Operation Cancelled" Else Rng.Select End If End Sub Sub SelectCell() Application.GoTo Reference:=ActiveSheet.Range("F1"), Scroll:=True End Sub Sub range_input() Dim pir As String pir = InputBox("Formlde Girebilirsiniz", "Hcreye yazlacak metni yaznz") Range("A1").Value = pir End Sub
Option Explicit Sub setKey() Application.OnKey "+^:", "EnterTime" End Sub Sub resetKey() Application.OnKey "+^:" End Sub Sub EnterTime() With ActiveCell .Value = Time() .NumberFormat = "hh:mm:ss" End With End Sub alma sayfasnda herhangi bir hcreye 1 yazldnda 1'e karlk gelen cmle otomatik yazlr. Private Sub Worksheet_Change(ByVal Target As Excel.Range) If IsEmpty(Target) Then Exit Sub If Target = "1" Then Target = "Selam" If Target = "2" Then Target = "Merhaba" If Target = "3" Then Target = "Ad Soyad" If Target = "4" Then Target = "Adres" End Sub Range (B5).Value=36' - -> B5 hcresine 36 atanr. Function ColumnLetter(ColumnNumber As Integer) As String If ColumnNumber > 26 Then ColumnLetter = Chr(Int((ColumnNumber - 1) / 26) + 64) & Chr(((ColumnNumber - 1) Mod 26) + 65) Else ColumnLetter = Chr(ColumnNumber + 64) End If End Function 'Kullanl 'A1=11 olsun B1=Columnletter(A1) 'sonu A1=K olur Sub SL() Sheets("Sayfa1").Select Set ALAN1 = [A2] Set ALAN2 = [B2] If ALAN1 <> "" Then Sheets("Sayfa1").Range(ALAN1).ClearContents If ALAN2 <> "" Then Sheets("Sayfa2").Range(ALAN2).ClearContents Sheets("Sayfa1").Select MsgBox "LEM TAMAMLANMITIR.", vbInformation End Sub rnek kodu biraz deitirdim. Aadaki ekilde deneyin. Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Intersect(Target, [a1:b7]) Is Nothing Or Not Intersect(Target, [c18:c21]) Is Nothing Then If sifre = False Then c = InputBox("ifre yaznz. (ifre : 123 )", "Onay ifresi") If c <> 123 Then Application.Undo Else sifre = True End If End If End If Application.EnableEvents = True End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Zelle = Target.Address Select Case Zelle Case "$D$2" Range("$D$2").ColumnWidth = 52 'entspricht 369 Pixel Case Else Range("$D$2").ColumnWidth = 16.43 'entspricht 120 Pixel End Select End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Set rng = Columns("B:B") If Not (Intersect(Target, rng) Is Nothing) Then rng.ColumnWidth = 30 Else rng.ColumnWidth = 10.71 End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address(False, False) = "A1" Then UserForm1.Show End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$C$3" Then MsgBox "Changed It!" End If End Sub Sub Labels() With Worksheets("Sheet1") .Range("A1") = "Name" .Range("B1") = "Address" .Range("A1:B1").Font.Bold = True End With End Sub Sub Macro1() Sheets("Sheet1").Select Range("A1").Select ActiveCell.FormulaR1C1 = "Name" Range("B1").Select ActiveCell.FormulaR1C1 = "Address" Range("A1:B1").Select Selection.Font.Bold = True End Sub Sub UniondePlage() Dim plg1, plg2, ToutePlage As Range Set plg1 = Sheets("Feuil1").Range("A1:A10") Set plg2 = Sheets("Feuil1").Range("B10:B20") Set ToutePlage = Union(plg1, plg2) ToutePlage.Interior.ColorIndex = 5 End Sub Sub pourcentage() Dim mycell, myvaleur, pourcent pourcent = InputBox("Quel pourcentage appliquer?") If IsNumeric(pourcent) Then For Each mycell In Application.Selection.Cells myvaleur = mycell.Value If IsNumeric(myvaleur) Then 'teste si la cellule n'est pas vide ou contient une formule If Not (IsEmpty(myvaleur) Or mycell.HasFormula) Then mycell.Value = myvaleur * (pourcent / 100 + 1) End If End If Next mycell End If End Sub Range("A1").NumberFormat = "@" Sub Makro1() Range("A2,B4,E6,F2:F21").Select Range("F2").Activate Selection.NumberFormat = "[$$-409]#,##0.00" Range("A1").Activate End Sub Private Sub Worksheet_Change(ByVal Target As Range) If [a10].Value <> [c10].Value Then MsgBox ("Girdiiniz rakamlar farkl") End Sub
Sub ResetTest3() For Each amount In Range("I1:I13") If amount.Value <> 0 Then amount.Value = 0 End If Next amount End Sub Sub OZamanSizefinMantnAnlataymSizzmleyin() If [A1].Value >= 1 Then [B1].Value = 1 'Eer A1 >= ise 1 e [B1]=1 yaz If [A1].Value >= 2 And [A1].Value <= 3 Then [B1].Value = 3 'Eer A1 >= 2 ise ve [A1].Value <= 3 ise [B1]=3 yaz End Sub hcrenin a1 hcresi, 'hcre deeri + ise "hcrede + iareti var" deil ise "hcrede + iareti yok" 'mesajn vermek istediimizi varsayarsak.
If cells(1,1) = "+" Then msgbox "hcrede + iareti var" Else msgbox "hcrede + iareti yok" End If Sub GetInput() Dim MyInput MyInput = InputBox("Adnz Giriniz") MsgBox ("Merhaba ") & MyInput End Sub Sub Asteriks() Dim i As Integer Dim j As Integer Dim Sayac As Integer Dim SinananVeri As String Veri = InputBox("Aranan Veriyi Belirtiniz", "ARANAN VER", "") SinananVeri = "*" & Veri & "*" Set Say1 = Worksheets("Sayfa1") Set Say2 = Worksheets("Sayfa2") j=1 For i = 1 To 10 If WorksheetFunction.CountIf(Say2.Cells(i, 1), SinananVeri) > 0 Then Say1.Cells(j, 1) = Say2.Cells(i, 1) Sayac = Sayac + 1 j=j+1 End If Next i MsgBox Say2.Name & "'de aram olduunuz " & Veri & " verisini ieren toplam " & Sayac & " adet hcre deeri bulundu ve " & Say1.Name & "'de liste End Sub Private Sub CommandButton1_Click() ara = InputBox("Ltfen aramak istediiniz ad yaznz ve OK tuuna basnz.Byk/kk harf duyarldr.") For i = 0 To ListBox1.ListCount - 1 If ListBox1.List(i, 0) = ara Then ListBox1.ListIndex = i Exit Sub End If Next MsgBox (ara & " kaydna veya benzer bir kayda ulalamad."), , "ListBoxta Ara bul" End Sub Private Sub UserForm_initialize() Sheets("Sayfa2").Select ListBox1.ColumnCount = 1 ListBox1.RowSource = "a1:a50" ListBox1.ColumnHeads = False End Sub On Error GoTo 10 Application.DisplayAlerts = False sor = InputBox("Silinecek sayfa adn yaznz.") If sor = "" Then Exit Sub mesaj = MsgBox("silmek istediinizden eminmisiniz", vbYesNo) If mesaj = vbNo Then Exit Sub Sheets("" & sor).Delete Exit Sub 10 MsgBox "sayfa bulunamad"
On Error Resume Next Dim Sayfa As Variant Sayfa = InputBox("Sayfa Numarasn Giriniz", "UYARI", "1") Sheets(Sayfa).Select Sub NeuesTabBlatt() Dim NewName As String ActiveSheet.Copy Before:=Sheets(1) 'ganz links anordnen 'ActiveSheet.Copy Before:=ActiveSheet 'links neben Original anordnen NewName = InputBox("Geben Sie einen Tabellenblattnamen ein") On Error Resume Next ActiveSheet.Name = NewName End Sub Sub a() b = InputBox("aaaa") If b = "" Then [a1]=1 End If End Sub Aadaki kod sanrm iinizi grecektir. Cancel butonuna bastnzda A1 hcresine 1 yazar;"[a1]=1" yazan yere kendi kodunuzu yaznz. selamlar Kod: Sub a() b = InputBox("aaaa") If b = "" Then [a1]=1 End If End Sub Private Declare Function apiGetUserName Lib _ "advapi32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, _ nSize As Long) _ As Long ' Sub Auto_Close() Sheets(1).Range("A1") = "Son Kullanc :" Sheets(1).Range("B1") = fGetUserName Sheets(1).Range("C1") = Now End Sub ' Function fGetUserName() As String Dim lngLen As Long, lngRet As Long Dim strUserName As String strUserName = String$(254, 0) lngLen = 255 lngRet = apiGetUserName(strUserName, lngLen) If lngRet Then fGetUserName = Left$(strUserName, lngLen - 1) End If End Function Sub ip() strComputer = "." Set objWMIService = GetObject( _ "winmgmts:\\" & strComputer & "\root\cimv2") Set IPConfigSet = objWMIService.ExecQuery _ ("Select IPAddress from Win32_NetworkAdapterConfiguration" _ & " where IPEnabled=TRUE") For Each IPConfig In IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i = LBound(IPConfig.IPAddress) _ To UBound(IPConfig.IPAddress) MsgBox IPConfig.IPAddress(i) Next End If Next End Sub
Sub Test() 'IP adresi - 02/09/2005 ' Raider If Err.Number <> 0 Then MsgBox "WMI yklenmemi! Programdan klacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub On Error GoTo 0 End If strComputer = "." Set objWMI = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set collIP = objWMI.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE") For Each RetVal In collIP If Left(RetVal.IPAddress(0), 1) <> 0 Then MsgBox "IP adresi :" & RetVal.IPAddress(0), vbInformation, _ "IP Adresi .... Raider " End If Next End Sub
#REF! If [A1] = 1 Then [A2].Value = 1 ElseIf [A1] = 2 Then [A2].Value = 2 ElseIf [A1] = 3 Then [A2].Value = 3 ElseIf [A1] = 4 Then [A2].Value = 4 ElseIf [A1] = 5 Then [A2].Value = 5 ElseIf [A1] = 6 Then [A2].Value = 6 ElseIf [A1] = 7 Then [A2].Value = 7 ElseIf [A1] = 8 Then [A2].Value = 8 ElseIf [A1] = 9 Then [A2].Value = 9 ElseIf [A1] = 10 Then [A2].Value = 10 ElseIf [A1] = 11 Then [A2].Value = 11 ElseIf [A1] = 12 Then [A2].Value = 12 ElseIf [A1] = 13 Then [A2].Value = 13 ElseIf [A1] = 14 Then [A2].Value = 14 ElseIf [A1] = 15 Then [A2].Value = 15 ElseIf [A1] = 16 Then [A2].Value = 16 ElseIf [A1] = 17 Then [A2].Value = 17 End If End Sub Sub deneme() MsgBox (IIf(IIf(Range("I2").Value = Range("E2").Value, Range("G2").Value - Range("F2"), (Range("G2").Value - Range("F2").Value) - Range("A500").Va End Sub
Merhaba aadaki kodda if lerden sadece birini altryor eer >< bu iaretlerin yanna = iareti koyarsam = iareti olan alyor If Range("L6") > Range("m6") Then UserForm1.Label3.Caption = "x" End If If Range("L6") < Range("m6") Then UserForm1.Label3.Caption = "$" End If If Range("L6") = Range("m6") Then UserForm1.Label3.Caption = "--" End If Private Sub Worksheet_Change(ByVal Target As Range) If [a10].Value <> [c10].Value Then MsgBox ("Girdiiniz rakamlar farkl") End Sub
Bu ilk sorunuza cevap olabilir. almanz ne ekilde tam bilemiyorum ama sanki Koullu Biimlendirme daha ok iinizi grr gibi geldi bana. C stununu s Public cik As Integer 'Bu ksm kodlarnzn en banda olmal. Private Sub UserForm_Activate() Do Label9 = format(Now, "dd.mm.yyyy hh,mm,ss") bugn.Value = format(Date, "dddd") tarih.Value = format(Now, "dd,mm,yyyy") saat.Value = format(Time, "hh,mm") DoEvents Loop While cik <> 1 End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) cik = 1 Unload Me End Sub Sub Auto_Open() [M1] = WorksheetFunction.Sum(Range("L1:L65536")) - WorksheetFunction.Sum(Range("J1:J65536")) End Sub
Option Explicit Function YMD(Day1 As Date, Day2 As Date) As String Dim years, months, days, m years = Year(Day2) - Year(Day1) If Month(Day1) > Month(Day2) Then years = years - 1 End If If Month(Day2) < Month(Day1) Then months = 12 - Month(Day1) + Month(Day2) Else months = Month(Day2) - Month(Day1) End If If Day(Day2) < Day(Day1) Then months = months - 1 If Month(Day2) = Month(Day1) Then years = years - 1 months = 11 End If End If days = Day(Day2) - Day(Day1) If days < 0 Then m = CInt(Month(Day2)) - 1 If m = 0 Then m = 12 Select Case m Case 1, 3, 5, 7, 8, 10, 12 days = 31 + days Case 4, 6, 9, 11 days = 30 + days Case 2 If (Year(Day2) Mod 4 = 0 And Year(Day2) _ Mod 100 <> 0) Or Year(Day2) Mod 400 = 0 Then days = 29 + days Else days = 28 + days End If End Select End If YMD = CStr(years) + " years " + CStr(months) _ + " months " + CStr(days) + " days " End Function A1 de balang, A2 de biti tarihi, sayfa2 A1 den itibaren aaya doru gnleri yazar balang ve biti tarihi de dahil Sub Listele() Baslangic = Sheets("Sayfa1").Range("A1").Value Bitis = Sheets("Sayfa1").Range("A2").Value Gun = Baslangic Satir = 1 Do Sheets("Sayfa2").Cells(Satir, 1).Value = Gun Gun = Gun + 1 Satir = Satir + 1 Loop While Gun <= Bitis End Sub A1 de balang, B1 de biti tarihi, A2 den itibaren aaya doru gnleri yazar balang ve biti tarihi hari Private Sub CommandButton1_Click() Dim i, j As Integer j = Worksheets("Sayfa1").Range("B1") - Worksheets("Sayfa1").Range("A1") If j < 2 Then Exit Sub End If For i = 1 To j - 1 Cells(i + 1, 1) = Cells(1, 1) + i Next i End Sub
Private Sub CommandButton1_Click() Dim x As Date For i = 2 To Sheets("EVRAK DEFTER").Cells(65536, 1).End(xlUp).Row x = Sheets("EVRAK DEFTER").Cells(i, 3) If x >= CDate(ComboBox1.Value) And x <= CDate(ComboBox2.Value) Then listbox1.additem Sheets("EVRAK DEFTER").Cells(i, 1) & "-" & Sheets("EVRAK DEFTER").Cells(i, 2) & "-" & Sheets("EVRAK DEFTER").Cells(i, 3) & "-
End If Next i End Sub Range("AZ2:BC65536").ClearContents Set ad = Sheets("DATA") sat = WorksheetFunction.CountA(ad.Range("A2:A65536")) c=0 d=0 For satr = 2 To sat + 2 If ad.Cells(satr, 2).Value >= CDate(TextBox1.Value) And ad.Cells(satr, 2).Value <= CDate(TextBox2.Value) Then c=c+1 d = d + ad.Cells(satr, 4).Value Cells(c + 1, 52) = ad.Cells(satr, 1).Value Cells(c + 1, 53) = ad.Cells(satr, 2).Value Cells(c + 1, 54) = ad.Cells(satr, 3).Value Cells(c + 1, 55) = ad.Cells(satr, 4).Value End If Next satr If c = 0 Then MsgBox ("Bu tarihler aras veri bulunamad") Exit Sub End If TextBox4 = d adres = "ANAMEN!AZ2:BC" & c + 1 ListBox1.RowSource = adres End Sub Gitmek stenilen Sayfalara Bir Buton ekleyin.Sayfalarn adlar Ana Sayfa ve UL185213 olsun.Modlede u kodlar yazn Kod: Sub UL185213() Sheets("UL185213").Select Range("A1").Select End Sub UL185213 Sayfasnada ayn butondan ekleyin. Modlede Kod: Sub anasayfa() Sheets("Ana Sayfa").Select Range("A1").Select End Sub
Sub Sifirla1() Dim rwIndex As Integer Dim colIndex As Integer For rwIndex = 1 To 10 For colIndex = 1 To 5 If Cells(rwIndex, colIndex).Value <> 0 Then _ Cells(rwIndex, colIndex).Value = 0 Next colIndex Next rwIndex End Sub 'stteki ile ayn ancak, (if) yerine (with) kullanlmtr. Sub Sifirla2() Dim rwIndex As Integer Dim colIndex As Integer For rwIndex = 1 To 10 For colIndex = 1 To 5 With Cells(rwIndex, colIndex) If Not (.Value = 0) Then Cells(rwIndex, colIndex).Value = 0 End With Next colIndex Next rwIndex End Sub Sub EnterInfo() Dim i As Integer Dim cel As Range Set cel = ActiveCell For i = 1 To 10 cel(i).Value = 100 Next i cel(i).Value = "=SUM(R[-10]C:R[-1]C)" End Sub Private Sub UserForm_Initialize() OptionButton1.Value = True End Sub Range("A1").select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop '----------------'A1 dolu ise A2 yi seecektir, oda dolu ise A3 ... 'Kaydnz sra ile kaydedebilirsiniz. sat=Cells(65536, "A").End(xlUp).Row + 1 'A stununda son dolu satra 1 ekle(bosatr) Cells(sat, "A").Value = TextBox1.Value * '1 bo satrdaki hcreyi textbox1 e yaz Cells(sat, "A").NumberFormat = "#,##0.00" 'ayni hcreyi saysal formatla Sub SentenceCase() For Each cell In Selection.Cells s = cell.Value Start = True For i = 1 To Len(s) ch = Mid(s, i, 1) Select Case ch Case "." Start = True Case "?" Start = True Case "a" To "z" If Start Then ch = UCase(ch): Start = False Case "A" To "Z" If Start Then Start = False Else ch = LCase(ch) End Select Mid(s, i, 1) = ch Next cell.Value = s Next End Sub
Sub TitleCase() Dim cell As Range For Each cell In Selection.Cells If cell.HasFormula = False Then cell = Application.Proper(cell) End If Next End Sub Sub sayfaolustur() Application.ScreenUpdating = False ad = ActiveSheet.Name tarih = [c1] [c:c].ClearContents songun = Day(DateSerial(Year(tarih), Month(tarih) + 1, 1) - 1) For a = 1 To songun deg = Weekday(DateSerial(Year(tarih), Month(tarih), a), vbMonday) If deg < 6 Then c=c+1 Cells(c, "c") = DateSerial(Year(tarih), Month(tarih), a) Sheets.Add After:=Sheets(Sheets.Count) Sheets(Sheets.Count).Name = a Sheets(ad).Select End If Next End Sub Private Sub Worksheet_selectionChange(ByVal Target As Range) If Target.Column = 1 And IsEmpty(Target.Next) Then Target.Offset(0, 2).Select End Sub hcre atlayp 4 nc hcre seilecek sanrm
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, [c1:c20]) Is Nothing Then Exit Sub If Target <> 0 Then Target.Offset(0, 4).Select End Sub Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox5.SetFocus End Sub Private Sub TextBox4_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then TextBox5.SetFocus ElseIf KeyCode = 40 Then TextBox5.SetFocus End If End Sub Sub indistest2() sonuc = WorksheetFunction.Index(Sheets("tablo").Range("A1:G16"), _ WorksheetFunction.Match(Sheets("tablo").Range("K1"), _ Sheets("tablo").Range("A1:A16"), 0), _ WorksheetFunction.Match(Sheets("tablo").Range("L1"), _ Sheets("tablo").Range("A1:G1"), 0)) MsgBox (sonuc) End Sub Hseyin bey verdiiniz her iki kodda gayet gzel alyor. Her ikisinide kullanmam mmkn,fakat tercihimi birinci koddan yana kullanyorum. Vermi oldu selamlar visual basic kodu: Sub indisdene() sonuc = Cells(Range("A2:A16").Find([K1]).Row, Range("B1:G1").Find([L1]).Column).Value MsgBox (sonuc) End Sub Sub indisdene() sonuc = Cells(Range("A2:A16").Find([K1]).Row, Range("B1:G1").Find([L1]).Column).Value MsgBox (sonuc) End Sub Sub dene() MsgBox WorksheetFunction.Index([ADI], 2) End Sub
Sub inputsheetcopy() Dim TBName$, WBName$ TBName = InputBox("Blattname:") If TBName = "" Then Exit Sub WBName = InputBox("Dateiname:") If WBName = "" Then Exit Sub Worksheets(TBName).Copy ActiveWorkbook.SaveAs WBName ActiveWorkbook.Close End Sub Sub DecideUserInput() Dim bText As String, bNumber As Integer ' here is the INPUTBOX-function : bText = InputBox("Insert in a text", "This accepts any input") ' here is the INPUTBOX-method : bNumber = Application.InputBox("Insert a number", "This accepts numbers only", , , , , , 1) MsgBox "You have inserted :" & Chr(13) & _ bText & Chr(13) & bNumber, , "Result from INPUT-boxes" End Sub
Sub MainProgram() ' 'Ana programin kodlari buralarda ' ' 'Asagidaki satirla "*" karakterli sifre girme kutusunu agiriyoruz ' MyPasswBox ' 'Eger kullanici bir sifre girdiyse, 'asagidaki satirlarda, kullanicinin girdigi sifreyi '"iplak" olarak grntlyoruz. ' 'Sizin yapmaniz gereken If - End If satirlari arasinda 'sifre kontrolunu yaptirip, kodlari alismaniza gre ynlendirmek olucak If MyPass <> "" Then MsgBox "Girilen sifre : " & MyPass End If ' 'Ana programin kodlarinin devami buralarda ' End Sub ' Sub MyPasswBox() Dim PassWForm Set PassWForm = ThisWorkbook.VBProject.VBComponents.Add(3) PassWForm.properties("Width") = 200 PassWForm.properties("Height") = 90 Set NewTextBox = PassWForm.Designer.Controls.Add("forms.TextBox.1") PassWForm.properties("Caption") = "Sifre girisi !" With NewTextBox .Width = 120 .Height = 18 .Left = 8 .Top = 20 .PasswordChar = "*" .ForeColor = vbRed End With Set NewCommandButton1 = PassWForm.Designer.Controls.Add("forms.CommandButton.1") With NewCommandButton1 .Caption = "Vazge" .Height = 18 .Width = 50 .Left = 140 .Top = 18 End With Set NewCommandButton2 = PassWForm.Designer.Controls.Add("forms.CommandButton.1") With NewCommandButton2 .Caption = "Tamam" .Height = 18 .Width = 50 .Left = 140 .Top = 42 End With With PassWForm.CodeModule X = .CountOfLines .InsertLines X + 1, "Sub CommandButton1_Click()" .InsertLines X + 2, "Unload Me" .InsertLines X + 3, "End Sub" .InsertLines X + 4, "Sub CommandButton2_Click()" .InsertLines X + 5, "MyPass = TextBox1" .InsertLines X + 6, "Unload Me" .InsertLines X + 7, "End Sub" .InsertLines X + 8, "Sub UserForm_Activate()" .InsertLines X + 9, "Me.SpecialEffect=3" .InsertLines X + 10, "End Sub" End With VBA.UserForms.Add(PassWForm.Name).Show ThisWorkbook.VBProject.VBComponents.Remove VBComponent:=PassWForm End Sub
Sub input_comment() Dim pir Dim n As Variant Dim l As Long pir = InputBox("Yaz yazn aklama olarak eklesin.", _ "input_aklama") n = ActiveCell.NoteText l = Len(n) If l > 0 Then ActiveCell.NoteText Text:=" / " & pir, Start _ :=l + 1 Else ActiveCell.NoteText Text:=pir End If End Sub Sub Filtrele() sec = InputBox("Neyi Filtrelemek stiyorsunuz", , "Pazartesi") Range("A1:" & [A65536].End(xlUp).Address).AutoFilter 1, sec End Sub Sub FiltrleneniSil() Range("A2:" & [A65536].End(xlUp).Address).SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp End Sub Sub hesaplama() zamoran: z = InputBox("Zam orann giriniz ! Ondalk ksm varsa virglle ayrnz !") If Not IsNumeric(z) Then GoTo zamoran Cells(1, 23) = (z + 100) / 100 End Sub Sub GetInput() Dim MyInput MyInput = InputBox("Enter your name") MsgBox ("Hello ") & MyInput End Sub
strJahr = InputBox("Kalender anlegen fr Jahr:", , Year(Date)) If strJahr = "" Or Not IsNumeric(strJahr) Then Exit Sub intJahr = CInt(strJahr) lngNumSheets = Application.SheetsInNewWorkbook Application.SheetsInNewWorkbook = 12 Workbooks.Add Application.SheetsInNewWorkbook = lngNumSheets Application.DisplayAlerts = False Application.ScreenUpdating = False Windows(1).Caption = "Jahreskalender " & strJahr For intI = 1 To 12 Worksheets(intI).Activate Call MonatAnlegen(intJahr, intI) Next intI Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub Private Sub MonatAnlegen(intJahr As Integer, intMonat As Integer) Dim intI As Integer Dim lngDate As Long lngDate = CLng(DateSerial(intJahr, intMonat, 1)) ActiveSheet.Name = Format(lngDate, "mmmm") 'zB "Januar" Range("A1") = "Datum" Range("C1") = "Eintragung" Range("D1") = "Geburtstage" With Range("A1:D1") With .Font .Bold = True .Size = 10 .ColorIndex = 6 End With .Interior.ColorIndex = 11 End With intI = DateSerial(intJahr, intMonat + 1, 1) - lngDate + 1 Range("A2") = lngDate Range("A3").Formula = "=A2+1" Range("A3:A" & intI).FillDown Range("A2:A" & intI).Copy Range("A2:A" & intI).PasteSpecial (xlValues) Range("A2:A" & intI).NumberFormat = "dd.mm.yy" Columns(1).Copy Columns(2) Range("B1") = "Tag" Range("B1").HorizontalAlignment = xlRight Range("B2:B" & intI).NumberFormat = "dddd" 'zB "Samstag" Range("C2").Select intI = 2 Do Until IsEmpty(Cells(intI, 1)) Select Case Weekday(Cells(intI, 1)) Case vbSaturday Range(Cells(intI, 1), Cells(intI, 2)).Interior.ColorIndex = 40 'Orange Case vbSunday Range(Cells(intI, 1), Cells(intI, 2)).Interior.ColorIndex = 3 'Rot End Select Cells(intI, 3).Value = Feiertag(Cells(intI, 1).Value) intI = intI + 1 Loop ActiveSheet.UsedRange.Columns.AutoFit End Sub 'http://home.t-online.de/home/t.igel/xlostern.htm Private Function Feiertag(datum As Long) As String Dim temp As Variant Feiertag = "" Select Case Month(datum) Case 1 Select Case Day(datum) Case 1 Feiertag = "Neujahr" Case 6
Sub BoslariSec() On Error Resume Next Dim x, y As Integer x = InputBox("x deerini gir") y = InputBox("y deerini de gir") Range("A1").Clear For Each sec In Range("J" & x & ":J" & y) If sec.Value = "" Then k = k + sec.Address & "," End If Next sec k = Mid(k, 1, Len(k) - 1) Range(k).Select End Sub Sub Makro1() On Error Resume Next ka = InputBox("Bu sayfadan ka adet yazdrmak istiyorsunuz?") ActiveWindow.SelectedSheets.PrintOut Copies:=ka, Collate:=True End Sub Sub yazdir() ilk=inputbox("Yazdrmaya balanacak Sayfa Numaras") son=inputbox("sonlandrlacak Sayfa Numaras") Kopyasayisi=inputbox("Kopya Saysn Giriniz") ActiveWindow.SelectedSheets.PrintOut From:=ilk, To:=son, Copies:=Kopyasayisi, Collate:=True End Sub Sub Wert_aus_inputBox_in_A1() Cells(1, 1) = InputBox("Bitte geben Sie den Wert ein, der in Zelle A1 geschrieben werden soll:") End Sub
Dim MyStr As String, InfoMsg As String Dim Rng1 As String, LookupValue As String Dim MyQ As VbMsgBoxResult Dim FoundRng As Variant MyStr = Trim(Application.InputBox("Aranacak metni girin !", _ "Find exact match ...")) If Not MyStr = "False" Then Set FoundRng = Cells.Find(MyStr, LookIn:=xlValues, LookAt:=xlPart) If Not FoundRng Is Nothing Then Rng1 = FoundRng.Address FoundRng.Activate ResumeSub2: If Right(FoundRng.Value, 1) <> " " Then LookupValue = FoundRng.Value & " " MyData = Split(LookupValue, " ", , vbTextCompare) For i = LBound(MyData) To UBound(MyData) If MyData(i) = MyStr Then InfoMsg = "Aranan metin " & FoundRng.Address(False, False) _ & " hcresinde bulundu." _ & vbCrLf & vbCrLf & "Bulunan hcrenin ierii :" _ & vbCrLf & vbCrLf & FoundRng.Value & vbCrLf _ & vbCrLf & "Aramaya devam etmek istiyormusunuz ?" MyQ = MsgBox(InfoMsg, vbInformation + vbYesNo, _ "Arama sonucu...") If MyQ = vbYes Then GoTo ResumeSub1: Exit Sub End If Next Else MsgBox "Aranan deer bulunamad !", vbInformation, "Arama sonucu..." Exit Sub End If ResumeSub1: Set FoundRng = Cells.FindNext(FoundRng) If Rng1 = FoundRng.Address Then MsgBox "Aranan deerden baka bulunamad !", vbInformation, _ "Arama sonucu..." Exit Sub End If FoundRng.Activate GoTo ResumeSub2: End If Set FoundRng = Nothing End Sub Private Sub CommandButton3_Click() On Error GoTo 10 Application.DisplayAlerts = False sor = InputBox("Silinecek sayfa adn yaznz.") If sor = "" Then Exit Sub mesaj = MsgBox("silmek istediinizden eminmisiniz", vbYesNo) If mesaj = vbNo Then Exit Sub Sheets("" & sor).Delete Exit Sub 10 MsgBox "sayfa bulunamad" End Sub Private Sub CommandButton2_Click() On Error Resume Next Dim Sayfa As Variant Sayfa = InputBox("Sayfa Numarasn Giriniz", "UYARI", "1") Sheets(Sayfa).Select End Sub Sub CalcPay() On Error GoTo HandleError Dim hours Dim hourlyPay Dim payPerWeek hours = InputBox("Please enter number of hours worked", "Hours Worked") hourlyPay = InputBox("Please enter hourly pay", "Pay Rate") payPerWeek = CCur(hours * hourlyPay) MsgBox "Pay is: " & Format(payPerWeek, "$##,##0.00"), , "Total Pay" HandleError: End Sub
Sub a() b = InputBox("aaaa") If b = "" Then [a1]=1 End If End Sub Sub DecideUserInput() Dim bText As String, bNumber As Integer ' here is the INPUTBOX-function : bText = InputBox("Insert in a text", "This accepts any input") ' here is the INPUTBOX-method : bNumber = Application.InputBox("Insert a number", "This accepts numbers only", 1) MsgBox "You have inserted :" & Chr(13) & _ bText & Chr(13) & bNumber, , "Result from INPUT-boxes" End Sub Accepted input: 0 A formula 1 A number 2 Text 4 A logical value (True or False) 8 A cell reference, e.g. a Range-object 16 An error value, e.g. #N/A 64 An array of values Sub Tarihi_Kontrol_Et() vade = InputBox("Vade tarihini aa/gg/2004 Formatnda Giriniz", "Ltfen Vade Kriter Tarihini Giriniz", "00.00.2004") If vbOKCancel = vbOK Then If vade = Range("A1").Text Then MsgBox "Tamam" End If End Sub Sub GetRange() Dim Rng As Range On Error Resume Next Set Rng = Application.InputBox(prompt:="Enter range",Type:=8) If Rng Is Nothing Then MsgBox "Operation Cancelled" Else Rng.Select End If End Sub
Sub MessageAbrufen() Dim appWord As Object Dim docWord As Object Dim txt As String txt = LoadURL(Range("A1").Value) Set appWord = CreateObject("Word.Application") Set docWord = appWord.documents.Add With docWord.Range With .Font .Name = "Courier New" .Size = 8 End With .Text = txt End With appWord.Visible = True Set appWord = Nothing Set docWord = Nothing End Sub Function LoadURL(URL As String) As String Dim IEApp As Object Dim IEDocument As Object Set IEApp = CreateObject("InternetExplorer.Application") IEApp.Visible = False IEApp.Navigate URL Do: Loop Until IEApp.Busy = False Do: Loop Until IEApp.Busy = False Set IEDocument = IEApp.Document LoadURL = IEDocument.Body.innerText IEApp.Quit Set IEDocument = Nothing Set IEApp = Nothing End Function Private Sub CommandButton1_Click() If TestInternetConnection = False Then MsgBox "BALANTI YOK" Else MsgBox "BALANTI var" End If End Sub Sub LanceIE() Dim IE As Object Set IE = CreateObject("InternetExplorer.Application") IE.Navigate "http://dj.joss.free.fr" IE.AddressBar = True IE.MenuBar = True IE.Toolbar = True IE.Width = 800 IE.Height = 600 IE.Resizable = True IE.Visible = True Set IE = Nothing End Sub
Private Declare Function IsNetworkAlive Lib "SENSAPI.DLL" (ByRef lpdwFlags As Long) As Long Private Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Boolean Private Declare Function InternetAutodialHangup Lib "wininet.dll" (ByVal dwReserved As Long) As Boolean Const NETWORK_ALIVE_LAN = &H1 Const NETWORK_ALIVE_WAN = &H2 Sub baglan() If IsNetworkAlive(lRet) = 0 Then InternetAutodial 1, 0 End If End Sub Sub kes() If IsNetworkAlive(lRet) <>0 Then InternetAutodialHangup 0 End If End Sub otomatik balanmas iin de Sub baglan() If IsNetworkAlive(lRet) = 0 Then InternetAutodial 2, 0 End If End Sub ifre iin Call Shell("c:\windows\system32\rasdial.exe " & Chr$(34) & "ttnet" & Chr$(34) & " " & "sirenko" & " " & "sifre")
Lib "wininet" ( _ ByRef lpdwFlags As Long, _ ByVal dwReserved As Long) _ As Long Private Declare Function InternetAutodial _ Lib "wininet.dll" ( _ ByVal dwFlags As Long, _ ByVal dwReserved As Long) _ As Long Private Declare Function InternetAutodialHangup _ Lib "wininet.dll" ( _ ByVal dwReserved As Long) _ As Long Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" ( _ ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) _ As Long Private Private Private Private Private Private Private Private Private Private Private Private Const Const Const Const Const Const Const Const Const Const Const Const INTERNET_CONNECTION_CONFIGURED = &H40 INTERNET_CONNECTION_LAN = &H2 INTERNET_CONNECTION_MODEM = &H1 INTERNET_CONNECTION_OFFLINE = &H20 INTERNET_CONNECTION_PROXY = &H4 INTERNET_RAS_INSTALLED = &H10 INTERNET_AUTODIAL_FORCE_ONLINE = 1 INTERNET_AUTODIAL_FORCE_UNATTENDED = 2 S_OK = &H0 E_ABORT = &H80004004 E_ACCESSDENIED = &H80070005 E_OUTOFMEMORY = &H8007000E
Const strDownLoad As String = "http://www.salipazari-meb.gov.tr/programlar/kayit.zip" Const strDest As String = "C:\kayit.zip" Sub GetFile() Dim DwnLoadOK As Boolean DwnLoadOK = DownloadFile(strDownLoad, strDest) If Not DwnLoadOK Then MsgBox "Error downloading " & strDownLoad & vbCr & IeState Else MsgBox "Succesfully downloaded:= " & strDest End If End Sub Public Function DownloadFile( _ URL As String, _ SaveAsFileName As String) As Boolean Dim lngRetVal As Long DownloadFile = False End Function Private Function IeState() As String Dim Ret As Long Dim Msg As String InternetGetConnectedState Ret, 0& If (Ret And INTERNET_CONNECTION_CONFIGURED) = _ INTERNET_CONNECTION_CONFIGURED Then _ Msg = "Local system has a valid connection to the Internet," & _ vbCr & "but it may or may not be currently connected." If (Ret And INTERNET_CONNECTION_LAN) = _ INTERNET_CONNECTION_LAN Then _ Msg = Msg & vbCr & "Uses a local area network" & _ "to connect to the Internet." If (Ret And INTERNET_CONNECTION_MODEM) = _ INTERNET_CONNECTION_MODEM Then _
Aadakileri sz konusu dosyada yeni bir module yerletirip, kaydedin. Dosyay kapattnz anda 1nci sayfada A1, B1 ve C1 hcrelerinde gerekli bilgiler y Kod: Private Declare Function apiGetUserName Lib _ "advapi32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, _ nSize As Long) _ As Long ' Sub Auto_Close() Sheets(1).Range("A1") = "Son Kullanc :" Sheets(1).Range("B1") = fGetUserName Sheets(1).Range("C1") = Now End Sub ' Function fGetUserName() As String Dim lngLen As Long, lngRet As Long Dim strUserName As String strUserName = String$(254, 0) lngLen = 255 lngRet = apiGetUserName(strUserName, lngLen) If lngRet Then fGetUserName = Left$(strUserName, lngLen - 1) End If End Function Sub Blatt_als_Datei() datname = InputBox("Dateiname:") ActiveSheet.Copy ActiveWorkbook.SaveAs datname ActiveWorkbook.Close End Sub dzeltilmi ve biraz daha hzlandrlm. 1. veriler sral deilse Kod: z = Cells(65536, 1).End(xlUp).Row Application.ScreenUpdating = False For i = 1 To z For j = z To i + 1 Step -1 If Cells(i, 1) = Cells(j, 1) Then Range(j & ":" & j).EntireRow.Delete End If Next j Next i 2. veriler sral ise Kod: z = Cells(65536, 1).End(xlUp).Row Application.ScreenUpdating = False For i = 1 To z For j = z To i + 1 Step -1 If Cells(i, 1) = Cells(j, 1) Then Range(j & ":" & j).EntireRow.Delete Else Exit For End If Next j Next i
Sub Sayfalarsfrla() '/_ 'stediiniz sayfa hari dier sayfadaki verileri temizler 'a.kkkaya / pir Dim i As Integer For i = 1 To Sheets.Count If Worksheets(i).Name <> "Rapor" Then Worksheets(i).Cells.Delete Selection.Style = "Normal" 'hcreyi reset eder yani ilk altaki haline evirir End If Next i End Sub Shapes(j).Delete Next j stediiniz sayfaya gider Sub Ali_sayfasna_git() Sheets("AL").Select End Sub Sonraki Sayfaya gemek iin kodlar Sub SayfaSeSonraki() On Error Resume Next If ActiveSheet.Index = Worksheets.Count Then Worksheets(1).Select Else On Error Resume Next Worksheets(ActiveSheet.Index + 1).Select End If End Sub nceki Sayfaya gemek iin kodlar Sub SayfaSenceki() On Error Resume Next If ActiveSheet.Index = Worksheets.Count Then Worksheets(-1).Select Else Worksheets(ActiveSheet.Index - 1).Select End If End Sub STEDNZ SAYFAYA GDER Sub Ali_sayfasna_git() Sheets("AL").Select End Sub Sonraki Sayfaya gemek iin kodlar Sub SayfaSeSonraki() On Error Resume Next If ActiveSheet.Index = Worksheets.Count Then Worksheets(1).Select Else On Error Resume Next Worksheets(ActiveSheet.Index + 1).Select End If End Sub nceki Sayfaya gemek iin kodlar Sub SayfaSenceki() On Error Resume Next If ActiveSheet.Index = Worksheets.Count Then Worksheets(-1).Select Else Worksheets(ActiveSheet.Index - 1).Select End If End Sub
Sub assist() Application.Assistant.Visible = True Assistant.Animation = msoAnimationIdle Set SB = Assistant.NewBalloon SB.Animation = msoAnimationCheckingSomething SB.BalloonType = msoBalloonTypeButtons SB.Heading = "istediiniz uyar!!" SB.Text = _ "Ich bin Dein persnlicher Assistent" If SB.Show = msoBalloonButtonOK Then Assistant.Visible = False End If end sub istediiniz yerde istediiniz uyary verdirin... Kod: Sub assist() Application.Assistant.Visible = True Assistant.Animation = msoAnimationIdle Set SB = Assistant.NewBalloon SB.Animation = msoAnimationCheckingSomething SB.BalloonType = msoBalloonTypeButtons SB.Heading = "istediiniz uyar!!" SB.Text = _ "Ich bin Dein persnlicher Assistent" If SB.Show = msoBalloonButtonOK Then Assistant.Visible = False End If end sub STENLEN ARALIKTAK VERLER TEMZLER Sub temizle() Range("a1:a20").Value = "" Range("b21:b23").Value = "" Range("a1").Select End Sub BU KODLA STEDNZ HCRELERE VER GREBLRSNZ Sub balkyaz() Range("a1").Select ActiveCell.FormulaR1C1 = "ali" Range("b1").Select ActiveCell.FormulaR1C1 = "veli" Range("c1").Select ActiveCell.FormulaR1C1 = "selami" Range("d1").Select ActiveCell.FormulaR1C1 = "aye" Range("e1").Select ActiveCell.FormulaR1C1 = "fatma" Range("f1").Select ActiveCell.FormulaR1C1 = "lale" End Sub
Sub PrintRpt1() 'To control orientation Sheets(1).PageSetup.Orientation = xlLandscape Range("f7").PrintOut Copies:=1 End Sub Sub PrintRpt1() Sheets(1).PageSetup.Orientation = xlLandscape Range("f7").PrintOut Copies:=1 End Sub Sub PrintRpt2() 'To print several ranges on the same sheet - 1 copy Range("A1").PrintOut Range("A3").PrintOut Range("A4").PrintOut End Sub
Sub hcresec() 'Gitmek istenilen hcreyi seer Dim Rng As Range On Error Resume Next Set Rng = Application.InputBox(prompt:="Gitmek istediiniz Hcreyi Yaznz", Type:=8) If Rng Is Nothing Then MsgBox "Seimden vazgetiniz" Else Rng.Select End If End Sub Sub ViewCode() Application.Goto Reference:="insertrow" End Sub Sub Alarm() Dim beepat As String beepat = InputBox("Give Alarm at", "hh:mm:ss " & _ Format(Now, "mm:hh"), "17:00") If beepat = "" Then MsgBox "cancelled" Exit Sub End If Application.OnTime TimeValue(beepat), "BeepMe" End Sub Sub CountDownTimer() Dim beepat As String beepat = InputBox("Count down Timer hh:mm:ss i.e. 10:00", _ "Time now is " & Format(Now, "hh:mm:ss"), "3:00") If beepat = "" Then MsgBox "cancelled" Exit Sub End If Application.OnTime (Now + TimeValue(beepat)), "BeepMe" End Sub Sub beepme() Beep Application.OnTime (Now + TimeSerial(0, 0, 0.8)), "beepme2" End Sub Sub beepme2() Beep Application.OnTime (Now + TimeSerial(0, 0, 0.8)), "beepme3" End Sub Sub beepme3() Beep End Sub Sub ProgrammeLaMacroTime() ' lance MacroImpression 10h25 heures Application.OnTime TimeValue("10:25:00"), "MacroImpression", , True End Sub Sub MacroImpression() 'cette macro imprime la feuille Feuil1 ThisWorkbook.Sheets("Feuil1").PrintOut End Sub Sub date_macro() datemacro = InputBox("rnek zaman " & Time & _ ". zaman belirt o zamanda makro alsn?") If datemacro = "" Then Exit Sub Application.OnTime TimeValue(datemacro), "makro1" 'makro1 isimli makro alr End Sub Sub makro1() MsgBox "makro1 alt" End Sub
Sub Abfrage() Dim sh Dim kw As String kw = InputBox("Bitte geben Sie Ihr Kennwort ein ...") If kw = "Meier" Then Sheets("Meier").Visible = True If kw = "Mller" Then Sheets("Mller").Visible = True If kw = "Schulz" Then Sheets("Schulz").Visible = True If kw = "Weber" Then Sheets("Weber").Visible = True If kw = "admin" Then For Each sh In ActiveWorkbook.Sheets If sh.Name <> "Auswahl" Then sh.Visible = True Next sh End If End Sub Sub AllerA() Application.Goto Reference:=Worksheets("Feuil1").Range("A154"), Scroll:=True End Sub For a = 1 To Sheets.Count If Sheets(a).Name <> "GELR CMAL" And Sheets(a).Name <> "ANASAYFA" Then Sheets(a).Visible = xlVeryHidden Next Sub DENEME() Dim i As Double i = Sheets("ANASAYFA").Range("a1").Value Worksheets("" & i).Select End Sub Sub excelerator() Dim MyShell As Object Set MyShell = CreateObject("WScript.Shell") MyShell.Run "http://www.excelerator.de" End Sub
gizleme Kod: Sub Macro2() colx = InputBox("Hangi sutunu gizlemek istiyorsun?") ' Select Sheet1 and Sheet2 and make Sheet1 the active sheet. Sheets(Array("Sayfa1", "Sayfa2")).Select Sheets("Sayfa1").Activate ' Loop through each sheet in the selected sheets and hide column ' A on that sheet. For Each Sht In ActiveWindow.SelectedSheets Sht.Columns("" & colx & ":" & colx & "").Hidden = True Next End Sub
gstermek: Kod: Sub Macro1() colx = InputBox("Hangi sutunu gstermek istiyorsun?") ' Select Sheet1 and Sheet2 and make Sheet1 the active sheet. Sheets(Array("Sayfa1", "Sayfa2")).Select Sheets("Sayfa1").Activate ' Loop through each sheet in the selected sheets and hide column ' A on that sheet. For Each Sht In ActiveWindow.SelectedSheets Sht.Columns("" & colx & ":" & colx & "").Hidden = false Next End Sub Private Sub UserForm_Activate() ' Rcupration de l'heure d'affichage de la BdD TimeDebut = Timer ' Donne la main excel pour facilit l'affichage de la BdD DoEvents ' Boucle tant que 2 secondes ne se sont pas coul While Timer < TimeDebut + 10 Wend ' Fermeture de la BdD Unload Me End Sub Private Sub UserForm_Activate() ' Rcupration de l'heure d'affichage de la BdD TimeDebut = Timer ' Donne la main excel pour facilit l'affichage de la BdD DoEvents ' Boucle tant que 2 secondes ne se sont pas coul While Timer < TimeDebut + 10 Wend ' Fermeture de la BdD Unload Me End Sub
GZLEMEK N: Sub Macro2() colx = InputBox("Hangi stunu gizlemek istiyorsun?") ' Select Sheet1 and Sheet2 and make Sheet1 the active sheet Sheets(Array("Sayfa1", "Sayfa2")).Select Sheets("Sayfa1").Activate ' Loop through each sheet in the selected sheets and hide column ' A on that sheet For Each Sht In ActiveWindow.SelectedSheets Sht.Columns("" & colx & ":" & colx & "").Hidden = True Next End Sub ' GSTERMEK N: Sub Macro1() colx = InputBox("Hangi sutunu gstermek istiyorsun?") ' Select Sheet1 and Sheet2 and make Sheet1 the active sheet Sheets(Array("Sayfa1", "Sayfa2")).Select Sheets("Sayfa1").Activate ' Loop through each sheet in the selected sheets and hide column ' A on that sheet For Each Sht In ActiveWindow.SelectedSheets Sht.Columns("" & colx & ":" & colx & "").Hidden = False Next End Sub Sub Macro2() colx = InputBox("Hangi sutunu gizlemek istiyorsun?") ' Select Sheet1 and Sheet2 and make Sheet1 the active sheet. Sheets(Array("Sayfa1", "Sayfa2")).Select Sheets("Sayfa1").Activate ' Loop through each sheet in the selected sheets and hide column ' A on that sheet. For Each Sht In ActiveWindow.SelectedSheets Sht.Columns("" & colx & ":" & colx & "").Hidden = True Next End Sub Sub Macro1() colx = InputBox("Hangi sutunu gstermek istiyorsun?") ' Select Sheet1 and Sheet2 and make Sheet1 the active sheet. Sheets(Array("Sayfa1", "Sayfa2")).Select Sheets("Sayfa1").Activate ' Loop through each sheet in the selected sheets and hide column ' A on that sheet. For Each Sht In ActiveWindow.SelectedSheets Sht.Columns("" & colx & ":" & colx & "").Hidden = false Next End Sub Sub PrinterSec() Application.ActivePrinter = "\\PRINTSERVER\HP LaserJet 1100 (MS) on Ne02:" End Sub
Aadaki kodlar ThisWorkbook ksmna yazarak baka bir alternatifi de deneyebilirsiniz. Dosya alrken belli bir yazc aktive edilmekte, kapanrken de ba Private Sub Workbook_Open() Application.ActivePrinter = "Microsoft Office Document Image Writer on Ne01:" End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.ActivePrinter = "\\PRINTSERVER\HP LaserJet 1100 (MS) on Ne02:" End Sub
Function Isgunu(Bas_Trh As Date, Son_Trh As Date) Dim Say As Integer For mars = Son_Trh To Bas_Trh Step -1 If Weekday(mars, vbMonday) = 6 Then Say = Say + 1 If Weekday(mars, vbMonday) = 7 Then Say = Say + 1 Next mars Isgunu = (Son_Trh - Bas_Trh) + 1 - Say End Function '=Isgunu(A1;B1) Sub Auto_Open()
Dim tarih As Date, i As Integer 'tarih olarak sizin isgunu fonksiyonundan kan 'tarihi kullandm tarih = isgunu(Date) If Format(tarih, "mmmm-yy") & ".xls" <> ThisWorkbook.Name Then If MsgBox("Bu aya ait bir alma kitab olmad iin yeni sayfa amadm.inci farkl kaydet yapacam kabul m?", vbYesNo) = vbYes Then ThisWorkbook.SaveAs ThisWorkbook.Path & Application.PathSeparator & Format(Date, "mmmm-yy") Sheets.Add.Name = Format(tarih, "dd-mm-yyyy") For Each sh In ThisWorkbook.Sheets If sh.Name <> Format(tarih, "dd-mm-yyyy") Then Application.DisplayAlerts = False 'veri varsa sormadan silecek. sh.Delete End If Next Exit Sub Else MsgBox "bu kitaba da yeni sayfa amadm, farkl kaydette yapmadm, hi bir ey yapmadm" Exit Sub End If End If Sayfaadi = Format(tarih, "dd-mm-yyyy") Application.DisplayAlerts = true For i = 1 To Sheets.Count If Sheets(i).Name = Sayfaadi Then Exit Sub Next i Sheets.Add.Name = Sayfaadi End Sub Sub Auto_Open() Sheets(Sheets.Count).Copy After:=Sheets(Sheets.Count) Sheets(Sheets.Count).Name = Format(Date, "dd mm yy") End Sub Sub InfoCPU() Dim MyOBJ As Object Dim MyCPU As Variant Dim MyMsg As String On Error Resume Next Set MyOBJ = GetObject("WinMgmts:").instancesOf _ ("Win32_Processor") If Err.Number <> 0 Then MsgBox "WMI yklenmemi! Programdan klacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub On Error GoTo 0 End If For Each MyCPU In MyOBJ [A1] = "lemci : " & Trim(MyCPU.Name) [A2] = "retici Firma : " & MyCPU.Manufacturer [A3] = "CPU ID : " & MyCPU.ProcessorId [A4] = "CPU hz : " & MyCPU.CurrentClockSpeed [A5] = "Max CPU hz : " & MyCPU.MaxClockSpeed Next End Sub
Option Explicit Sub ProcessorSpeed() Dim objWMI As Object Dim Cpu As Object Set objWMI = GetObject("WinMgmts:").instancesOf("Win32_Processor") '// Don't forget the computer maybe multiprocessor! For Each Cpu In objWMI MsgBox Cpu.Name & " " & Cpu.CurrentClockSpeed & " Mhz", _ vbInformation Next Set objWMI = Nothing End Sub Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'Kullanm; '1000 milisaniye kadar ilemciyi durdurur. "DoEvents" 'e benzer. Sub cal() Call Sleep(1000) End Sub Sub Geici_Dosya_smi_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") f = ds.GetTempName MsgBox f End Sub Function OSis32BIT() As Boolean OSis32BIT = False If InStr(Application.OperatingSystem, "32-bit") Then OSis32BIT = True End If End Function Sub TestOSis32BIT() If OSis32BIT Then MsgBox "You use a 32bit operating system", , _ Application.OperatingSystem Else MsgBox "You don't use a 32bit operating system", , _ Application.OperatingSystem End If End Sub Sub Dialog_35() Application.Dialogs(xlDialogFunctionWizard).Show End Sub Sub TanimliAlanSil() For Each Nm In ActiveWorkbook.Names If Nm.Name Like "Alan" Then Nm.Delete End If Next Nm End Sub Sub JokerliAlanlariSil() For Each Nm In ActiveWorkbook.Names If Nm.Name Like "Alan*" Then Nm.Delete End If Next Nm End Sub Sub auto_open() Dim jpgekle As Object Set jpgekle = ActiveSheet.Pictures.Insert("C:\arnold.jpg") Application.Wait (Now + TimeSerial(0, 0, 10)) jpgekle.Delete End Sub Sub Count() mycount = Selection.Rows.Count MsgBox mycount End Sub
Sub sayfasay() say= Application.Sheets.Count MsgBox (say) End Sub Function hafta(tarih As Date) As Integer ek = 7 - Day(DateSerial(Year(tarih), 1, 1) + 7 - Weekday(DateSerial(Year(tarih), 1, 1), vbMonday)) hafta = ((tarih + 7 - Weekday(tarih, vbMonday)) - DateSerial(Year(tarih), 1, 1) + 1 + ek) / 7 End Function Dim tarih As Date, hafta As Integer tarih = Date hafta = DatePart("ww", tarih, vbMonday, vbFirstJan1) MsgBox "Bugn: " & Date & " --> Yln " & hafta & ". Haftas" Function kacinci_hafta(Tarih As Date) As Byte Dim aybasi As Date, hsonuilk As Date Dim hgunu As Byte aybasi = DateSerial(Year(Tarih), Month(Tarih), 1) hgunu = WorksheetFunction.Weekday(aybasi, 2) hsonuilk = DateSerial(Year(aybasi), Month(aybasi), (7 - hgunu) + 1) kacinci_hafta = 1 If Day(Tarih) > Day(hsonuilk) Then kacinci_hafta = kacinci_hafta + WorksheetFunction.RoundUp((Day(Tarih) - Day(hsonuilk)) / 7, 0) End Function =Kwoche(J20) Function Kwoche(d) Dim t t = DateSerial(Year(d + (8 - Weekday(d)) Mod 7 - 3), 1, 1) Kwoche = ((d - t - 3 + (Weekday(t) + 1) Mod 7)) \ 7 + 1 End Function Private Sub CommandButton1_Click() MsgBox Weekday(Date, vbMonday) Select Case Weekday(Date, vbMonday) Case 1: gun = "Bugn pazartesi, " Case 2: gun = "Sal" Case 3: gun = "aramba " Case 4, 5: gun = "Hafta ii son gnler " Case Is > 5: gun = "Hafta Sonu" Case Else: gun="Byle bir gn olamaz" End Select MsgBox gun End Sub Sub MyPosition() myRow = ActiveCell.Row & ".satr" myCol = ActiveCell.Column & ".stun" MsgBox myRow & " , " & myCol End Sub Sub negircen() sutun = InputBox("Kanc Stun:") satir = InputBox("Kanc Satr:") yaz = InputBox("yaz:") Range("A1").Select ActiveCell.Offset(satir - 1, sutun - 1).Range("A1").Select ActiveCell.Value = yaz End Sub kullanl '=kalintop(a1:a10) Function kalintop(rngCells As Range) As Double Application.Volatile Dim cell As Range kalintop = 0 On Error Resume Next For Each cell In rngCells If cell.Font.Bold Then kalintop = kalintop + cell.Value Next cell End Function
Bunu yapmann en iyi yolu Exce2000 - ADO kullanmdr. Bu kodu kullanarak; "Microsoft ActiveX Data Objects 2.1 Library" ve "Microsoft ADO Ext. 2.1 for D Sub ReadSheetNames(TheCompleteFilePath As String) Dim cnn As New ADODB.Connection Dim cat As New ADOX.Catalog Dim tbl As ADOX.Table cnn.Open "Provider=MSDASQL.1;Data Source=" _ & "Excel Files;Initial Catalog=" & TheCompleteFilePath cat.ActiveConnection = cnn For Each tbl In cat.Tables MsgBox Left$(tbl.Name, Len(tbl.Name) - 1) Next tbl Set cat = Nothing cnn.Close Set cnn = Nothing End Sub
Function CWRIA(fPath As String, fName As String, _ sName As String, rng As String) Dim sRow As Integer Dim sColumn As Integer Dim sRows As Integer Dim sColumns As Integer Dim vrow As Integer Dim vcol As Integer Dim fpStr As String Dim cArr() On Error GoTo NoArr If Right(fPath, 1) <> "\" Then fPath = fPath & "\" If Dir(fPath & fName) = "" Then CWA = CVErr(xlErrValue) Exit Function End If sRow = Range(rng).Row sColumn = Range(rng).Column sRows = Range(rng).Rows.Count sColumns = Range(rng).Columns.Count ReDim cArr(sRows, sColumns) For vrow = 1 To sRows For vcol = 1 To sColumns fpStr = "'" & fPath & "[" & fName & "]" & sName & "'!" & _ "r" & sRow + vrow - 1 & "c" & sColumn + vcol - 1 cArr(vrow, vcol) = ExecuteExcel4Macro(fpStr) Next Next CWRIA = cArr Exit Function NoArr: CWRIA = CVErr(xlErrValue) End Function 'CWRIR; ClosedWorkbookRangeIntoArray in ksaltlm halidir. Sub CWRIR(fPath As String, fName As String, sName As String, _ rng As String, destRngUpperLeftCell As String ) Dim sRow As Integer Dim sColumn As Integer Dim sRows As Integer Dim sColumns As Integer Dim vrow As Integer Dim vcol As Integer Dim fpStr As String Dim cArr() On Error GoTo NoArr If Right(fPath, 1) <> "\" Then fPath = fPath & "\" If Dir(fPath & fName) = "" Then CWA = CVErr(xlErrValue) Exit Function End If sRow = Range(rng).Row sColumn = Range(rng).Column sRows = Range(rng).Rows.Count sColumns = Range(rng).Columns.Count ReDim cArr(sRows, sColumns) Set destRange = ActiveSheet.Range(destRngUpperLeftCell) For vrow = 1 To sRows For vcol = 1 To sColumns fpStr = "'" & fPath & "[" & fName & "]" & sName & "'!" & _ "r" & sRow + vrow - 1 & "c" & sColumn + vcol - 1 destRange.Offset(vrow - 1, vcol - 1) = ExecuteExcel4Macro(fpStr) Next Next NoArr: End Sub
C srcsndeki Deneme klasrndeki kapal deneme alma kitabnn deneme1,deneme2,deneme3,deneme4 sayfalarn siler Sub SayfaSil() Dim silinecek() Application.ScreenUpdating = False silinecek = Array("deneme1", "deneme2", "deneme3", "deneme4") Set xlBook = Workbooks.Open("C:\deneme\deneme.xls") For Each sira In silinecek For Each sayfa In xlBook.Worksheets If sira = sayfa.Name Then Application.DisplayAlerts = False sayfa.Delete Application.DisplayAlerts = True End If Next Next xlBook.Save xlBook.Close Application.ScreenUpdating = True Set xlBook = Nothing Msgbox "Bitti" End Sub Aadaki prosedr; kapal alma kitabndaki(cellDataVal.xls dosyas) Sayfa1'de A1:C3 aralndaki deeri, aktif alma sayfasndaki(D:\EXCEL97\xl form
Sub InsertRangeFromClosedWorkbook() CWRIR "D:\EXCEL97\xlformulas", "cellDataVal.xls", "Sheet1", "a1:c3", "f9" End Sub kod ile "C:\Temp\" klasrnde kapal durumda olan tm alma 'kitaplarndaki Sheet1 isimli sayfalarnda A1:E10 aralndaki tm hcreler 'topla Aadaki Const MyPath As String = "C:\Temp\" Const MySh As String = "Sheet1" Dim MyArg As String ' Sub Test() 'Raider Dim MyFile As String Dim i As Long, j As Integer Range("A1:E10").ClearContents MyFile = Dir(MyPath & Application.PathSeparator & "*.xls", vbDirectory) Do While MyFile <> "" If MyFile = ThisWorkbook.Name Then GoTo ResumeSub: MyArg = "'" & MyPath & "[" & MyFile & "]" & MySh & "'!R" For j = 1 To 5 For i = 1 To 10 Cells(i, j) = Cells(i, j) + ExecuteExcel4Macro(MyArg & i & "C" & j) Next Next ResumeSub: MyFile = Dir Loop End Sub
Eer C:\Data dosyasnn iinde excel belgesi varsa (kapal olsa dahi) veri yazar. Sub Copyrange() Dim basebook As Workbook Dim mybook As Workbook Dim sourceRange As Range Dim destrange As Range Dim i As Long Application.ScreenUpdating = False With Application.FileSearch .NewSearch .LookIn = "C:\Data" .SearchSubFolders = False .FileType = msoFileTypeExcelWorkbooks If .Execute() > 0 Then Set basebook = ThisWorkbook For i = 1 To .FoundFiles.Count Set mybook = Workbooks.Open(.FoundFiles(i)) Set sourceRange = basebook.Worksheets(1).Range("a1:c5") Set destrange = mybook.Worksheets(1).Range("a1") sourceRange.Copy destrange mybook.Close True Next i End If End With Application.ScreenUpdating = True End Sub kitab kapat, vakit geldiinde alp ve gerekli uyary verir Application.OnTime Now + TimeValue("00:00:10"), "deneme" End Sub Sub deneme() MsgBox "oldu" End Sub Public soru Sub auto_open() soru = MsgBox("Gizlensin mi?", vbYesNo) If soru = vbYes Then Application.Visible = False Call dene End If End Sub Sub dene() Application.OnTime Now + TimeValue("00:00:03"), "deneme2" End Sub Sub deneme2() gnler = MsgBox("gn dolanlar var" & vbCrLf & "Excel alma kitab alsn m?", vbYesNo) If gnler = vbNo Then Call dene Else Application.Visible = True End If End Sub Private Sub Workbook_Activate() If soru = vbYes Then Application.Visible = False End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) soru2 = MsgBox("Zamanlanm grevi olan dosyada kapansn m?", vbYesNo) If soru2 = vbYes Then Exit Sub Cancel = True End Sub Sub datagonder() Rows(2).Copy Windows("notdata.xls").Activate son = [a65356].End(3).Row + 1 Rows(son).PasteSpecial Windows("notisleme.xls").Activate End Sub
Kullancya gnderecein B.xls dosyasndaki kod; Kod: Sub Test() Myfile = "C:\Test.xls" MyForm = "C:\UserForm1.frm" If Dir(Myfile) <> Empty And Dir(MyForm) <> Empty Then Workbooks.Open Myfile On Error GoTo ErrHandler: Workbooks(Dir(Myfile)).VBProject.VBComponents.Import MyForm Workbooks(Dir(Myfile)).Close SaveChanges:=True MsgBox "lem tamam !" Exit Sub Else MsgBox Myfile & " ve " & MyForm & " dosyalarnn isimlerini ve doru" _ & " yerletirildiini kontrol edin !" Exit Sub End If ErrHandler: Select Case Err.Number Case 60061 MsgBox "Dosyada " & Dir(MyForm) & " zaten mevcut !" Case Else MsgBox Err.Number & vbCrLf & Err.Description End Select Workbooks(Dir(Myfile)).Close SaveChanges:=False End Sub
Yaplan i; yukardaki kodlar altrldnda kapal durumdaki C:\Test.xls dosyas alacak ve iine C:\UserForm1.frm ilave edildikten sonra kaydedilerek ka
Kodlar altrlmadan nce yaplmas gereken ise; kullancnn C:\Test.xls ve C:\UserForm1.frm dosyalarn kendi bilgisayarlarnda, kodlarda belirtilen yerle Sub auto_close() Sheets("Bir").Select Range("C2").Select End Sub Dosya kapanrken bir selamlama mesaj kar. Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "GLE GLE!" End Sub CommandButton13_Click() Public Sub cevap = MsgBox(" PROGRAMI KAPATMAK STEDNZDEN EMNMSNZ ? ", vbYesNo, "") If cevap = vbNo Then Exit Sub Unload Me Application.Quit If cevap = vbYes Then auto_close End If End Sub Private Sub CommandButton13_Click() Cevap = MsgBox(" PROGRAMI KAPATMAK STEDNZDEN EMNMSNZ ? ", vbYesNo, "") If Cevap = vbNo Then Exit Sub Unload Me kullanici = Application.UserName saat = Format(Now, "hh:mm:ss") tarih = Format(Date, "d mmmm yyyy dddd") sor = MsgBox(" GRMEK ZERE " & kullanici & Chr(10) & Chr(10) & _ "..BROSU/ 0212 ." & Chr(10) & Chr(10) & _ "Tarih : " & tarih & Chr(10) & Chr(10) _ & "Saat : " & saat & Chr(10) & Chr(10) _ & ". BROSU iyi almalar Diler." & Chr(10) & Chr(10) & _ "Dosyanzn kaydedilmesini istiyor musunuz?", 4, "") If sor = vbYes Then ActiveWorkbook.Save ActiveWorkbook.Close Else Application.DisplayAlerts = False ActiveWorkbook.Close End If End Sub
Range("B2").Value=100 'saysal deer Range("B2").Value="pir" 'Text; trnak iinde 3- Hcredeki Fontun Bykln deitirmek. Range("B2").Font.Size=20 4- Hcredeki fontun adn deitirmek. Range("B2").Font.Name="Verdana" 5- Hcredeki fontu Kaln,talic ve Alt izgili yapmak. Range("B2").Font.Bold = True Range("B2").Font.Italic = True Range("B2").Font.Underline = xlUnderlineStyleSingle ve yahut Range("B2").Select Selection.Font.Bold = True Selection.Font.Italic = True Selection.Font.Underline = xlUnderlineStyleSingle 6- Hcrenin dolgu rengini deitirmek. Range("B2").Interior.ColorIndex = 6 'Sar renk 7- Hcrenin Fontunun rengini deitirmek. Range("B2").Font.ColorIndex = 3 'Krmz renk 8- Hcreye Forml yazdrmak. Range("B2").Formula="=A1+A2"'A1 ve A2 hcresini toplar,B2 ye yazdrr. 9- Aktif olan hcrenin etrafndaki hcreyi semek ActiveCell.Offset(1, 0).Select 'Aktif hcrenin altdakini seer. ActiveCell.Offset(-1, 0).Select 'Aktif hcrenin stndekini seer. ActiveCell.Offset(0, 1).Select 'Aktif hcrenin sandakini seer. ActiveCell.Offset(0, -1).Select 'Aktif hcrenin solundakini seer. 10- Aktif olan hcrenin belirtilen kadar uzandaki hcreyi semek. ActiveCell.Offset(0, 5).Select 'Aktif hcrenin sandaki 5. hcreyi seer. 11- Aktif hcreden belirtilen uzaklktaki hcreye deer atamak. ActiveCell.Offset(1,1).Value = "Muhammed" 'Aktif hcrenin altnda ve sandaki hcreye Muhammed yazdrr. 12- Aktif hcrenin zerindeki iki hcrenin deerleri toplanr ve sonu aktif olan hcreye yazlr. Sub toplama() t1 = ActiveCell.Offset(-1, 0).Value t2 = ActiveCell.Offset(-2, 0).Value ActiveCell.Value = t1 + t2 End Sub 13- Seili hcrelerdeki biimleri siler. Selection.ClearFormats 14- Seili hcreleri aa teler. Range("A1:A5").Select 'A1 ile A5 arasndaki hcreler seilir. Selection.Insert Shift:=xlDown 'Seimi aa kaydrr. Burada sadece seili olan 5 adet hcre aa kaydrlr. 15- Seili hcrelere ait hm satr telemek. Range("A1:A5").Select Selection.EntireRow.Insert '14. koddan farkl olarak seili olan hcrelere ait 1 ila 5 arasndaki tm satrlar 5 satr aa telenir. 16- Seili hcrelere ait tm stunu telemek. Range("D6:E7).Select selection.EntireColumn.Insert 17- Ak olan Excel alma Kitabnn belirtilen sayfasndaki istenen hcreye deer atar. Workbooks("Kitap1.xls").Worksheets("Sayfa1").Range("A1").Value = 3 18- Yaplan seimlerde bo olmayan hcre saysn verir. Sub hucresayisi() Dim kontur As Integer kontur = Application.CountA(Selection) MsgBox "Seimdeki dolu hcrelerin says:" & kontur End Sub 19- 18. maddedeki kodlamada 'CountA' da bulunan 'A' kaldrlrsa seimde sadece ka hcrede say (rakam) varsa onlarn adedini verir. Application.Count(Selection) 20- Seili hcrelerin saysn verir. Selection.Count 21- Seimin satr saysn verir. Selection.Rows.Count 22- Seimin stun saysn verir. Selection.Columns.Count 24- Seili hcrenin altnda veriler varsa onlar seer. lk bo hcreden sonra ilk deer olan hcreyi seer. Range(ActiveCell,ActiveCell.End(xlDown)).Select 25- 24. de stteki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlUp)).Select 26- 24. de sadaki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlToRight)).Select 27- 24. de soldaki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlToLeft)).Select 28- Aktif hcrenin etrafndaki dolu hcreleri seer. ActiveCell.CurrentRegion.Select 29- Seimin etrafndaki dolu hcreleri seer. Selection.CurrentRegion.Select ActiveCell.EntireColumn.Select 31- Seili hcrelerin bulunduklar stunlar tamamen seer. Selection.EntireColumn.Select 30- Aktif hcrenin bulunduu satr tamamn seer.
Range("B2").Value=100 'saysal deer Range("B2").Value="pir" 'Text; trnak iinde 3- Hcredeki Fontun Bykln deitirmek. Range("B2").Font.Size=20 4- Hcredeki fontun adn deitirmek. Range("B2").Font.Name="Verdana" 5- Hcredeki fontu Kaln,talic ve Alt izgili yapmak. Range("B2").Font.Bold = True Range("B2").Font.Italic = True Range("B2").Font.Underline = xlUnderlineStyleSingle ve yahut Range("B2").Select Selection.Font.Bold = True Selection.Font.Italic = True Selection.Font.Underline = xlUnderlineStyleSingle 6- Hcrenin dolgu rengini deitirmek. Range("B2").Interior.ColorIndex = 6 'Sar renk 7- Hcrenin Fontunun rengini deitirmek. Range("B2").Font.ColorIndex = 3 'Krmz renk 8- Hcreye Forml yazdrmak. Range("B2").Formula="=A1+A2"'A1 ve A2 hcresini toplar,B2 ye yazdrr. 9- Aktif olan hcrenin etrafndaki hcreyi semek ActiveCell.Offset(1, 0).Select 'Aktif hcrenin altdakini seer. ActiveCell.Offset(-1, 0).Select 'Aktif hcrenin stndekini seer. ActiveCell.Offset(0, 1).Select 'Aktif hcrenin sandakini seer. ActiveCell.Offset(0, -1).Select 'Aktif hcrenin solundakini seer. 10- Aktif olan hcrenin belirtilen kadar uzandaki hcreyi semek. ActiveCell.Offset(0, 5).Select 'Aktif hcrenin sandaki 5. hcreyi seer. 11- Aktif hcreden belirtilen uzaklktaki hcreye deer atamak. ActiveCell.Offset(1,1).Value = "Muhammed" 'Aktif hcrenin altnda ve sandaki hcreye Muhammed yazdrr. 12- Aktif hcrenin zerindeki iki hcrenin deerleri toplanr ve sonu aktif olan hcreye yazlr. Sub toplama() t1 = ActiveCell.Offset(-1, 0).Value t2 = ActiveCell.Offset(-2, 0).Value ActiveCell.Value = t1 + t2 End Sub 13- Seili hcrelerdeki biimleri siler. Selection.ClearFormats 14- Seili hcreleri aa teler. Range("A1:A5").Select 'A1 ile A5 arasndaki hcreler seilir. Selection.Insert Shift:=xlDown 'Seimi aa kaydrr. Burada sadece seili olan 5 adet hcre aa kaydrlr. 15- Seili hcrelere ait hm satr telemek. Range("A1:A5").Select Selection.EntireRow.Insert '14. koddan farkl olarak seili olan hcrelere ait 1 ila 5 arasndaki tm satrlar 5 satr aa telenir. 16- Seili hcrelere ait tm stunu telemek. Range("D6:E7).Select selection.EntireColumn.Insert 17- Ak olan Excel alma Kitabnn belirtilen sayfasndaki istenen hcreye deer atar. Workbooks("Kitap1.xls").Worksheets("Sayfa1").Range("A1").Value = 3 18- Yaplan seimlerde bo olmayan hcre saysn verir. Sub hucresayisi() Dim kontur As Integer kontur = Application.CountA(Selection) MsgBox "Seimdeki dolu hcrelerin says:" & kontur End Sub 19- 18. maddedeki kodlamada 'CountA' da bulunan 'A' kaldrlrsa seimde sadece ka hcrede say (rakam) varsa onlarn adedini verir. Application.Count(Selection) 20- Seili hcrelerin saysn verir. Selection.Count 21- Seimin satr saysn verir. Selection.Rows.Count 22- Seimin stun saysn verir. Selection.Columns.Count 24- Seili hcrenin altnda veriler varsa onlar seer. lk bo hcreden sonra ilk deer olan hcreyi seer. Range(ActiveCell,ActiveCell.End(xlDown)).Select 25- 24. de stteki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlUp)).Select 26- 24. de sadaki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlToRight)).Select 27- 24. de soldaki hcreler iin ayn ilemi yapar. Range(ActiveCell,ActiveCell.End(xlToLeft)).Select 28- Aktif hcrenin etrafndaki dolu hcreleri seer. ActiveCell.CurrentRegion.Select 29- Seimin etrafndaki dolu hcreleri seer. Selection.CurrentRegion.Select ActiveCell.EntireColumn.Select 31- Seili hcrelerin bulunduklar stunlar tamamen seer. Selection.EntireColumn.Select 30- Aktif hcrenin bulunduu satr tamamn seer.
Private Sub Workbook_Open() Dim Utilis As String Dim DateJour As Date 'Rcupration du nom de l'utilisateur Utilis = Application.UserName 'Rcupration de la date du jour DateJour = Date Msgbox "Selamn Aleykm " & Utilis & Chr(10) & _ "Nous sommes le " & DateJour End Karsilastir1() Sub Sub Dim Sh1 As Worksheet, Sh2 As Worksheet Dim Bul As Range, Soyad, i Dim ilkAdres Set Sh1 = Worksheets("Sayfa1") Set Sh2 = Worksheets("Sayfa2") For i = 2 To Sh2.Cells(65536, "C").End(xlUp).Row Soyad = Sh2.Cells(i, 3) Set Bul = Sh1.Range("C:C").Find(Soyad, LookAt:=xlWhole) If Not Bul Is Nothing Then ilkAdres = Bul.Address Do If Sh2.Cells(i, 2) = Bul.Offset(, -1) Then Bul.Offset(, 1) = "Bulundu" End If Set Bul = Sh1.Range("C:C").FindNext(Bul) Loop Until ilkAdres = Bul.Address End If Next End Sub
Label8.Top = 0 Label8.Left = 5 For i = 10 To (UserForm1.Width Label8.Left = Label8.Left + 0.1 DoEvents Next i Label8.Top = 0 Label8.Left = 280 For i = 10 To (UserForm1.Width Label8.Left = Label8.Left - 0.1 DoEvents Next i Label8.Top = 0 Label8.Left = 5 For i = 10 To (UserForm1.Width Label8.Left = Label8.Left + 0.1 DoEvents Next i Label8.Top = 0 Label8.Left = 275 For i = 10 To (UserForm1.Width Label8.Left = Label8.Left - 0.1 DoEvents Next i Label8.Top = 0 Label8.Left = 0 For i = 10 To (UserForm1.Width Label8.Left = Label8.Left + 0.1 DoEvents Next i 'End Sub 'Private Sub UserForm_Activate() 'Dim i As Integer '2 Label9.Top = 20 Label9.Left = 280 For i = 10 To (UserForm1.Width Label9.Left = Label9.Left - 0.1 DoEvents Next i '1 Label9.Top = 20 Label9.Left = 5 For i = 10 To (UserForm1.Width Label9.Left = Label9.Left + 0.1 DoEvents Next i '4 Label9.Top = 20 Label9.Left = 275 For i = 10 To (UserForm1.Width Label9.Left = Label9.Left - 0.1 DoEvents Next i '3 Label9.Top = 20 Label9.Left = 5 For i = 10 To (UserForm1.Width Label9.Left = Label9.Left + 0.1 DoEvents Next i
Label8.Width) * 10
Label8.Width) * 10
Label8.Width) * 10
Label8.Width) * 10
Label8.Width) * 5
Label8.Width) * 10
Label8.Width) * 10
Label8.Width) * 10
Label8.Width) * 10
'5 Label9.Top = 20 Label9.Left = 270 For i = 10 To (UserForm1.Width - Label8.Width) * 4.5 Label9.Left = Label9.Left - 0.1 DoEvents Next i End Sub
Sub KayanYazi() [J2] = "" For i = 1 To 10 On Error Resume Next For j = 1 To 1000000 j=j+1 Next j Cells(2, i).Value = "Kayan Yazi" Cells(2, i - 1).Value = "" Next End Sub Sub kaydet_cik() ThisWorkbook.Close Saved = True End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Range("A1") = Now 'Select any cell you want End Sub Private Sub Workbook_BeforeSave _ (ByVal SaveAsUI As Boolean, Cancel As Boolean) pir = _ MsgBox(" Gerekten kadetmek istiyor musunuz?", _ vbYesNo) If pir = vbNo Then Cancel = True End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Range("A1").Value = "Stand: " & Format(Date, "DD.MM.YYYY") Worksheets("Tabelle1").PageSetup.LeftFooter = "Stand: " & Format(Date, "DD.MM.YYYY") End Sub Sub Makro1() Range("A1:C20").ClearContents ActiveWorkbook.Save Application.Quit End Sub ListBox1.RemoveItem (ListBox1.ListIndex) Sayfa1.Rows(ListBox1.ListIndex + 2).Clear 'satrlar komple kaldrmak istiyorsan clear yerine delete kullan End Sub Private Sub kayit_Click() If TextBox2.Text = "" Or TextBox3.Text = "" Then MsgBox "Tarih veya Tutar bo geilemez", vbExclamation Else dene = Application.CountA(Sheets("sayfa1").Columns("A")) + 1 sira = TextBox1.Text Sheets("sayfa1").Cells(dene, 1) = TextBox1.Text Sheets("sayfa1").Cells(dene, 2) = TextBox2.Text Sheets("sayfa1").Cells(dene, 3) = TextBox3.Text TextBox1.Text = sira + 1 TextBox2.Text = "" MsgBox "Kayt ilemi Tamamland", vbInformation End If End Sub Private Sub ListBox1_Change() TextBox1 = ListBox1.List(ListBox1.ListIndex, 0) TextBox2 = ListBox1.List(ListBox1.ListIndex, 1) TextBox3 = ListBox1.List(ListBox1.ListIndex, 2) End Sub Private Sub UserForm_Initialize() ComboBox1.RowSource = "sayfa1!A2:A50" 'combobox1'e sayfa1 deki A1:A10 aralndaki deerleri atar 'ListBox1.RowSource = "sayfa1!A2:C50" 'listbox1'e sayfa1 deki A2:B10 aralndaki deerleri atar ComboBox1.ColumnHeads = True 'listboxta stun balklarn grnr hale getirir burada balk A1:B1 araldr. 'ListBox1.ColumnCount = 3 'stun says-ka veri varsa o kadar stun almaldr ListBox1.ColumnWidths = "20;50;40" 'alan stunlarn genilikleri. For i = 1 To WorksheetFunction.CountA(Sayfa1.[A1:A50]) ListBox1.AddItem Cells(i + 1, 1) ListBox1.List(i - 1, 1) = Cells(i + 1, 2) ListBox1.List(i - 1, 2) = Cells(i + 1, 3) 'ListBox1.ColumnHeads = True Next i End Sub
Sub Ohne_Speichern_schliessen() ThisWorkbook.Close Saved = True 'oder ThisWorkbook.Close False End Sub Sub close() ThisWorkbook.Close Saved = True End Sub Sub DateiSchlieen() ActiveWorkbooks.Close SaveChanges:=False End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) a = InputBox("Kaydetmek iin ifrenizini girin") If a <> 1234 Then Cancel = True End If End Sub Aadaki kodlar almanzda ThisWorkbook modulune kopyalayn. Yalnzca ilk kaytta yalnzca 1 kez alr , '2. kayttan sonra btn kodlar temizler. Const silme = True Satrn kodlarn bana ekleyerek 1 kez daha kayt ansnz olur. Const silme = True Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Set comp = Application.VBE.ActiveVBProject.VBComponents If silme Then comp.Item("ThisWorkbook").CodeModule.deletelines 1, 1 Exit Sub End If For Each kodsayfa In Application.VBE.ActiveVBProject.VBComponents sat = comp.Item(kodsayfa.Name).CodeModule.CountOfLines comp.Item(kodsayfa.Name).CodeModule.deletelines 1, sat Next Set comp = Nothing End Sub Thisworkbook'a aadaki kodlar ekleyin Private Sub Workbook_BeforePrint(Cancel As Boolean) If Sheets("Sayfa1").Range("M56") = "" Then MsgBox ("Yazdrlamyor !" & vbNewLine & _ "M56 hcresini bo brakamazsnz.") Cancel = True End If End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If Sheets("Sayfa1").Range("M56") = "" Then MsgBox ("Kaydedilemiyor!" & vbNewLine & _ "M56 hcresini bo brakamazsnz.") Cancel = True End If End Sub Private Sub Command1_Click() Dim a, sonuc As Integer a = InputBox("CRET GRNZ") If a > 0 Then sonuc = a * 1.18 MsgBox sonuc End If End Sub Private Sub Command1_Click() Dim a, sonuc As Integer a = InputBox("CRET GRNZ") If a > 0 Then sonuc = a * 1.18 MsgBox sonuc End If End Sub Worksheets("Kedi2").Move After:=Worksheets("Kedi5")
Sub myEdit() MsgBox Left("abcd", 2) 'Soldan 2 harfi gsterir MsgBox Right("abcd", 2) 'Sadan 2 harfi gsterir MsgBox Len("abcd") 'Karakter saysn gsterir End Sub alma sayfasnda ka kelime olduunu sayar. Sub CountWords() Dim WordCount As Long Dim Rng As Range Dim S As String Dim N As Long For Each Rng In ActiveSheet.UsedRange.Cells S = Application.WorksheetFunction.Trim(Rng.Text) N=0 If S <> "" Then N = Len(S) - Len(Replace(S, " ", "")) + 1 End If WordCount = WordCount + N Next Rng MsgBox WordCount End Sub Sub BereichGlaetten() Dim r As Range, c As Range On Error Resume Next Set r = Application.InputBox("Bereich markieren, der geglttet werden soll: ", Type:=8) For Each c In r.Cells c.Value = Application.WorksheetFunction.Trim(c.Value) Next c End Sub Sub Dialog_08() Application.Dialogs(xlDialogBorder).Show End Sub Thisworkbooka Private Sub Workbook_BeforeClose(Cancel As Boolean) Zurcksetzen End Sub Private Sub Workbook_Open() startzeit End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) startzeit End Sub 'Modle Dim DaA As Date Sub startzeit() On Error Resume Next Application.OnTime EarliestTime:=DaA, Procedure:="Schlieen", Schedule:=False DaA = Now + CDate("0:00:10") Application.OnTime DaA, "Schlieen" End Sub Sub Schlieen() ThisWorkbook.Close True End Sub Sub Zurcksetzen() Application.OnTime EarliestTime:=DaA, Procedure:="Schlieen", Schedule:=False End Sub
Private Sub Workbook_Open() DaZeit = "0:00:10" ThisWorkbook.Worksheets("Tabelle1").Range("A1") = CDate(DaZeit) Zeitmakro End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.OnTime EarliestTime:=VaEt, Procedure:="Zeitmakro", Schedule:=False End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) ThisWorkbook.Worksheets("Tabelle1").Range("A1") = DaZeit End Sub 'Modle Sub Zeitmakro() ' ThisWorkbook.Worksheets("Tabelle1").Range("A1") = ThisWorkbook.Worksheets("Tabelle1").Range("A1") - CDate("00:00:01") If ThisWorkbook.Worksheets("Tabelle1").Range("A1") <> 0 Then VaEt = Now + TimeValue("00:00:01") Application.OnTime VaEt, "Zeitmakro" Else ThisWorkbook.Close True 'speichern ' Meldung bei Excel immer in Vordergrund ' Dim mldg ' mldg = MsgBox("Endzeit erreicht", 1048576, "Endzeit") ' 1048576 entspricht vbMsgBoxRtlReading End If End Sub Sub DisableCutAndPaste() EnableControl 21, False ' cut EnableControl 19, False ' copy EnableControl 22, False ' paste EnableControl 755, False ' pastespecial Application.OnKey "^c", "" Application.OnKey "^v", "" Application.OnKey "+{DEL}", "" Application.OnKey "+{INSERT}", "" Application.CellDragAndDrop = False End Sub ' BU KOD KISITLAMALARI AKTF YAPAR Sub EnableCutAndPaste() EnableControl 21, True ' cut EnableControl 19, True ' copy EnableControl 22, True ' paste EnableControl 755, True ' pastespecial Application.OnKey "^c" Application.OnKey "^v" Application.OnKey "+{DEL}" Application.OnKey "+{INSERT}" Application.CellDragAndDrop = True End Sub Sub EnableControl(Id As Integer, Enabled As Boolean) Dim CB As CommandBar Dim C As CommandBarControl For Each CB In Application.CommandBars Set C = CB.FindControl(Id:=Id, recursive:=True) If Not C Is Nothing Then C.Enabled = Enabled Next End Sub
Sub DisableCutAndPaste() EnableControl 21, False ' cut EnableControl 19, False ' copy EnableControl 22, False ' paste EnableControl 755, False ' pastespecial Application.OnKey "^c", "" Application.OnKey "^v", "" Application.OnKey "+{DEL}", "" Application.OnKey "+{INSERT}", "" Application.CellDragAndDrop = False End Sub ' BU KOD KISITLAMALARI AKTF YAPAR Sub EnableCutAndPaste() EnableControl 21, True ' cut EnableControl 19, True ' copy EnableControl 22, True ' paste EnableControl 755, True ' pastespecial Application.OnKey "^c" Application.OnKey "^v" Application.OnKey "+{DEL}" Application.OnKey "+{INSERT}" Application.CellDragAndDrop = True End Sub Sub EnableControl(Id As Integer, Enabled As Boolean) Dim CB As CommandBar Dim C As CommandBarControl For Each CB In Application.CommandBars Set C = CB.FindControl(Id:=Id, recursive:=True) If Not C Is Nothing Then C.Enabled = Enabled Next End Sub Sub EnableCutAndPaste() EnableControl 21, True ' cut EnableControl 19, True ' copy EnableControl 22, True ' paste EnableControl 755, True ' pastespecial Application.OnKey "^c" Application.OnKey "^v" Application.OnKey "+{DEL}" Application.OnKey "+{INSERT}" Application.CellDragAndDrop = True End Sub Sub DisableCutAndPaste() EnableControl 21, False ' cut EnableControl 19, False ' copy EnableControl 22, False ' paste EnableControl 755, False ' pastespecial Application.OnKey "^c", "" Application.OnKey "^v", "" Application.OnKey "+{DEL}", "" Application.OnKey "+{INSERT}", "" Application.CellDragAndDrop = False End Sub
Sub DisableCutAndPaste() ' Kes-kopyala pasif EnableControl 21, False ' kes EnableControl 19, False ' kopyala EnableControl 22, False ' yaptr EnableControl 755, False ' zel yaptr Application.OnKey "^c", "" Application.OnKey "^v", "" Application.OnKey "+{DEL}", "" Application.OnKey "+{INSERT}", "" Application.CellDragAndDrop = False End Sub Sub EnableCutAndPaste() ' Kes-kopyala Etkin EnableControl 21, True ' kes EnableControl 19, True ' kopyala EnableControl 22, True ' yaptr EnableControl 755, True ' zel yaptr Application.OnKey "^c" Application.OnKey "^v" Application.OnKey "+{DEL}" Application.OnKey "+{INSERT}" Application.CellDragAndDrop = True End Sub Sub EnableControl(Id As Integer, Enabled As Boolean) Dim CB As CommandBar Dim C As CommandBarControl For Each CB In Application.CommandBars Set C = CB.FindControl(Id:=Id, recursive:=True) If Not C Is Nothing Then C.Enabled = Enabled Next End Sub Sub sommeCouleurRougeText() Dim Cellule As Range Dim total As Variant For Each Cellule In Selection If Cellule.Font.ColorIndex = 3 Then '3 rouge et 1 pour le noir 'If Cellule.Interior.ColorIndex = 3 Then (pour la couleur de fond) If IsNumeric(Cellule) Then total = total + Cellule.Value End If Next MsgBox total Range("G12") = total End Sub
Sub StartList() Dim R As Range ActiveSheet.UsedRange.ClearContents Set R = Range("A3") ListCtrls Application.CommandBars.ActiveMenuBar, R End Sub Sub ListCtrls(Ctrl As Object, Rng As Range) Dim C As Office.CommandBarControl Static S As String Dim Pos As Integer If TypeOf Ctrl Is CommandBar Then S = "ALT" End If If Not TypeOf Ctrl Is Office.CommandBarButton Then For Each C In Ctrl.Controls Rng.Value = C.Caption Pos = InStr(1, C.Caption, "&") If Pos Then S = S & "+" & Mid(C.Caption, Pos + 1, 1) Rng.EntireRow.Cells(1, "H").Value = UCase(S) End If Set Rng = Rng(2, 2) ListCtrls C, Rng Set Rng = Rng(1, 0) If Len(S) > 3 Then S = Left(S, Len(S) - 2) End If Next C End If Option Explicit Public IteM As Variant, SheetR As Integer, DdD As Integer, SheetC as Integer Sub ColorActive() SheetR = 0 'Reset counter SheetC = ActiveWorkbook.Worksheets.Count 'See how many sheets to work on For DdD = 1 To SheetC 'Work from Sheet 1 to ... Worksheets(DdD).Activate 'Activate active sheet ActiveSheet.Unprotect 'Unprotect - assuming no password For Each IteM In ActiveSheet.UsedRange 'Color cells according to locked If IteM.Locked = False Then 'If not locked IteM.Font.ColorIndex = 32 'Blue for unlocked SheetR = SheetR + 1 'Add to cells fixed count ElseIf IteM.Locked = True Then 'If IS locked ... IteM.Font.ColorIndex = xlAutomatic 'Set color to default End If Next 'Loop next cell ActiveSheet.Protect 'Re-protect Next MsgBox SheetR & " cells were colored Blue if 'unlocked'", 64 'Done message End Sub Sub dosyaa() Workbooks.Open Filename:="C:\Belgelerim\kitap1.xls" End Sub Sub kopyala() Sheets("Sayfa1").Copy After:=Workbooks("Kitap1").Sheets(1) End Sub Sub dosyakapat() Workbooks("kitap1.xls").Close End Sub
Sub test() UsrRsp = Application.Dialogs(xlDialogSaveAs).Show("test.xls") Select Case UsrRsp Case -1 Case 0 End Select End Sub Sub SaveWorkbookBackupToFloppyA() Dim awb As Workbook, BackupFileName As String, i As Integer, OK As Boolean If TypeName(ActiveWorkbook) = "Nothing" Then Exit Sub Set awb = ActiveWorkbook If awb.Path = "" Then Application.Dialogs(xlDialogSaveAs).Show Else BackupFileName = awb.Name OK = False On Error GoTo NotAbleToSave If Dir("A:\" & BackupFileName) <> "" Then Kill "A:\" & BackupFileName End If With awb Application.StatusBar = "Saving this workbook..." .Save Application.StatusBar = "Saving this workbook backup..." .SaveCopyAs "A:\" & BackupFileName OK = True End With End If NotAbleToSave: Set awb = Nothing Application.StatusBar = False If Not OK Then MsgBox "Backup Copy Not Saved!", vbExclamation, ThisWorkbook.Name End If End Sub Sub Save() ActiveWorkbook.Save End Sub Sub SaveName() ActiveWorkbook.SaveAs Filename:="C:\MyFile.xls" End Sub alma Kitabn Kapat Sub kayt() ActiveWorkbook.Close End Sub alma Kitabn Kaydet Sub kayt() ActiveWorkbook.Save End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Sheets(1).[A1] = "Dernire modification le " & Format(Date, "dd/mm/yyyy") End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _ Cancel As Boolean) a = MsgBox("Bu kitab geretken kaydetmek istiyor musunuz?", vbYesNo) If a = vbNo Then Cancel = True End Sub KTABI KAYDET PENCEREY KAPAT A1' SE Private Sub CommandButton6_Click() ActiveWorkbook.Save ActiveWindow.Close Range("A1").Select End Sub
Sub auto_open() Application.CommandBars("Worksheet Menu Bar").Controls(6).Controls("Makro").Enabled = False Application.OnKey "%{F11}", "mesaj" End Sub Sub auto_close() Application.CommandBars("Worksheet Menu Bar").Controls(6).Controls("Makro").Enabled = True Application.OnKey "%{F11}" End Sub Sub mesaj() MsgBox "Makrolar gizli!!" End Sub Thisworkbook a Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.DisplayAlerts = False ActiveWorkbook.Save Application.DisplayAlerts = True End SaveWorkbookBackup() Sub Sub Dim awb As Workbook, BackupFileName As String, i As Integer, OK As Boolean If TypeName(ActiveWorkbook) = "Nothing" Then Exit Sub Set awb = ActiveWorkbook If awb.Path = "" Then Application.Dialogs(xlDialogSaveAs).Show Else BackupFileName = awb.FullName i=0 While InStr(i + 1, BackupFileName, ".") > 0 i = InStr(i + 1, BackupFileName, ".") Wend If i > 0 Then BackupFileName = Left(BackupFileName, i - 1) BackupFileName = BackupFileName & ".bak" OK = False On Error GoTo NotAbleToSave With awb Application.StatusBar = "Saving this workbook..." .Save Application.StatusBar = "Saving this workbook backup..." .SaveCopyAs BackupFileName OK = True End With End If NotAbleToSave: Set awb = Nothing Application.StatusBar = False If Not OK Then MsgBox "Backup Copy Not Saved!", vbExclamation, ThisWorkbook.Name End If End Sub
Sub dsave() Dim s_pfad(20) SPfad = ThisWorkbook.Sheets(1).Range("A1") OPfad = ActiveWorkbook.Path On Error Resume Next opfad2 = Right(OPfad, Len(OPfad) - 3) spfad2 = SPfad & "\" & opfad2 n=0 For s = 1 To Len(spfad2) If Mid(spfad2, s, 1) = "\" Then s_pfad(n) = Left(spfad2, s - 1) Debug.Print n, s_pfad(n) n=n+1 End If Next s s_pfad(n) = spfad2 oname = ActiveWorkbook.Name On Error GoTo erstellen For t = 1 To n ChDir (s_pfad(t)) Next t ActiveWorkbook.SaveCopyAs FileName:=spfad2 & "\" & oname ActiveWorkbook.Save Exit Sub erstellen: MkDir (s_pfad(t)) Resume Next End Sub Sub sf_ein() Set SM = CommandBars.FindControl(Id:=3) SM.OnAction = "dsave" End Sub Sub sf_aus() Set SM = CommandBars.FindControl(Id:=3) SM.OnAction = "" End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) sf_aus End Sub Private Sub Workbook_Open() sf_ein End Sub Sub Dateiname() MsgBox ActiveWorkbook.Name End Sub Sub test() Application.Caption = "Excelci" ActiveWindow.Caption = "pirr" 'Incorrect MsgBox Application.Caption & " " & ActiveWindow.Caption 'Correct MsgBox Application.Caption End Sub Sub Taillefile() Dim SizeFile SizeFile = FileLen("c:\ajeter\classeur1.xls") MsgBox "Taille du fichier " & SizeFile & " octets" 'du classeur actif MsgBox FileLen(ThisWorkbook.FullName) & " octets" End Sub
Function FileOrFolderName(InputString As String, _ ReturnFileName As Boolean) As String Dim i As Integer, FolderName As String, FileName As String i=0 While InStr(i + 1, InputString, Application.PathSeparator) > 0 i = InStr(i + 1, InputString, Application.PathSeparator) Wend If i = 0 Then FolderName = CurDir Else FolderName = Left(InputString, i - 1) End If FileName = Right(InputString, Len(InputString) - i) If ReturnFileName Then FileOrFolderName = FileName Else FileOrFolderName = FolderName End If End Function Sub TestFileOrFolderName() MsgBox FileOrFolderName(ThisWorkbook.FullName, False), , _ "This Workbook Foldername:" MsgBox FileOrFolderName(ThisWorkbook.FullName, True), , _ "This Workbook Filename:" End Sub Sub LetztesSpeicherdatumEintragen() Range("A1").Value = _ ActiveWorkbook.BuiltinDocumentProperties("Last Save Time").Value End Sub Dim vFilename As Variant Dim wbActiveBook As Workbook Dim oVBComp As Object Dim oVBComps As Object On Error GoTo CodeError vFilename = Application.GetSaveAsFilename(filefilter:="Microsoft Excel Workbooks,*.xls", _ Title:="Save Copy Without Macros") If vFilename = False Then Exit Sub ActiveWorkbook.SaveCopyAs vFilename Set wbActiveBook = Workbooks.Open(vFilename) Set oVBComps = wbActiveBook.VBProject.VBComponents For Each oVBComp In oVBComps Select Case oVBComp.Type Case 1, 2, 3 oVBComps.Remove oVBComp Case Else With oVBComp.CodeModule .DeleteLines 1, .CountOfLines End With End Select Next oVBComp wbActiveBook.Save MsgBox "Vba kodlarnz silinerek alma kitabnzn kopyas oluturuldu!.", vbInformation, "pir" Exit Sub CodeError: MsgBox Err.Description, vbExclamation, "Baarsz" End Sub
Sub SaveWorkbookBackupToFloppyA() Dim awb As Workbook, BackupFileName As String, i As Integer, OK As Boolean If TypeName(ActiveWorkbook) = "Nothing" Then Exit Sub Set awb = ActiveWorkbook If awb.Path = "" Then Application.Dialogs(xlDialogSaveAs).Show Else BackupFileName = awb.Name OK = False On Error GoTo NotAbleToSave If Dir("A:\" & BackupFileName) <> "" Then Kill "A:\" & BackupFileName End If With awb Application.StatusBar = "Saving this workbook..." .Save Application.StatusBar = "Saving this workbook backup..." .SaveCopyAs "A:\" & BackupFileName OK = True End With End If NotAbleToSave: Set awb = Nothing Application.StatusBar = False If Not OK Then MsgBox "Dosya Yedeklenemedi!", vbExclamation, ThisWorkbook.Name End If End Sub This workbook ksmna; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If Worksheets("Sayfa1").Range("A1").Value < 10 Then Cancel = True End If End Sub alma Kitabn Kapat Sub kayt() ActiveWorkbook.Close End Sub alma Kitabn Kaydet Sub kayt() ActiveWorkbook.Save End Sub KTABI KAYDET PENCEREY KAPAT A1' SE Private Sub CommandButton6_Click() ActiveWorkbook.Save ActiveWindow.Close Range("A1").Select End Sub ALIMA KTABINI KAPATTIINIZDA KTABI OTOMATK KAYIT YAPAR VEYA YAPMAZ Sub Auto_close() Workbooks("Kitap1.xls").Close True 'False kaydetmeden kitab kapar End Sub Private Sub Workbook_Open() Dim StDatei As String Dim StPhad As String StDatei = ThisWorkbook.Name ' Dateiname StPhad = ThisWorkbook.Path ' Phad Dim Fso As Object Set Fso = CreateObject("Scripting.FileSystemObject") If Fso.FileExists(StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei) Then Kill StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei End If ActiveWorkbook.SaveCopyAs FileName:=StPhad & "\" & Format(Now, "DD-MM-YY") & "_" & Format(Now, "hh-mm") & "_" & StDatei End Sub
Sub OpenMultipleFiles() Dim fn As Variant, f As Integer fn = Application.GetOpenFilename("Excel-files,*.xls", _ 1, "Select One Or More Files To Open", , True) If TypeName(fn) = "Boolean" Then Exit Sub For f = 1 To UBound(fn) Debug.Print "Selected file #" & f & ": " & fn(f) Workbooks.Open fn(f) MsgBox ActiveWorkbook.Name, , "Active Workbook Name:" ActiveWorkbook.Close False Next f End Sub Sub OpenOneFile() Dim fn As Variant fn = Application.GetOpenFilename("Excel-files,*.xls", _ 1, "Select One File To Open", , False) If TypeName(fn) = "Boolean" Then Exit Sub Debug.Print "Selected file: " & fn Workbooks.Open fn End Sub Sub kitap_ismi() Sheets("Sayfa1").Range("A1").Value = ThisWorkbook.FullName End Sub Public AppCap$ Public ActWinCap$ 'Titelleiste ndern, wenn Mappe aktiviert wird Private Sub Workbook_Activate() Application.Caption = "excel-lex" ActiveWindow.Caption = "http://www.excel-lex.de.vu: Das EXCEL-2000-Lexikon 2003 K.-M. Buss" End Sub 'Titelleiste zurcksetzen, wenn diese geschlossen wird Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.Caption = AppCap ActiveWindow.Caption = ActWinCap End Sub 'Titelleiste zurcksetzen, wenn diese deaktiviert wird Private Sub Workbook_Deactivate() Application.Caption = AppCap ActiveWindow.Caption = ActWinCap End Sub 'Titelleiste ndern, wenn Mappe geffnet wird Private Sub Workbook_Open() Application.Caption = "excel-lex" ActiveWindow.Caption = "http://www.excel-lex.de.vu: Das EXCEL-2000-Lexikon 2003 K.-M. Buss" End Sub Sub Workbook_Open() With Worksheets(1).Range("A1") .Value = .Value + 1 End With End Sub
Option Explicit Sub sayfalari_ayir_kaydet() Dim Sheet As Worksheet, SheetName$, MyFilePath$, N& MyFilePath$ = ActiveWorkbook.Path & "\" & _ Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) With Application .ScreenUpdating = False .DisplayAlerts = False On Error Resume Next MkDir MyFilePath For N = 1 To Sheets.Count Sheets(N).Activate SheetName = ActiveSheet.Name Cells.Copy Workbooks.Add (xlWBATWorksheet) With ActiveWorkbook With .ActiveSheet .Paste .Name = SheetName [A1].Select End With .SaveAs Filename:=MyFilePath _ & "\" & SheetName & ".xls" .Close SaveChanges:=True End With .CutCopyMode = False Next End With Sayfa1.Activate End Sub Sub auto_open() Worksheets("Sheet2").Range("A1") = Worksheets("Sheet2").Range("A1") + 1 End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Range("A1").Value = "Stand: " & Format(Date, "DD.MM.YYYY") Worksheets("Tabelle1").PageSetup.LeftFooter = "Stand: " & Format(Date, "DD.MM.YYYY") End Sub Sub ShowFileSaveAsDialog() Workbooks.Add ' create a new workbook With Worksheets(1).Range("A1") ' add information to the new workbook .Formula = "Log File for " & Format(Date, "yyyy-mm-dd") & ":" .Font.Size = 14 .Font.Bold = True End With Application.Dialogs(xlDialogSaveAs).Show ' display the Save as dialog If Len(ActiveWorkbook.Path) = 0 Then ' the workbook was not saved MsgBox "You can save the workbook manually later..." Else MsgBox "The workbook is saved as " & ActiveWorkbook.FullName End If End Sub Sub SaveOneFile() Dim fn As Variant fn = Application.GetSaveAsFilename("MyFileName.xls", _ "Excel files,*.xls", 1, "Select your folder and filename") If TypeName(fn) = "Boolean" Then Exit Sub ActiveWorkbook.SaveAs fn End Sub Sub InTheMiddle() Dim dWidth As Double, dHeight As Double With Application .WindowState = xlMaximized dWidth = .Width dHeight = .Height .WindowState = xlNormal .Top = dHeight / 4 .Height = dHeight / 2 .Left = dWidth / 4 .Width = dWidth / 2 End With End Sub
Private Sub CmdIntro_Click() ActiveWindow.WindowState = xlMinimized End Sub This workbook blmne; Private Sub Workbook_Open() Dim Counter As Long, LastOpen As String, Msg As String Counter = GetSetting("XYZ Corp", "Budget", "Count", 0) LastOpen = GetSetting("XYZ Corp", "Budget", "Opened", "") Msg = "alma kitab " & Counter & " kere ald." Msg = Msg & vbCrLf & "En son al: " & LastOpen MsgBox Msg, vbInformation, ThisWorkbook.Name Counter = Counter + 1 LastOpen = Date & " " & Time SaveSetting "XYZ Corp", "Budget", "Count", Counter SaveSetting "XYZ Corp", "Budget", "Opened", LastOpen End SaveWorkbookBackup() Sub Sub Dim awb As Workbook, BackupFileName As String, i As Integer, OK As Boolean If TypeName(ActiveWorkbook) = "Nothing" Then Exit Sub Set awb = ActiveWorkbook If awb.path = "" Then Application.Dialogs(xlDialogSaveAs).Show Else BackupFileName = awb.FullName i=0 While InStr(i + 1, BackupFileName, ".") > 0 i = InStr(i + 1, BackupFileName, ".") Wend If i > 0 Then BackupFileName = Left(BackupFileName, i - 1) BackupFileName = BackupFileName & ".bak" OK = False On Error GoTo NotAbleToSave With awb Application.StatusBar = "Saving this workbook..." .Save Application.StatusBar = "Saving this workbook backup..." .SaveCopyAs BackupFileName OK = True End With End If NotAbleToSave: Set awb = Nothing Application.StatusBar = False If Not OK Then MsgBox "Backup Copy Not Saved!", vbExclamation, ThisWorkbook.Name End If End Sub, Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.FullName End Sub
' revised 04 July 2003 by Tom Ogilvy to add ' sheets when reaching ROWLIM formulas Const SHEETNAME As String = "Formulas in *" Const ALLFORMULAS As Integer = _ xlNumbers + xlTextValues + xlLogical + xlErrors Const ROWLIM As Long = 65500 Dim formulaSht As Worksheet Dim destRng As Range Dim cell As Range Dim wkSht As Worksheet Dim formulaRng As Range Dim shCnt As Long Dim oldScreenUpdating As Boolean With Application oldScreenUpdating = .ScreenUpdating .ScreenUpdating = False End With shCnt = 0 ListFormulasAddSheet formulaSht, shCnt ' list formulas on each sheet Set destRng = formulaSht.Range("A4") For Each wkSht In ActiveWorkbook.Worksheets If Not wkSht.Name Like SHEETNAME Then Application.StatusBar = wkSht.Name destRng.Value = wkSht.Name Set destRng = destRng.Offset(1, 0) On Error Resume Next Set formulaRng = wkSht.Cells.SpecialCells( _ xlCellTypeFormulas, ALLFORMULAS) On Error GoTo 0 If formulaRng Is Nothing Then destRng.Offset(0, 1).Value = "None" Set destRng = destRng.Offset(1, 0) Else For Each cell In formulaRng With destRng .Offset(0, 1) = cell.Address(0, 0) .Offset(0, 2) = "'" & cell.Formula .Offset(0, 3) = cell.Value End With Set destRng = destRng.Offset(1, 0) If destRng.row > ROWLIM Then ListFormulasAddSheet formulaSht, shCnt Set destRng = formulaSht.Range("A5") destRng.Offset(-1, 0).Value = wkSht.Name End If Next cell Set formulaRng = Nothing End If With destRng.Resize(1, 4).Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With Set destRng = destRng.Offset(1, 0) If destRng.row > ROWLIM Then ListFormulasAddSheet formulaSht, shCnt Set destRng = formulaSht.Range("A5") destRng.Offset(-1, 0).Value = wkSht.Name End If End If Next wkSht With Application .StatusBar = False .ScreenUpdating = oldScreenUpdating End With End Sub Private Sub ListFormulasAddSheet( _ formulaSht As Worksheet, shtCnt As Long) Const SHEETNAME As String = "Formulas in " Const SHEETTITLE As String = "Formulas in $ as of " Const DATEFORMAT As String = "dd MMM yyyy hh:mm" Dim shtName As String With ActiveWorkbook ' Delete existing sheet and create new one shtCnt = shtCnt + 1
' Thanks to Tom Ogilvy for help with overflow. Const SHEETNAME As String = "Names in *" Const ROWLIM As Long = 65500 Dim nameSht As Worksheet Dim destRng As Range Dim cell As Range Dim wkSht As Worksheet Dim shCnt As Long Dim i As Long Dim oldScreenUpdating As Boolean With Application oldScreenUpdating = .ScreenUpdating .ScreenUpdating = False End With shCnt = 0 ListNamesAddSheet nameSht, shCnt ' list Workbook-level names Set destRng = nameSht.Range("A5") With destRng.Offset(-1, 0) .Value = "Workbook-Level names" .Font.Bold = True End With With ActiveWorkbook.Names If .Count Then destRng.Offset(0, 1).ListNames 'only workbook level Set destRng = destRng.Offset(0, 1).End(xlDown).Offset(1, -1) Else destRng.Offset(0, 1).Value = "None" Set destRng = destRng.Offset(0, 1) End If End With With destRng.Resize(1, 3).Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With Set destRng = destRng.Offset(1, 0) For Each wkSht In ActiveWorkbook.Worksheets With destRng .Value = "Names in sheet """ & wkSht.Name & """" .Font.Bold = True Set destRng = .Offset(1, 0) End With With wkSht.Names If .Count Then For i = 1 To .Count With .Item(i) destRng.Offset(0, 1) = Mid(.Name, InStr(.Name, "!") + 1) destRng.Offset(0, 2) = "'" & .RefersTo Set destRng = destRng.Offset(1, 0) If destRng.Row > ROWLIM Then ListNamesAddSheet nameSht, shCnt Set destRng = nameSht.Range("A5") destRng.Offset(-1, 0).Value = _ "Names in sheet """ & wkSht.Name & """" End If End With Next i Else destRng.Offset(0, 1).Value = "None" Set destRng = destRng.Offset(1, 0) End If End With With destRng.Resize(1, 4).Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With Set destRng = destRng.Offset(1, 0) Next wkSht With Application .StatusBar = False .ScreenUpdating = oldScreenUpdating End With End Sub Private Sub ListNamesAddSheet( _ nameSht As Worksheet, shtCnt As Long) Const SHEETNAME As String = "Names in "
'Prevent Printing via menu MenuBars(xlWorksheet).Menus("File").MenuItems("Print...").Delete 'Turn off Print icon wherever it may be in the toolbars For J = 1 To Toolbars.Count For K = 1 To Toolbars(J).ToolbarButtons.Count If Toolbars(J).ToolbarButtons(K).Id = 2 Then Toolbars(J).ToolbarButtons(K).Enabled = False End If If Toolbars(J).ToolbarButtons(K).Id = 3 Then Toolbars(J).ToolbarButtons(K).Enabled = False End If Next K Next J End Sub Sub Auto_Close() 'Reset the menu items For Each mb In MenuBars mb.Reset Next mb 'Reset the buttons For J = 1 To Toolbars.Count For K = 1 To Toolbars(J).ToolbarButtons.Count If Toolbars(J).ToolbarButtons(K).Id = 2 Then Toolbars(J).ToolbarButtons(K).Enabled = True End If If Toolbars(J).ToolbarButtons(K).Id = 3 Then Toolbars(J).ToolbarButtons(K).Enabled = True End If Next K Next J End Sub Private Sub Workbook_BeforePrint(Cancel As Boolean) Cancel = True End Sub Sub DeleteShapes() Dim wks As Worksheet For Each wks In Worksheets wks.Pictures.Delete Next wks End Sub Private Sub Command1_Click() Dim a a = Shell("C:\WINDOWS\Explorer.exe c:\windows", vbNormalFocus) End Sub Sub Klasr_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("D:\Excelrnekleri") End Sub Sub klasr_ara() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.FolderExists("C:\SXS") If a = True Then MsgBox "Bu isimde bir klasr var" Else MsgBox "Bu isimde bir klasr yok" End If End Sub
Sub Klasr_Bilgisi_Gster() Dim ds, f, s Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("D:\Excelrnekleri") s = UCase("D:\Excelrnekleri") & vbCrLf s = s & "Created: " & f.DateCreated & vbCrLf 'Oluturma s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf 'Son Eriim s = s & "Last Modified: " & f.DateLastModified 'Son Deitirilme MsgBox s, 0, "File Access Info" End Sub Sub Klasr_Bilgisi_Gster() Dim ds, f, s Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("D:\Excelrnekleri") s = UCase("D:\Excelrnekleri") & vbCrLf s = s & "Created: " & f.DateCreated & vbCrLf 'Oluturma s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf 'Son Eriim s = s & "Last Modified: " & f.DateLastModified 'Son Deitirilme MsgBox s, 0, "File Access Info" End Sub Sub Klasr_smi_Deitir() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") dosya = ds.GetFileName("D:\Excelrnekleri\Yeni") dosya2 = ds.GetFileName("C:\SXS") f = ds.MoveFolder(dosya, dosya2) End Sub Sub Klasr_smi_Deitir() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") dosya = ds.GetFileName("D:\Excelrnekleri\Yeni") dosya2 = ds.GetFileName("C:\SXS") f = ds.MoveFolder(dosya, dosya2) End Sub Sub Klasr_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetFolder("D:\Excelrnekleri") End Sub Sub Klasr_Olutur() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.CreateFolder "C:\SXS\Deneme" End Sub Sub Klasr_Olutur() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.CreateFolder "C:\SXS\Deneme" End Sub Sub Dizin_smi_Olutur() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.BuildPath("C:\SXS", "\A") MsgBox a End Sub Sub Yedekle_Pocket() Dim Zippeur$, Archive$, Source$, Tarih$ Zippeur = "C:\Program Files\WinRAR\WinRAR.exe" Tarih = Format(Date, "d-m-yy") 'Rarlanacak Arivin ad Archive = "C:\PocketYedek\" & Tarih 'Rar'lanacak Dosyann yolu veya Klasr Source = "C:\Docume~1\Azakli\Belgel~1\Pocket~1\*.xls" ShellExecute 0, "open", Zippeur, _ "a " & Archive & " " & Source, "", vbHide For i = 1 To 10: DoEvents: Next End Sub Sub Klasr_Sil() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.DeleteFolder "C:\SXS\Deneme" End Sub
Sub Klasr_Sil() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.DeleteFolder "C:\SXS\Deneme" End Sub Sub klasr_ara() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.FolderExists("C:\SXS") If a = True Then MsgBox "Bu isimde bir klasr var" Else MsgBox "Bu isimde bir klasr yok" End If End Sub Sub DosyaKlasorYol() 'Aktif alma Kitabnn ismini alma kitabnn balna (en ste yazdrr) ActiveWindow.Caption = ActiveWorkbook.FullName 'Aktif alma Kitabnn ismini aktif hcreye yazdrr ActiveCell = ActiveWorkbook.FullName 'Aktif hcreye aktif sayfann isminin yazdrlmas ActiveCell.Value = ActiveSheet.Name 'Aktif alma sayfasnn isminin alma kitabnn balna (en ste) yazdrr ActiveWindow.Caption = ActiveSheet.Name 'belirtilen dizindeki dosyann boyutunu verir MsgBox FileLen("C:\Ahmet\tanan.xls") 'Belirtilen srcdeki klasrn ismini deitirir Name "C:\Ahmet\Alihan\12.xls" As "C:\Veli\tanan.xls" 'Belirtilen srcdeki klasrn ismini deitirir Name "C:\Alis" As "C:\Ahmet" 'Yeni Klasr dizin oluturur MkDir "c:\Alihan" End Sub Private Sub UserForm_Initialize() MyPath = "C:\Temp\" MyObj = Dir(MyPath, vbDirectory) Do While MyObj <> "" i=i+1 If (GetAttr(MyPath & MyObj) And vbDirectory) = vbDirectory Then If MyObj <> ".." And MyObj <> "." Then ComboBox1.AddItem MyObj End If End If MyObj = Dir Loop End Sub Sub Dosya_Kopyala() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.CopyFile "D:\Excelrnekleri\*.xls", "C:\SXS" End Sub Sub Dosya_Kopyala() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.CopyFile "D:\Excelrnekleri\*.xls", "C:\SXS" End Sub Sub Groesse() Dim sFileName As String 'sFileName = ThisWorkbook.Name sFileName = "C:\xls.xls" 'C:\pir\xls.xls MsgBox "Diese Mappe hat eine Grsse von " & FileLen(sFileName) & " kB" End Sub
Sayfa1'e A1 hcresinden balayarak aadoru klasr iindeki doyalara kpr kurar, anasayfann ad "anasayfa.xls" olmal veya kodu deitirin Private Sub Workbook_Open() Dim fs, f, f1, fc, s Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(ActiveWorkbook.Path) Set fc = f.Files i=1 For Each f1 In fc If f1.Name <> "anasayfa.xls" Then Sheets("Sayfa1"). Range("a" & i).Select ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=f1.Name, _ TextToDisplay:=Mid(f1.Name, 1, Len(f1.Name) - 4) i=i+1 End If Next End Sub hOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type '32-bit API declarations Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long Function GetDirectory(Optional Msg) As String Dim bInfo As BROWSEINFO Dim path As String Dim r As Long, x As Long, pos As Integer bInfo.pidlRoot = 0& If IsMissing(Msg) Then bInfo.lpszTitle = "Select a folder." Else bInfo.lpszTitle = Msg End If bInfo.ulFlags = &H1 x = SHBrowseForFolder(bInfo) path = Space$(512) r = SHGetPathFromIDList(ByVal x, ByVal path) If r Then pos = InStr(path, Chr$(0)) GetDirectory = Left(path, pos - 1) Range("A1") = GetDirectory Else GetDirectory = "" End If End Function
lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long Sub Verzeichnisse_auflisten() Dim Pfad1, Name1, Anzahl, X, X0, X1, X2, Verz, Anzverz, Gre Dim TB1, TB2 As Worksheet Dim msg As String Set TB1 = ThisWorkbook.Worksheets(1) Set TB2 = ThisWorkbook.Worksheets(2) start = Now TB1.[a:D] = "" TB2.[a:D] = "" 'berflssige Tabellenbltter lschen If ThisWorkbook.Worksheets.Count > 2 Then Application.DisplayAlerts = False For X = 3 To ThisWorkbook.Worksheets.Count ThisWorkbook.Worksheets(3).Delete Next X Application.DisplayAlerts = True End If ' Pfad abfragen msg = "Whlen Sie bitte einen Ordner aus:" Pfad1 = getdirectory(msg) If Pfad1 = "" Then Exit Sub Name1 = Dir(Pfad1, vbDirectory) ' Ersten Eintrag abrufen. TB1.[a2] = Pfad1 Anzahl = 2 TB1.[a1] = "Pfad" TB1.[b1] = "UnterVerz." TB1.[c1] = "Anz. Dateien" TB1.[d1] = "Datgre in Verz." X0 = 2 X1 = 2 Do While TB1.Cells(Rows.Count, 1).End(xlUp).Row <> TB1.Cells(Rows.Count, 2).End(xlUp).Row For X2 = X0 To X1 Pfad1 = TB1.Cells(X2, 1) ' Pfad setzen. If Right(Pfad1, 1) <> "\" Then Pfad1 = Pfad1 & "\" Name1 = Dir(Pfad1, vbDirectory) ' Ersten Eintrag abrufen. Verz = 0 Do While Name1 <> "" ' Schleife beginnen. ' Aktuelles und bergeordnetes Verzeichnis ignorieren. If Name1 <> "." And Name1 <> ".." Then ' Mit bit-weisem Vergleich sicherstellen, da Name1 ein ' Verzeichnis ist. If (GetAttr(Pfad1 & Name1) And vbDirectory) = vbDirectory Then Anzahl = Anzahl + 1 TB1.Cells(Anzahl, 1) = Pfad1 & Name1 & "\" Verz = Verz + 1 'Eintrag nur anzeigen, wenn es sich um ein Verzeichnis handelt. End If End If Name1 = Dir ' Nchsten Eintrag abrufen. Loop TB1.Cells(X2, 2) = Verz Next X2 X0 = X1 + 1 X1 = X2 Loop 'Dateien aus den Verzeichnissen auslesen Anzverz = TB1.Cells(Rows.Count, 1).End(xlUp).Row i=1 ii = 0 For Verz = 2 To Anzverz Anzahl = 0 Gre = 0 Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(TB1.Cells(Verz, 1)) Set fc = f.Files
Sub jpgbul() Dim Dosya Dim i As Integer Dosya = Dir("C:\Evren\Resimler\*.jpg") i=1 While Dosya <> "" Dosya = Dir Cells(i, 1) = Dosya i=i+1 Wend MsgBox i - 1 End Sub Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = vbKeyEscape Then MsgBox "Escape'e bastn" End If If KeyCode = vbKeyRight Then MsgBox "sa ok'a bastn" End If If KeyCode = vbKeyLeft Then MsgBox "sol ok'a bastn" End If If KeyCode = vbKeyUp Then MsgBox "ileri ok'a bastn" End If
If KeyCode = vbKeyDown Then MsgBox "geri ok'a bastn" End If End Sub Bir modul ilave edip, iine aadakileri yaptrn. Daha sonra da bir ekilde Test isimli prosedr altrn. (Formun ad - Name zellii - UserForm1 olmas visual basic kodu: -------------------------------------------------------------------------------Sub Test() UserForm1.Show 0 End Sub
Vba penceresinde kod yazarken rnein Worksheets yazacaksnz, ancak bunu alr pencereden semek iin CTR + J yi, nerme veya tamamlama iin ise Sub Yaz() ActiveCell.Formula = [b3].Text & ":\" & [c3].Text & "\" & [d3].Text & "\" & [e3].Text & "\[" & [e4] & ".xls]" & [e5] & " '!" & [e6] End Sub KODLARIN BAINA VEYA SONUNA GRLDNDE AIKLAMA EKLER MsgBox "DENEME"
CTRL+C CTRL+V LE KOPYALA YAPITIR LEMN YAPABLRSNZ Kodlarnzn balangcnda; Application.EnableEvents = False 'kodlarnzn bitiminde de; Application.EnabeEvents = True 'kullann BU KOD YAZDIINIZ KODLAR HATA VERRSE ONU ENGELLER (KODUNUZUN BAINA EKLEYN) On Error Resume Next rnek; eer(ActiveWorkbook.Names, "ThisOne") Then ... Function IsIn(oCollection As Object, stName As String) As Boolean Dim O As Object On Error Goto NotIn Set O = oCollection(stName) IsIn = True 'succeeded in creating a pointer to the object so 'must be there NotIn: End Function
kullanl 'A1=5 'B1=Columnletter(A1) Function ColumnLetter(ColumnNumber As Integer) As String If ColumnNumber > 26 Then ColumnLetter = Chr(Int((ColumnNumber - 1) / 26) + 64) & Chr(((ColumnNumber - 1) Mod 26) + 65) Else ColumnLetter = Chr(ColumnNumber + 64) End If End Function rnek kullanl =Columnletter(A1) Function ColumnLetter(ColumnNumber As Integer) As String If ColumnNumber > 26 Then ColumnLetter = Chr(Int((ColumnNumber - 1) / 26) + 64) & Chr(((ColumnNumber - 1) Mod 26) + 65) Else ColumnLetter = Chr(ColumnNumber + 64) End If End Function Sub Dialog_18() Application.Dialogs(xlDialogCustomizeToolbar).Show End Sub Tablonuzun herhangi bir hcresi seiliyken aadaki makroyu altrn. Sub Makro1() Selection.CurrentRegion.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False ActiveCell.SpecialCells(xlLastCell).Select End Sub KOPYALAMA YAPITIRMA LEMLER Sub kopya() Range("a1:a2").Copy Range("b1").PasteSpecial xlPasteValues Application.CutCopyMode = False Range("a1:a2").Value = "" End Sub Sub autobreite() spbreite = ActiveCell.Columns.ColumnWidth Selection.Copy Range("A1").Select ActiveSheet.Paste With Selection .ColumnWidth = spbreite End With End Sub Sub NewBar() Application.CommandBars.Add(Name:="BarPerso").Visible = True Application.CommandBars("BarPerso").Controls.Add Type:=msoControlButton, ID _ :=19, Before:=1 Application.CommandBars("BarPerso").Controls.Add Type:=msoControlButton, ID _ :=22, Before:=2 With CommandBars("BarPerso") .Left = 620 .Top = 450 .Width = 120 End With End Sub
Sub auto_open() 'kopyala kes yaptr alta pasif yapar EnableControl 21, False 'Kes EnableControl 19, False ' Kopyala EnableControl 22, False ' Yaptr EnableControl 755, False ' zelyaptr Application.OnKey "^c", "yasakla" Application.OnKey "^v", "yasakla" Application.CellDragAndDrop = False 'hcreyi oaltma ve tama CommandBars("ToolBar List").Enabled = False 'dzen mensndeki ilgili menleri gizle End Sub Sub auto_close() 'kopyala kes yaptr kapanrken aktifletirir EnableControl 21, True 'Kes EnableControl 19, True ' Kopyala EnableControl 22, True ' Yaptr EnableControl 755, True ' zelyaptr Application.OnKey "^c" Application.OnKey "^v" Application.CellDragAndDrop = True CommandBars("ToolBar List").Enabled = True End Sub Sub EnableControl(Id As Integer, Enabled As Boolean) Dim CB As CommandBar Dim C As CommandBarControl On Error Resume Next For Each CB In Application.CommandBars Set C = CB.FindControl(Id:=Id, recursive:=True) If Not C Is Nothing Then C.Enabled = Enabled Next End Sub
Sub yasakla() MsgBox "zgnm yapmak istediiniz ilem yasaklanmtr.!", , "www.kod.gen.tr" End Sub Aadaki makroyu sralama ilemi iin kullanyorum. Ancak sayfa koruma yaptm zaman doal olarak sralamay yapmyor. Kilitli ve gizli hcreleri seerek Sub SIRALA() Range("B6:F300").Select Selection.Sort Key1:=Range("B6"), Order1:=xlAscending, Header:=xlNo, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal MsgBox "BU BU KADAR ...)", vbInformation End Sub Bunun iin kodlarnzn bana korumay aan, sonunada korumay tekrar koyan satrlar ilave edebilirsiniz. rnein koruma ifreniz "1234" olsun; visual basic kodu: Sub SIRALA() activesheet.unprotect "1234" Range("B6:F300").Sort Key1:=Range("B6") MsgBox "BU BU KADAR ...)", vbInformation activesheet.protect "1234" End Sub Sub deneme() Sheets("Sayfa1").Unprotect Password:="sifre" 'Buraya sizin kodlarnz yazn. Sheets("Sayfa1").Protect Password:="sifre" End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("a1")) Is Nothing Then If Range("A1").Value = 6 Then Range("C1").Value = Range("C1").Value - Range("B1").Value End If End If End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveCell.Address = "$A$1" And [a1] = 0 Then Call makroad End Sub Sub Dialog_14() Application.Dialogs(xlDialogConditionalFormatting).Show End Sub Sub Kk_Dosya_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") s = d.RootFolder MsgBox s End Sub Sub Kk_Dosya_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") s = d.RootFolder MsgBox s End Sub Sub Dialog_39() Application.Dialogs(xlDialogInsertHyperlink).Show End Sub Sub KopruSil() Range("A:A").Select Selection.Hyperlinks.Delete Range("A1").Select End Sub For x = Cells(65536, 3).End(xlUp).Row To 2 Step -1 If Cells(x, 3) = ComboBox1.Text Then Rows(x).Delete Next Private Sub workbook_open() Application.Visible = False UserForm1.Show End Sub 'Dosyanza ekleyeceiniz Userforma bir CommandButton ve iki Textbox yerletirin ve aadaki kodu Userformun kod ksmna girin Private Sub CommandButton1_Click() If TextBox1.Value = "Ali" Or TextBox1.Value = "Veli" Then goto Kontrol2 Else Unload UserForm1 MsgBox "zgnm girdiiniz kullanc ad hatal.", vbCritical, "HATA" ActiveWorkbook.Close 0 Exit Sub EndIf Kontrol2: If TextBox2.Value = "123" Or TextBox2.Value = "456" Then MsgBox "Programa giriiniz onaylanmtr.", vbInformation Unload Me Application.Visible = True Else Unload UserForm1 MsgBox "zgnm girdiiniz parola hatal.", vbCritical, "HATA" ActiveWorkbook.Close 0 Exit Sub EndIf End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode <> 1 Then Cancel = True End Sub
'Ayrca Textbox2'nin Properties ksmnda bulunan "PasswordChar" blmne "*" (yldz) iareti koyarsanz girilen parola ekranda "*****" eklinde grne
Private Declare Function GUN Lib "advapi32.dll" Alias "GetUserNameA" (ByVal myPara As String, myLen As Long) As Long '******************************************************* 'Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long 'Private Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, nSize As Long) As Long Public Function ActiveUserName() As String Dim AUN As String * 100 Dim AunLen As Byte AunLen = 100 If GUN(AUN, Len(AUN)) Then ActiveUserName = Left(AUN, AunLen) Else ActiveUserName = "User can not be Identified" End If End Function Public Function ActiveComputerName() As String Dim ACN As String * 100 Dim AcnLen As Byte AcnLen = 100 If GCN(ACN, Len(ACN)) Then ActiveComputerName = Left(ACN, AcnLen) Else ActiveComputerName = "User can not be Identified" End If End Function Sub wer_und_was_bin_ich() Dim Qe As Byte MsgBox ("Mein Rechner heisst" & ActiveComputerName) MsgBox ("Aktuell angemeldeter User ist: " & ActiveUserName) End Sub Declare Function GetUserName Lib "advapi32.dll" _ Alias "GetUserNameA" (ByVal lpBuffer As String, _ nSize As Long) As Long
Sub ShowUserName() Dim Buffer As String * 100 Dim BuffLen As Long BuffLen = 100 GetUserName Buffer, BuffLen MsgBox Left(Buffer, BuffLen - 1) End Sub Option Explicit Sub CloseUserBooks() Dim objWB As Workbook, arrSysBooks arrSysBooks = Array(ThisWorkbook.Name, _ "SYS01F.XLS", "SYS01S.XLS", _ "SYS01M.XLS", "SYS01D.XLS") 'These books can be open. With Application .DisplayAlerts = True 'Make sure the user has a chance to save! For Each objWB In Workbooks 'Loop through the Workbook collection. If IsError(.Match(objWB.Name, arrSysBooks, 0)) Then 'Not in the array? MsgBox "Your workbook " & objWB.Name & " must be closed before the system can start.", 0, "The Fortress" objWB.Close End If Next End With End Sub Fonksiyon; program ierisinden parametrelerle arlabilen ve geriye deer dndren komutlar dizisidir. Excelde Fonksiyonlar; "Fonksiyonlar, bamsz de
'Fonksiyonlar ile nesneler ynetilemez, zellikleri etkilenemez sadece arlan yere deer dndrr. Yani fonksiyonlar iinden formlara ve sayfa nesnelerin 'Kullanc tanml fonksiyonlar yine makrolar gibi modullere yazlrlar. Function Fonksiyon_ad([Deiken1] As tip , [Deiken2] As tip,) ... kodlar Fonksiyon_ad=[atanan deer] End Function
'Fonksiyonlar dier makrodan ayran zellik nesnelere etki etmeyip geriye deer dndrmesidir. Burada Fonksiyon_ad=[atanan deer] satryla fonksiyon
Function Puan(a) If a > 100 Then Puan = "Notun 100 den byk olduuna emin misiniz?" If a = "d" Then Puan = "F1" If a = "g" Then Puan = "F2" If a < 0 Then Puan = "NOT Sfrdan Kk Olmaz" If a >= 0 And a <= 59 Then Puan = "F3" If a >= 60 And a <= 69 Then Puan = "C" If a >= 70 And a <= 74 Then Puan = "B2" If a >= 75 And a <= 80 Then Puan = "B1" If a >= 81 And a <= 89 Then Puan = "A2" If a >= 90 And a <= 100 Then Puan = "A1" End Function Function Sutun2(a As String) As Integer If LCase(a) = LCase("a") Then Sutun2 = 1 End Function Function SayfaSec(Hucre As Range) As String Select Case Range("B1") Case 0 SayfaSec = "Sayfa bo" Case 1 To 51 SayfaSec = Sheets(1).Name Case 52 To 101 SayfaSec = Sheets(2).Name '...... '.... '... End Select End Function ="Sayfa " & nsat(B1/50) Sub Test() Dim MyLang As Long MyLang = Application.LanguageSettings.LanguageID(msoLanguageIDInstall) MsgBox GetLang(MyLang) End Sub ' Function GetLang(ID As Long) As String Select Case ID Case msoLanguageIDEnglishUS GetLang = "XL - Ingilizce" Case msoLanguageIDTurkish GetLang = "XL - Turkce" Case msoLanguageIDRussian GetLang = "XL - Rusca" Case msoLanguageIDFrench GetLang = "XL - Fransizca" Case msoLanguageIDDutch GetLang = "XL - Almanca" Case msoLanguageIDSpanish GetLang = "XL - Ispanyolca" Case msoLanguageIDItalian GetLang = "XL - Italyanca" Case Else GetLang = "XL - Belirsiz" End Select End Function On Error Resume Next a = Round(TextBox3, 2) a = WorksheetFunction.Substitute(a, ",", ".") b = Round(TextBox4, 2) b = WorksheetFunction.Substitute(b, ",", ".") c = Round(TextBox5, 2) c = WorksheetFunction.Substitute(c, ",", ".") y = Round(TextBox2, 2) y = WorksheetFunction.Substitute(y, ",", ".") z = (Val(a) + Val(b) + Val(c)) - Val(y) z = WorksheetFunction.Substitute(z, ".", ",") TextBox1 = z
Sub LowerCase() Dim cell As Range For Each cell In Selection.Cells If cell.HasFormula = False Then cell = LCase(cell) End If Next End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Application.EnableEvents = False Target = UCase(Target) Application.EnableEvents = True End Sub B1 hcresine girilecek forml; =TAMSAYI(A1) C1 hcresine girilecek forml; =(A1-TAMSAYI(A1))*100 Private Sub UserForm_Initialize() Dim Metin As String Dim byt As Byte Label1.Caption = "Sleyman" For byt = 1 To Len(Label1) Metin = Metin & Mid(Label1, byt, 1) & Chr(13) Next byt Label1 = Metin End Sub Private Sub UserForm_Initialize() Label1.Caption = Format(Now, "dddd d mmmm yyyy hh:mm:ss") End Sub Label3 = Format((Val(Label1) + Val(Label2)) / 2, "0.00") Private Sub UserForm_Initialize() Dim NewLabel As Control Me.Width = 600 Me.Height = 300 TopPos = 4 For j = 1 To 5 TopPos = TopPos + 20 LeftPos = 10 For i = 1 To 10 Set NewLabel = Controls.Add("Forms.label.1") With NewLabel .Width = 50 .Caption = "Test" & i & " - " & j .Height = 15 .Left = LeftPos + .Width .Top = TopPos .Tag = i .AutoSize = True .Visible = True End With LeftPos = LeftPos + NewLabel.Width + 15 Next i Next j End Sub Label1 ve Label2'e deerleri aktardn kodun/prosedurun sonuna aadakini ilave et; Kod: Label3 = Format((Val(Label1) + Val(Label2)) / 2, "0.00") Private Sub UserForm_Initialize() UserForm1.Label1.Caption = Worksheets("Sayfa1").Range("A" & ActiveCell.Row) End Sub Private Sub UserForm_Initialize() Label1.Caption = Format(Now, "dddd d mmmm yyyy hh:mm:ss") End Sub Label1:Captioni = Now
Private Sub Label1_Click() Label1.Caption = "Programmer pir" End Sub Label3 = Format((Val(Label1) + Val(Label2)) / 2, "0.00") Sub ColorLinks() Dim myLnk As Hyperlink 'Dim wks As Worksheet ' For Each wks In ActiveWorkbook.Worksheets 'For Each myLnk In wks.Hyperlinks For Each myLnk In ActiveSheet.Hyperlinks 'MsgBox myLnk.Parent.Address & vbLf _ & myLnk.Parent.Parent.Name Range(myLnk.Parent.Address).Interior.ColorIndex = 34 Next myLnk ' Next wks End Sub Option Explicit Declare Function ShellAbout Lib "shell32.dll" _ Alias "ShellAboutA" ( _ ByVal hWnd As Long, _ ByVal szApp As String, _ ByVal szOtherStuff As String, _ ByVal hIcon As Long) As Long Declare Function GetActiveWindow Lib "user32" () As Long '// Define your message constants here Const strApp As String = "My Programe" Const strMyDetails As String = " Ivan F Moala, 3 Sept, 2001" Sub About() Dim hWnd As Long Dim x As Long hWnd = GetActiveWindow() x = ShellAbout(hWnd, strApp, Chr(13) & Chr(169) & strMyDetails _ & Chr(13), 0) End Sub BU KOD LSTBOX'A YAZILACAK Private Sub ListBox1_Change() Dim sira sira = "veri!b$" & ListBox1.ListIndex + 1& veri.textbox1.ControlSource = sira End Sub BU KOD LSTBOX' AYAZILACAK Private Sub ListBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Select Case KeyCode Case vbKeyEscape veri.Hide End Select End Sub BU KOD TEXTBOX'A YAZILACAK Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Select Case KeyCode Case vbKeyEscape veri.Hide End Select End Sub
Private Sub CommandButton1_Click() For X = 1 To Sheets("sayfa1").[A65536].End(3).Row If Left(Sheets("sayfa1").Cells(X, 1), 100) = TextBox1.Value Then Sheets("sayfa1").Rows(X).Delete MsgBox "SLND" TextBox1.SetFocus End If Next UserForm_Activate End Sub Private Sub ListBox1_Change() X = ListBox1.ListIndex TextBox1.Text = Sheets("SAYFA1").Cells(X + 1, 1) End Sub Private Sub UserForm_Activate() For X = 1 To Sheets("SAYFA1").[A65536].End(3).Row c=c+1 ListBox1.AddItem ListBox1.List(c - 1, 0) = Sheets("SAYFA1").Cells(X, 1) Next End Sub Private Sub TextBox1_Change() Dim MyRange As Range Dim noA As Integer ListBox1.Clear noA = WorksheetFunction.CountA(Sheets("Sayfa1").Range("A:A")) For Each MyRange In Sheets("Sayfa1").Range("A1:A" & noA) If Left(LCase(MyRange), Len(TextBox1)) = LCase(TextBox1) Then ListBox1.AddItem (MyRange) Next End Sub Private Sub ListBox1_Click() Dim x As Integer x = Sheets("Sayfa1").Range("A:A").Cells.Find(what:=ListBox1, LookIn:=xlValues).Row TextBox1.Value = ListBox1 TextBox2 = Sheets("Sayfa1").Cells(x, 2) End Sub Private Sub CommandButton1_Click() Dim Freezer As New FreezeForm Freezer.Freeze Me Dim I As Integer For I = 1 To 1000 ListBox1.AddItem "Item " & I DoEvents Next I End Sub Private Sub UserForm_Initialize() Dim myrange As Range Dim myrange As Range Set myrange = Range("A1:A200") For Each c In myrange If c.Value = ListBox1.Value Then TextBox1.Value = ListBox1.Value & c.Value.Offset(1, 0).Value End If Next End Sub Sub sayfa_isimleri_yaz() Sheets.Add i=1 s = ActiveSheet.Name For Each sht In ActiveWorkbook.Sheets Sheets(s).Cells(i, 1).Value = sht.Name ListBox1.AddItem sht.Name bu da listboxa yazar i=i+1 Next sht End Sub
ListBox1 de listelediim isime tklaynca "Sayfa3" de B4:B150 arasnda '(Her isimden bir adet bulunmaktadr.) C;D;E stunlarnda o isimin karsna gelen kayd TextBox1,TextBox2,TextBox3 de gstermek Dim x As Integer x = Sheets("ISCI_DATA").Range("B4:B9000").Cells.Find(What:=ListBox1, LookIn:=xlValues).Row TextBox2 = Sheets("ISCI_DATA").Cells(x, 3) TextBox3 = Sheets("ISCI_DATA").Cells(x, 4) TextBox4 = Format(Sheets("ISCI_DATA").Cells(x, 5), "dd.mm.yyyy") listbox1 in 4. kolonunun toplamn textbox1 de Private Sub UserForm_Initialize() For i = 1 To ListBox1.ListCount - 1 T1 = ListBox1.List(i - 1, 3) + T1 buradaki 3, 4.kolon numarasdr. Ona gre 1 eksiini alnz Next i TextBox1 = T1 End Sub bu listbox'a deerleri nasl aktardnza gre deiir. rnein Private Sub UserForm_Initialize() ListBox1.RowSource = "Sayfa1!a1: a10" End Sub Private Sub CommandButton1_Click() ListBox1.RowSource = "Sayfa1!a3:g8" 'lisbox'ta gsterilecek hcre aral ListBox1.ColumnCount = 7 ' lisbox'ta ki stun says End Sub Private Sub ListBox1_Click() MsgBox ListBox1.ListIndex'sra numaral olarak sayfadan aldryorsanz eit olmas iin +1 eklemelisiniz. End Sub Private Sub Listbox1_Click() ListBox2.ListIndex = ListBox1.ListIndex End Sub
Private Sub UserForm_Initialize() Sheets("sayfa9").Activate ListBox1.RowSource = "Sayfa9!B1:B5" ListBox2.RowSource = "Sayfa9!C1:C5" End Sub Private Sub UserForm_Initialize() ListBox1.RowSource = "Sayfa1!A1:A10" 'lisbox'ta gsterilecek hcre aral ListBox1.ColumnCount = 5 ' lisbox'ta ki stun says ListBox1.ColumnWidths = 100 & ";" & 70 'lisbox'taki stunlarn genilii End Sub verileri RowSource zellii ile alyorsanz silmeniz birey ifade etmiyecektir.Asl Sayfadaki Bilgileri silmeniz gerekmektedir.Bunun in yle yapm ListBoxa Kod: 'ListBox zellikleri belirleniyor Private Sub UserForm_Initialize() a = WorksheetFunction.CountA(Sheets("Sayfa1").Range("A2:A65536")) + 1 ListBox1.RowSource = "Sayfa1!A2:D" & a ListBox1.ColumnCount = 4 ListBox1.ColumnHeads = True ListBox1.ColumnWidths = "50;100;150;200" End Sub 'ListBox'dan seilen aktif hcre oluyor Private Sub ListBox1_Click() Dim i As Integer For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then Sheets("Sayfa1").Select Sheets("Sayfa1").Range("A" & ListBox1.ListIndex + 2).Select End If Next End Sub 'ListBox ift Tklandnda Aktif Satr Siliniyor Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Selection.EntireRow.Delete End Sub
Bunun iin userforma aadaki kodu yazmak gerekir,combobox a veri almak tek satrda rowsource komutu ile halledilir. Buna karn listboxta alnacak ver visual basic kodu: -------------------------------------------------------------------------------Private Sub UserForm_Initialize() ComboBox1.RowSource = "sayfa1!A1:A10" 'combobox1'e sayfa1 deki A1:A10 aralndaki deerleri atar ListBox1.RowSource = "sayfa1!A2:B10" 'listbox1'e sayfa1 deki A2:B10 aralndaki deerleri atar ListBox1.ColumnHeads = True 'listboxta stun balklarn grnr hale getirir burada balk A1:B1 araldr. ListBox1.ColumnCount = 2 'stun says-ka veri varsa o kadar stun almaldr ListBox1.ColumnWidths = "40;40" 'alan stunlarn genilikleri. End Sub Private Sub UserForm_Initialize() For i = 1 To [b65536].End(3).Row If Cells(i, 2) = "" Then GoTo 10 ListBox1.AddItem (Cells(i, 2)) 10 Next End Sub Yine rowsource ile almak isterseniz aadaki gibi en son dolu hcreyide tantabilirsiniz. visual basic kodu: Private Sub UserForm_Initialize() listbox1.rowsource="sayfa1!b1:b" & [sayfa1!b65536].end(3).row End Sub combobox iin grnecek satr says iin aadaki kodu kullann. ComboBox1.ListRows = 5 Listebox alr kutu olmad iin byle bir zellik yoktur,sadece yksekliini aadaki kod ile deitirebilirsiniz. ListBox1.Height = 50 her iki koduda UserForm_Initialize olayna yazabilirsiniz. Aadaki kodu deneyin. Listboxtaki verileri sayfa2 ye aktarr.
visual basic kodu: Private Sub CommandButton1_Click() Set s1 = Sheets("sayfa2") sat = ListBox1.ListCount sut = ListBox1.ColumnCount s1.Range(s1.Cells(1, 1), s1.Cells(sat, sut)) = ListBox1.List End Sub Private Sub UserForm_Initialize() satr = Cells(65536, 1).End(xlUp).Row kolon = Cells(1, 256).End(xlToLeft).Column bbb = Cells(satr, kolon).Address ListBox1.RowSource = "veri!A2:" & bbb End Sub Private Sub ListBox1_Click() On Error Resume Next 'hata durumunda hatay pas gemesini salar TextBox1 = "" 'textbox1 deki veriyi siler a = Sheets("PerBil").Range("D5:D34").Find(ListBox1.Value).Row 'listbox1 de seilen ismin, Perbil sayfasndaki D5:D34 aralnda yerini bulur ve satr dee For sira = 8 To 52 'dng balangc Perbil sayfasnn 8(H stunu) den balayarak 52(AZ stunu) ye kadar stunlarn taranmasn salar If sira <= 19 Then Cells(sira - 4, 7) = Sheets("Perbil").Cells(a, sira).Value 'Sicil bilgilerini kayt dosyasndaki yerine tar If sira >= 20 And sira < 24 Then Cells(sira - 2, 10) = Sheets("Perbil").Cells(a, sira).Value 'tazminat bilgilerini kayt dosyasndaki yerine tar If sira >= 24 And sira < 36 Then Cells(sira - 20, 10) = Sheets("Perbil").Cells(a, sira).Value 'terfi bilgilerini kayt dosyasndaki yerine tar If sira >= 36 And sira < 48 Then Cells(sira - 18, 7) = Sheets("Perbil").Cells(a, sira).Value 'kesinti bilgilerini kayt dosyasndaki yerine tar If sira >= 48 Then Cells(sira - 24, 10) = Sheets("Perbil").Cells(a, sira).Value 'dier bilgilerini kayt dosyasndaki yerine tar Next sira 'dngnn tekrar For komutuna yani baa dnmesini salar End Sub Private Sub UserForm_Initialize() Dim shttemp As Worksheet For Each shttemp In ActiveWorkbook.Worksheets ListBox1.AddItem "'" & shttemp.Name & "'!A1" Next End Sub
Private Sub ComboBox1_Change() Sheets("Sayfa1").Select ListBox1.Clear son = Cells(65536, 1).End(xlUp).Row For i = 1 To son If LCase(Cells(i, 2).Text) = LCase(ComboBox1.Text) Then Cells(i, 1).Select c=c+1 For Y = 1 To 7 ListBox1.AddItem ListBox1.List(c - 1, Y - 1) = Cells(i, Y).Value Next End If Next End Sub Private Sub UserForm_Initialize() On Error Resume Next With Application Me.Top = .Top Me.Left = .Left Me.Height = .Height Me.Width = .Width End With Sheets("Sayfa1").Select For i = 1 To Cells(65536, 2).End(xlUp).Row If WorksheetFunction.CountIf(Range("B1:B" & i), Cells(i, "b")) = 1 Then ComboBox1.AddItem Cells(i, "b") Next i ListBox1.ColumnCount = 7 ListBox1.ColumnWidths = 30 & ";" & 90 & ";" & 70 & ";" & 40 & ";" & 60 & ";" & 40 & "" End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) ListBox1.RemoveItem ListBox1.ListIndex Rows(ListBox1.ListIndex + 1).Delete End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = ListBox1.List(ListBox1.ListIndex, 0) 'ListBox'a tkladmzda deerleri textbox'lara alyoruz. TextBox2 = ListBox1.List(ListBox1.ListIndex, 1) TextBox3 = ListBox1.List(ListBox1.ListIndex, 2) TextBox4 = ListBox1.List(ListBox1.ListIndex, 3) TextBox5 = ListBox1.List(ListBox1.ListIndex, 4) TextBox6 = ListBox1.List(ListBox1.ListIndex, 5) TextBox7 = ListBox1.List(ListBox1.ListIndex, 6) TextBox8 = ListBox1.List(ListBox1.ListIndex, 7) TextBox9 = ListBox1.List(ListBox1.ListIndex, 8) End Sub Private Sub UserForm_Activate() X = WorksheetFunction.CountA(Sheets("Sayfa1").Range("A2:A65536")) + 1 ListBox1.RowSource = "Sayfa1!b2:b" & X End Sub Private Sub UserForm_Initialize() Dim i As Long For i = 1 To Worksheets.Count With Me.ListBox1 .AddItem Sheets(i).Name & "!A1" End With Next i Me.ListBox1.ListIndex = 0 End Sub Private Sub UserForm_Initialize() ListBox1.ColumnCount = 5 ListBox1.RowSource = "TABLO!A2:S4" ListBox1.ColumnHeads = True End Sub
ListBox'a aktarlacak veriler aktif sayfada A stununda ise ve UserForm zerinde 1 adet ListBox, 1 adet CommandButton varsa; Private Sub UserForm_Initialize() ListBox1.RowSource = "A1:A" & Cells(65536, 1).End(xlUp).Row ListBox1.MultiSelect = fmMultiSelectMulti ListBox1.ListStyle = fmListStyleOption End Sub Private Sub CommandButton1_Click() Dim i As Long, x As Long Dim MyArray() For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then ReDim Preserve MyArray(x) MyArray(x) = ListBox1.List(i) x=x+1 End If Next For i = LBound(MyArray) To UBound(MyArray) MsgBox "Secilen deger -" & i + 1 & ": " & MyArray(i) Next Erase MyArray End Sub Private Sub CommandButton1_Click() Range("D1") = ListBox1.Column(0) Range("E1") = ListBox1.Column(1) Range("F1") = ListBox1.Column(2) End Sub 'veya; Private Sub ListBox1_Click() Range("D1") = ListBox1.Column(0) Range("E1") = ListBox1.Column(1) Range("F1") = ListBox1.Column(2) End Sub x = listbox1 Ama : Workbooks.Open ("Dosya yolu" & x) Kapama : Workbooks(x).Close SaveChanges:=True/False Silme : Kill ("Dosya yolu" & x) Private Sub CommandButton1_Click() Range("a1").AutoFilter Field:=1 End Sub Private Sub ListBox1_Change() Range("A1").AutoFilter Field:=1, Criteria1:=ListBox1.Value End Sub Private Sub UserForm_Initialize() Sheets("Sayfa9").Activate a = WorksheetFunction.CountA(Range("A:A")) For i = 2 To a ListBox1.AddItem Cells(i, 1) Next ListBox1.ColumnCount = 4 ListBox1.ColumnWidths = "35,35,35,35" ListBox1.RowSource = "Sayfa9!a1:d5" End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Range("a1").AutoFilter Field:=1 Selection.AutoFilter End Sub
Private Sub TextBox1_Change() TextBox1.Value = UCase(TextBox1.Value) Dim i As Integer ListBox1.Clear For i = 1 To Worksheets.Count - 9 If Left(Worksheets(i).Name, Len(TextBox1)) = TextBox1 Then ListBox1.AddItem Worksheets(i).Name End If Next End Sub if listbox1.listcount=0 then label1="Aranan Kayt bulunamamtr" else label1="" end if A:A200 Hcrelerindeki verilerden listbox a sadece dolu hcreleri alr. (bo hcreler gzkmez) Kod: Private Sub UserForm_Initialize() Dim myrange As Range Dim myrange As Range Set myrange = Range("A1:A200") For Each c In myrange If c.Value = ListBox1.Value Then TextBox1.Value = ListBox1.Value & c.Value.Offset(1, 0).Value End If Next End Sub Private Sub UserForm_Initialize() On Error Resume Next Dim g As Integer Dim i As Integer For i = 2 To Worksheets.Count '3olursa ilk 2 sayfa gzkmez ListBox1.AddItem Worksheets(i).Name Next i End Sub Private Sub UserForm_Activate() For Each Ws In Worksheets frmlis.ListBox1.AddItem Ws.Name Next End Sub Private Sub UserForm_Activate() Me.ListBox1.AddItem "Deniz" Me.ListBox1.AddItem "Derya" Me.ListBox1.AddItem "smail" Me.ListBox1.AddItem "Hlya" Me.ListBox1.AddItem "Emel" Me.ListBox1.AddItem "Aye" End Sub Private Sub UserForm_Initialize() ListBox1.RowSource = "Sayfa1!A1:A10" 'lisbox'ta gsterilecek hcre aral ListBox1.ColumnCount = 5 ' lisbox'ta ki stun says ListBox1.ColumnWidths = 100 & ";" & 70 'lisbox'taki stunlarn genilii End Sub
ListBox zellikleri belirleniyor Private Sub UserForm_Initialize() a = WorksheetFunction.CountA(Sheets("Sayfa1").Range("A2:A65536")) + 1 ListBox1.RowSource = "Sayfa1!A2:D" & a ListBox1.ColumnCount = 4 ListBox1.ColumnHeads = True ListBox1.ColumnWidths = "50;100;150;200" End Sub 'ListBox'dan seilen aktif hcre oluyor Private Sub ListBox1_Click() Dim i As Integer For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then Sheets("Sayfa1").Select Sheets("Sayfa1").Range("A" & ListBox1.ListIndex + 2).Select End If Next End Sub 'ListBox ift Tklandnda Aktif Satr Siliniyor Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Selection.EntireRow.Delete End Sub Private Sub UserForm_Initialize() ListBox1.ColumnHeads = True ListBox1.ColumnCount = 50 ListBox1.RowSource = "Sayfa1!A1:AG200" End Sub A dan D ye kadar veri yaz ve gr Private Sub ListBox1_Click() Dim x As Integer x = Sheets("Sayfa1").Range("a:a").Cells.Find(What:=ListBox1, LookIn:=xlValues).Row TextBox1.Value = ListBox1 TextBox2 = Sheets("Sayfa1").Cells(x, 2) TextBox3 = Sheets("Sayfa1").Cells(x, 3) End Sub Private Sub UserForm_Initialize() ListBox1.RowSource = "Sayfa1!A1: A500" End Sub Private Sub altr_Click() ListBox1.Clear ListBox2.Clear Dim i, r, y As Integer Dim s As String Dim q As Date q = ilk For r = 4 To WorksheetFunction.CountA(Range("C4:C62")) + 1 If Cells(r, 3).Value = q Then ListBox1.AddItem Cells(r, 6).Value ListBox2.AddItem Cells(r, 7).Value TotalCredit = TotalCredit + Cells(r, 7).Value End If Next r ListBox1.AddItem "TOPLAM :" & TotalCredit & " K KALACAK" ListBox2.AddItem "TOPLAM :" & TotalCredit & " K KALACAK" End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim Pos% Dim Neu$ Neu = InputBox("Neuen Eintrag eingeben:") If Neu = "" Then Exit Sub With ListBox1 Pos = .ListIndex .RemoveItem (.ListIndex) .AddItem Neu, Pos End With End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim addy As String addy = ListBox1.Text Unload Me Application.Goto Range(addy) End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim i As Long, Pos As Long Dim strSheet As String, strAddy As String With Me.ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) Then Pos = i: Exit For Next i If i = .ListCount Then Exit Sub strSheet = Left(.List(i), InStr(1, .List(i), "!") - 1) strAddy = Right(.List(i), Len(.List(i)) - Len(strSheet) - 1) Sheets(strSheet).Activate Range(strAddy).Activate End With Unload Me End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) 'Check for range addresses If ListBox1.ListCount = 0 Then Exit Sub 'GoTo doubled clicked address Application.Goto Range(ListBox1.Text), True End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Application.Goto Range(ListBox1.List(ListBox1.ListIndex)) End Sub Private Sub ListBox1_Click() 'Check for range addresses If ListBox1.ListCount = 0 Then Exit Sub 'GoTo doubled clicked address Range(ListBox1.Text).Parent.Activate Application.Goto Range(ListBox1.Text), True End Sub Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Application.Goto Range(ListBox1).EntireRow Unload Me End Sub Format(ListBox1.Column(8), "dd.mm.yyyy") On satrlk bir listboxta tarihlerin ilk stunda olduunu varsayarak yazyorum. For i = 0 To 9 ListBox1.List(i, 0) = Format(ListBox1.List(i, 0), "dd.mm.yyyy") Next i 'Yukardaki kodda i satr numarasn, 0 stun numarasn gstermektedir. Private Sub CommandButton8_Click() toplam = 0 For i = 1 To ListBox1.ListCount toplam = toplam + Val(ListBox1.List(i - 1)) Next i TextBox1 = toplam End Sub sat1=listbox1.listcount sut1=listbox1.columncount sonsat1=[i65536].end(3).row+1 range(cells(sonsat1,"i"),cells(sat1+sonsat1,sut1+9))=listbox1.list sat2=listbox2.listcount sut2=listbox2.columncount sonsat2=[b65536].end(3).row+1 range(cells(sonsat2,"b"),cells(sat2+sonsat2,sut2+2))=listbox2.list Private Sub CommandButton1_Click() Set s1 = Sheets("sayfa2") sat = ListBox1.ListCount sut = ListBox1.ColumnCount s1.Range(s1.Cells(1, 1), s1.Cells(sat, sut)) = ListBox1.List End Sub Private Sub ListBox1_Change() TextBox1 = ListBox1 End Sub ' Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then ListBox1.SetFocus End Sub
Private Sub CommandButton1_Click() z=0 For i = 1 To ListBox1.ListCount z = z + Val(ListBox1.List(i - 1)) Next i MsgBox z End Sub Private Sub CommandButton1_Click() Dim xlApp As Object Set xlApp = CreateObject("Excel.Application") xlApp.Visible = False Set NewWB = xlApp.Workbooks.Add Set MySh = NewWB.Worksheets(1) nRow = ListBox1.ListCount nColumn = ListBox1.ColumnCount MySh.Range("A1", Cells(nRow, nColumn).Address) = ListBox1.List WBname = "C:\" & (TextBox3.Text) & ".xls" NewWB.SaveAs WBname MsgBox WBname & " Adnda Bir Excel Kitab oluturulmutur...", _ vbInformation, "AKD.YAZILIM" xlApp.Quit Set xlApp = Nothing Set MySh = Nothing Set NewWB = Nothing End Sub Private Sub ListBox1_Click() Userform1.ComboBox1.Value = Userform2.ListBox1.Column(0) End Sub Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "#,##0.00") End Sub If MsgBox("Setiginiz Veri Silinecek,Eminmisiniz?",vbYesNo) = vbYes Then sil = Sheets("DATA").Columns(1).Find(ListBox1.Value).Row Sheets("DATA").Rows(sil).Delete End If Private Sub CommandButton1_Click() On Error GoTo yanlis ListBox1.AddItem (Columns(2).Find(What:=TextBox1, LookAt:=xlWhole)) yanlis: If Err Then MsgBox "Bulamadm!" End Sub Private Sub CommandButton1_Click() Dim xlApp As Object Set xlApp = CreateObject("Excel.Application") xlApp.Visible = False Set NewWB = xlApp.Workbooks.Add Set MySh = NewWB.Worksheets(1) nRow = ListBox1.ListCount nColumn = ListBox1.ColumnCount MySh.Range("A1", Cells(nRow, nColumn).Address) = ListBox1.List WBname = "C:\" & (TextBox3.Text) & ".xls" NewWB.SaveAs WBname MsgBox WBname & " Adnda Bir Excel Kitab oluturulmutur...", _ vbInformation, "AKD.YAZILIM" xlApp.Quit Set xlApp = Nothing Set MySh = Nothing Set NewWB = Nothing End Sub Bunun iin benim bildiim kadaryla 3 yol mevcut, bunlar; 1-Makro iinde worksheetfunction.CountA kodu ile 2-Cells(65536, 1).End(xlUp).Row kodu ile 3-BA _DE _DOLU_SAY(...) formln bir hcreye yazarak burdan aldnz veri ile
Private Sub CommandButton1_Click() ListView1.View = lvwReport say = ListView1.ListItems.Count With ListView1 .ListItems.Add , , TextBox1 .ListItems(say + 1).SubItems(1) = TextBox2 End With End Sub Private Sub UserForm_Initialize() Dim i As Integer Me.Caption = "uluc" TextBox1.Value = "" TextBox2.Value = "" Dim a ListView1.View = lvwReport With ListView1.ColumnHeaders .Add , , "Sra No", 55, 0 .Add , , "Ad Soyad", 75, 2 End With End Sub Private Sub CommandButton1_Click() On Error Resume Next With ListView1 If ListView1.FindItem(Text1.Text) <> Text1.Text Then .ListItems.Add , , Text1.Text End With End Sub Private Sub UserForm_Activate() ListView1.ListItems.Add , , "1" ListView1.ListItems.Add , , "2" ListView1.ListItems.Add , , "3" ListView1.ListItems.Add , , "4" ListView1.ListItems.Add , , "5" End Sub
Dim x As Integer Select Case ColumnHeader.Index - 1 Case 2, 3 ListView1.Sorted = False ListView1.SortKey = ColumnHeader.Index - 1 For i = 1 To ListView1.ListItems.Count ListView1.ListItems(i).ListSubItems(ColumnHeader.I ndex - 1).Text = ListView1.ListItems(i).ListSubItems(ColumnHeader.I ndex - 1).Text Next i If ListView1.SortOrder = lvwAscending Then ListView1.SortOrder = lvwDescending Else ListView1.SortOrder = lvwAscending End If ListView1.Sorted = True For i = 1 To ListView1.ListItems.Count ListView1.ListItems(i).ListSubItems(ColumnHeader.I ndex - 1).Text = ListView1.ListItems(i).ListSubItems(ColumnHeader.I ndex - 1).Text Next i Case 1 x = ColumnHeader.Index - 1 ListView1.Sorted = False ListView1.SortKey = x If ColumnHeader.Index = 1 Then For i = 1 To ListView1.ListItems.Count ListView1.ListItems(i).Tag = ListView1.ListItems(i).Text If CDbl(ListView1.ListItems(i).Text) >= 0 Then ListView1.ListItems(i).Text = CDbl(ListView1.ListItems(i).Text) Else ListView1.ListItems(i).Text = "&" & CDbl(ListView1.ListItems(i).Text) End If Next i If ListView1.SortOrder = lvwAscending Then ListView1.SortOrder = lvwDescending Else ListView1.SortOrder = lvwAscending End If ListView1.Sorted = True For i = 1 To ListView1.ListItems.Count ListView1.ListItems(i).Text = ListView1.ListItems(i).Tag Next i Else For i = 1 To ListView1.ListItems.Count ListView1.ListItems(i).ListSubItems(x).Tag = ListView1.ListItems(i).ListSubItems(x).Text If ListView1.ListItems(i).ListSubItems(x).Text <> "" Then ListView1.ListItems(i).ListSubItems(x).Text = ListView1.ListItems(i).ListSubItems(x).Text Else ListView1.ListItems(i).ListSubItems(x).Text = "&" & ListView1.ListItems(i).ListSubItems(x).Text End If Next i If ListView1.SortOrder = lvwAscending Then ListView1.SortOrder = lvwDescending Else ListView1.SortOrder = lvwAscending End If ListView1.Sorted = True For i = 1 To ListView1.ListItems.Count ListView1.ListItems(i).ListSubItems(x).Text = _ ListView1.ListItems(i).ListSubItems(x).Tag Next i End If Case Else ListView1.Sorted = False ListView1.SortKey = ColumnHeader.Index - 1
Diyelimki Excelde hazrladmz bir isim listemiz var ve biz bunlar A1 hcresi ile A9000 hcreleri arasna kaydediyoruz. Kaytl (dolu) hcre saysn program Sub DoluKayitSayisi() Sayi=WorksheetFunction.CountA(Range("A1:A9000")) 'Eer mesajla almak isterseniz u koduda ekleyin MsgBox Sayi End Sub Sub imlecidondur() Application.EnableEvents = False Range("a1").Value = "Akn" Application.EnableEvents = True End Sub Sub sil() For i = Cells(65536, 1).End(xlUp).Row To 2 Step -1 If Trim(Cells(i, 1)) <> "SARF F" And Trim(Cells(i, 1)) <> "TOPTAN SATI RSALYES" Then Rows(i & ":" & i).Delete Shift:=xlUp End If Next i End Test() Sub Sub Dim NoB As Long Dim ii As Long Dim i As Integer Dim j As Integer Dim MyRng As Range Application.ScreenUpdating = False For i = 1 To Worksheets.Count Sheets(i).Select ii = 0 j=0 NoB = Cells(65536, 2).End(xlUp).Row For ii = NoB To 5 Step -1 If Trim(Cells(ii, 2)) = Trim("Net Miktar") Then Rows(ii + 1).Select For j = 1 To 6 Selection.Insert Shift:=xlDown Next End If Next For ii = 5 To Cells(65536, 2).End(xlUp).Row If Trim(Cells(ii, 2)) = Trim("Smm Sat") Then Rows(ii).Delete Next Next Application.ScreenUpdating = True End EmailSheet() Sub Sub Dim OutlookApp As Object, OutlookMsg As Object Dim FSO As Object, BodyText As Object Dim MyRange As Range, TempFile As String 'On Error Resume Next Set MyRange = ActiveSheet.UsedRange If MyRange Is Nothing Then Exit Sub Set FSO = CreateObject("Scripting.FilesystemObject") TempFile = "C:\TempHTML.htm" ActiveWorkbook.PublishObjects.Add _ (4, TempFile, MyRange.Parent.Name, MyRange.Address, 0, "", "").Publish True Set OutlookApp = CreateObject("Outlook.Application") Set OutlookMsg = OutlookApp.CreateItem(0) Set BodyText = FSO.OpenTextFile(TempFile, 1) OutlookMsg.HTMLBody = BodyText.ReadAll OutlookMsg.Subject = "Merhaba !" OutlookMsg.To = "excalub@yahoo.com" 'OutlookMsg.Display OutlookMsg.Send 'Kill TempFile Set BodyText = Nothing Set OutlookMsg = Nothing Set OutlookApp = Nothing Set FSO = Nothing End Sub
for a=1 to 50 Sheets("Ana Liste").Select Rows("1:1").Select Selection.Insert Shift:=xlDown Sheets("Sayfa" & a).Select Range("C3").Select Selection.Copy next a Sub gosterme() Application.ScreenUpdating = False kodlarnz... Application.ScreenUpdating = True End Sub Sub imlecidondur() Application.EnableEvents = False Range("a1").Value = "Merhaba" Application.EnableEvents = True End Sub Sub aralkl_calstr() Application.OnTime Now + TimeValue("00:05:00"), "makro1" End Sub Sub makro1() msgbox("transfer balyor") '...sizin kodlarnz '....... call aralkl_calstr End sub TavanaYuvarla iin MsgBox WorksheetFunction.Ceiling(25.32, 1) Tamsay iin MsgBox Int(25.32) Aadaki ekilde de kullanmanz mmkndr. ActiveCell = "=INT(10.65)" ActiveCell= "=CEILING(25.32,1)" Private Sub CommandButton6_Click() sor = MsgBox("SLMEK STEDNZDEN EMNMSNZ...?", vbYesNo) If sor = vbNo Then Exit Sub Application.Wait Now + TimeValue("00:00:02") / 1.5 CommandButton6.Caption = "SL" 'sat = ListBox1.ListIndex + 2 'Range("B" & sat & ":I" & sat).Delete '[a65536].End(2).Delete Shift:=xlUp Sheets("STOKLAR").Rows(Sheets("STOKLAR").Columns(1).Find(ListBox1.Value).Row).Delete MsgBox "SELEN KAYIT SLNMTR" End Sub Sub Macro1() Msgbox("Bu Macro1 dir") Call Macro2 ' Macro2 altrlr End Sub aadaki makro sadece hcredeki deerleri siler. Sub Makro1() x = WorksheetFunction.CountA(Range("A1:A65000")) For a = 1 To x b = Cells(a, 1).Value For c = a + 1 To x d = Cells(c, 1).Value If b = d Then Cells(c, 1).ClearContents End If Next c Next a End Sub
Aadaki kodu deneyin. Yazdrlacak sayfa saysn verir. Sub sayfasay() Application.ScreenUpdating = False ActiveWindow.View = 2 say = ActiveSheet.HPageBreaks.Count + 1 ActiveWindow.View = 1 MsgBox say End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 And Target.Row = 1 Then X = [A1] & [A2] & [A3] & [A4] & [A5] [A1] = X End If End Sub alma sayfasnn kod blmne girilecek kodlar: Kod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 And Target.Row = 1 Then X = [A1] & [A2] & [A3] & [A4] & [A5] [A1] = X End If End Sub Workbooks.Open Filename:=activeworkbook.path & "\satis.xls" Makro ile Import iin; Sub import_form() Application.VBE.ActiveVBProject.VBComponents.Import ("C:\Documents and Settings\bulent\Desktop\UserForm1.frm") End Sub 'C:\Documents and Settings\bulent\Desktop\UserForm1.frm - dosya yolunu kendinize uyarlayn Application:Undo VBA da thisworkbook ksmna Kod: Private Sub Workbook_SheetActivate(ByVal Sh As Object) If LCase(Sh.Name) = "sheet1" Or LCase(Sh.Name) = "sheet2" Then If InputBox("ifreyi girin") <> "sifre" Then Sh.Visible = False End If End Sub Range("A1:D1").Merge Private Sub Worksheet_Activate() Set Sh1 = Sheets("Sevk") Set Sh2 = Sheets("Anasayfa") If Sh2.Range("E8").FormulaR1C1 <> "" Then Sh1.[C3] = Sh2.[Z2] 'Kurum Ad' Sh1.[D11] = Sh2.[Z3] 'Kurum Amiri' Sh1.[D12] = Sh2.[Z4] 'Kurum Amirinin Unvan' Sh1.[C5] = Sh2.[Z5] 'Memurun Ad Soyad' Sh1.[C7] = Sh2.[Z6] 'Memurun Unvan' Sh1.[E5] = Sh2.[Z7] 'Hastann Ad Soyad' Sh1.[C15] = Sh2.[Z8] 'Salk Kurumu' Sh1.[F11] = Sh2.[Z9] 'Tarih' Sh1.[C9] = Sh2.[Z10] 'Adres' Sh1.[F3] = Sh2.[Z11] 'T.C. Kimlik No' Sh1.[E7] = Sh2.[Z12] 'Sicil No' Sh1.[F7] = Sh2.[Z13] 'Derece/Kadro' Sh1.[F13] = Sh2.[Z14] 'Say' End If Set Sh1 = Nothing Set Sh2 = Nothing End Sub Sub Sayfa_Sil() Dim sil As String Application.DisplayAlerts = False sil = ActiveSheet.Name Sheets.Add Sheets(sil).Select ActiveWindow.SelectedSheets.Delete Application.DisplayAlerts = True End Sub
Sub DatumVBA() MsgBox CLng(CDate("29.11.2005")) - CLng(CDate("05.04.1978")) End Sub kodlarn bana If Date>=Cdate("23.02.2006") then Exit sub 'satrn ilave ediniz Sub ErrHand() On Error GoTo ErrorHandler n = 10 Selection.SpecialCells(xlConstants).Select x = Selection.Areas MsgBox (x) Exit Sub ErrorHandler: Select Case Err.Number Case 104 MsgBox ("104") Exit Sub Case Else MsgBox "Runtime Error: " & Err.Number & vbNewLine & Err.Description Stop Resume End Select End Sub
yani marifet formda deil kodlarda. Anlalan hala anlatm zorluu ekiyorum. bu modul tek kriterli olan tm filtreler iin kullanlabilir. kodlar aynen yle visual basic kodu: -------------------------------------------------------------------------------Global adres As String 'excel.web.tr'den 'Bu Makro genel filtre amaldr. '****************************************************** ' AIKLAMA '******************************************************
// rnekler
'KaynakSayfa : Filrelemenin yaplaca sayfa // "stok" 'FiltreBal : Filtrelenmek istenen tablonun bal // "A1:C1" 'FiltreAlan : Filtrenin uygulanaca alan // 3 "yani c1 hcresi" 'lt : Byklk,kklk...(>,<,=,<>..) // "=" 'Kriter : Filtrelenen deer // Combobox1.text 'AdresAlan : Filtre sonucu alnmak istenen verilerin alan // "A1:B1" 'HedefSayfa : Filtrelenen verilerin kopyalanaca sayfa // "stok" 'HedefAlan : Filtrelenen verilerin kopyalanaca alan // "H1:I1" 'NOT:Hata denetim ilemleri henz yaplmad Sub AdresAl(KaynakSayfa, FiltreBal, lt, Kriter, AdresAlan, HedefSayfa, HedefAlan As String, FiltreAlan As Integer) Application.ScreenUpdating = False Sheets(HedefSayfa).Select Range(Range(HedefAlan), Range(HedefAlan).End(xlDown)).Clear Sheets(KaynakSayfa).Select Range(FiltreBal).AutoFilter Range(FiltreBal).AutoFilter Field:=FiltreAlan, Criteria1:=lt & Kriter, Operator:=xlAnd Range(Range(AdresAlan), Range(AdresAlan).End(xlDown)).Copy Sheets(HedefSayfa).Select Range(HedefAlan).Select ActiveSheet.Paste Sheets(KaynakSayfa).AutoFilterMode = False Application.CutCopyMode = False adres = HedefSayfa & "!" & Range(Range(HedefAlan), Range(HedefAlan).End(xlDown)).Address End Sub --------------------------------------------------------------------------------
kullanmak iin rnek kodlar: visual basic kodu: -------------------------------------------------------------------------------Private Sub ComboBox1_Change() Call AdresAl("stok", "A1:C1", "=", ComboBox1.Text, "A1:B1", "stok", "H1:I1", 3) ListBox1.RowSource = adres End Sub --------------------------------------------------------------------------------
visual basic kodu: -------------------------------------------------------------------------------Private Sub ComboBox2_Change() Call AdresAl("firma", "A1:C1", "=", ComboBox2.Text, "A1:B1", "firma", "H1:I1", 3) ListBox2.RowSource = adres End Sub
aadaki rnek iinizi grr sanrm; Makroyu altrdn sayfada ilem yapar. Kod: Sub arabul() ara = Application.InputBox(prompt:="Aranacak Veri?", Type:=3) Range("A3:A341").Select Selection.Find(What:=ara, After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate satir = ActiveCell.Row Range(Cells(satir, 2), Cells(satir, 8)).Select Selection.Copy Sheets("Sayfa1").Select Range("A2").Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=True End Sub Private Sub Tamam_Click() Application.StatusBar = "Hesaplama Yaplyor" Tamam.Enabled = False 'Hesaplama ile ilgili kodlar '.......... '.......... 'Hesaplama ile ilgili kodlar Application.StatusBar = "Hesaplama Tamamland" Tamam.Enabled = True End Sub Dim rng As Range Set rng = Range("A2:b4") 'Excel macro test code 'Note iRow = Start Row of Range and iRow2= Ending Row of Range 'Set rng = oXLApp.Range(Cells(iRow, 1), oXLApp.Cells(iRow2,1).End(xlToRight)) grid rng End Sub Sub grid(rng) rng.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 With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End Sub
Bu kodlar henz bitirmediim bir alma dosyamda denedim.Daha sonra iptal etmek iin ara ubuklar zerinde sa tklayp modlden auto_open ve aut Yardmc olursanz sevinirim. Teekkrler. Kod: Sub auto_open() Application.CommandBars("Worksheet Menu Bar").Controls(6).Controls("Makro").Enabled = False Application.OnKey "%{F11}", "mesaj" End Sub Sub auto_close() Application.CommandBars("Worksheet Menu Bar").Controls(6).Controls("Makro").Enabled = True Application.OnKey "%{F11}" End Sub Sub mesaj() MsgBox "Makrolar gizli!!" End Sub '************** Kod: Sub Panzehir() Application.CommandBars("Worksheet Menu Bar").Reset Application.OnKey "%{F11}" End Sub
Eer kodlar yerletirmek iin VBE ksmna ulaamyorsanz, aadaki dosyay indirip, an. Bu arada ufak bir hatrlatma;
ngilizce Office ykl bir bilgisayarda kodlarnz hata verecektir nk, menlere "etiket - balk" ile referans vermiiniz. Bunun yerine mennn ID zellii
Aadaki resimde grld gibi, "Makro" veya "Makrolar" mens/dialog kutusu veya kod sayfas yani VBE (Visual Basic Editor)'n kendisi Excel'in eitl Bu durumda benim nerim aadaki gibidir; Kod: Sub Auto_Open() Application.CommandBars.FindControl(ID:=30017).Enabled = False Application.CommandBars.FindControl(ID:=186).Enabled = False Application.CommandBars.FindControl(ID:=1561).Enabled = False Application.CommandBars("Ply").FindControl(ID:=1561).Enabled = False Application.CommandBars("Document").FindControl(ID:=1561).Enabled = False Application.CommandBars("Visual Basic").Enabled = False Application.CommandBars("Control ToolBox").Enabled = False Application.OnKey "%{F11}", "Mesaj" Application.OnKey "%{F8}", "Mesaj" End Sub ' Sub Auto_Close() Application.CommandBars.FindControl(ID:=30017).Enabled = True Application.CommandBars.FindControl(ID:=186).Enabled = True Application.CommandBars.FindControl(ID:=1561).Enabled = True Application.CommandBars("Ply").FindControl(ID:=1561).Enabled = True Application.CommandBars("Document").FindControl(ID:=1561).Enabled = True Application.CommandBars("Visual Basic").Enabled = True Application.CommandBars("Control ToolBox").Enabled = True Application.OnKey "%{F11}" Application.OnKey "%{F8}" End Sub ' Sub Mesaj() MsgBox "Makrolar gizli!!" End Sub
Dip Not: Eer ama kullancdan makrolar gizlemekse; makrolarn olduu moduln en stne aadaki satr yerletirdiinizde, kullanc bahsettiiniz menler aktif
Sub auto_open() Application.CommandBars("Worksheet Menu Bar"). _ Controls(6).Controls("Makro").Enabled = False Application.OnKey "%{F11}", "mesaj" End Sub Sub auto_close() Application.CommandBars("Worksheet Menu Bar"). _ Controls(6).Controls("Makro").Enabled = True Application.OnKey "%{F11}" End Sub Sub mesaj() MsgBox "Makrolar gizli!" End Sub Dim RunWhen As Double Const RunWhat = "Info" Sub Auto_Open() StartTimer End Sub Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, 5) Application.OnTime earliesttime:=RunWhen, procedure:=RunWhat, schedule:=True End Sub Sub Info() ' Aadaki satrda yer alan MsgBox fonksiyonu yerine, ' altrlmasn istediiniz baka bir makronun adn yazarak ' o makronun altrlmasn salayabilirsiniz. MsgBox "Dikkat, sayfayi gncelleyin !" StartTimer End Sub Sub StopTimer() On Error Resume Next Application.OnTime earliesttime:=RunWhen, procedure:=RunWhat, schedule:=False End Sub Sub Auto_Close() StopTimer End Sub Sub Auto_Open() If ActiveSheet.Name = "Sayfa1" Then Range("B3") = "Evren1" 'Buraya Call::::::. makro ismi de yazlabilir End If End Sub Sub z() If ActiveSheet.Name = "Sayfa1" Then Range("B4") = "Evren2" 'Buraya Call::::::. makro ismi de yazlabilir End If End Sub Sub auto_open() Application.CommandBars("Worksheet Menu Bar").Controls(6).Controls("Makro").Enabled = False Application.OnKey "%{F11}", "mesaj" End Sub Sub auto_close() Application.CommandBars("Worksheet Menu Bar").Controls(6).Controls("Makro").Enabled = True Application.OnKey "%{F11}" End Sub Sub mesaj() MsgBox "Makrolar gizli!!" End Sub
kodlar kopyala alt+F11-insert-module 'den sonra yaptrarak kullanabilirsiniz...Kolay gelsin Kod: Sub auto_open() Application.CommandBars("Worksheet Menu Bar").Controls(6).Controls("Makro").Enabled = False Application.OnKey "%{F11}", "mesaj" End Sub Sub auto_close() Application.CommandBars("Worksheet Menu Bar").Controls(6).Controls("Makro").Enabled = True Application.OnKey "%{F11}" End Sub Sub mesaj() MsgBox "Makrolar gizli!!" End Sub A1 hcresine 1000 yazp aadaki kodu altrn. Kod: Sub sfr() Do Until [a1] = 0 [a1] = [a1] - 1 Loop End Sub Aadakileri szkonusu dosyada yeni bir module yaptrdktan sonra kaydedin ve kapatn. Daha sonra dosyay tekrar an. Kod: Dim RunWhen As Double Const RunWhat = "Info" ' Sub Auto_Open() StartTimer End Sub ' Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, 5) Application.OnTime earliesttime:=RunWhen, procedure:=RunWhat, schedule:=True End Sub ' Sub Info() ' Aadaki satrda yer alan MsgBox fonksiyonu yerine, ' altrlmasn istediiniz baka bir makronun adn yazarak ' o makronun altrlmasn salayabilirsiniz. MsgBox "Dikkat, sayfayi gncelleyin !" StartTimer End Sub ' Sub StopTimer() On Error Resume Next Application.OnTime earliesttime:=RunWhen, procedure:=RunWhat, schedule:=False End Sub ' Sub Auto_Close() StopTimer End Sub Yaptrdnz ilemlerin bana Thisworkbook ekleyerek yapabilirsiniz. ThisWorkbook.Sheets(1)....
Private Declare Function OpenProcess Lib "kernel32" ( _ ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" ( _ ByVal lnghProcess As Long, _ lpExitCode As Long) As Long Private Const PROCESS_ALL_ACCESS = &H1F0FFF Public Function ShlProc_IsRunning(ShellReturnValue As Long) As Boolean Dim lnghProcess As Long Dim lExitCode As Long Dim lRet As Long ' Get the process handle lnghProcess = OpenProcess(PROCESS_ALL_ACCESS, 0&, ShellReturnValue) If lnghProcess <> 0 Then ' The GetExitCodeProcess function retrieves the ' termination status of the specified process. GetExitCodeProcess lnghProcess, lExitCode If lExitCode <> 0 Then ' Process still ALIVE! ShlProc_IsRunning = True Else ' YES...finished @ last ShlProc_IsRunning = False End If End If End Function Sub ShellTester() Dim RetVal As Long On Error Resume Next RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) On Error GoTo 0 If RetVal = 0 Then MsgBox "NoGo!" & vbCr & "Check your Path": End ' Ok, lets loop until the App process is terminated! Do While ShlProc_IsRunning(RetVal) = True DoEvents Loop MsgBox "Program finished!" & vbCr & "Lets continue on now!" End Sub
Private Declare Function OpenProcess Lib "kernel32" ( _ ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Private Declare Function WaitForSingleObject Lib "kernel32" ( _ ByVal hHandle As Long, _ ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" ( _ ByVal hProcess As Long, _ lpExitCode As Long) As Long Private Const SYNCHRONIZE = &H100000 Private Const INFINITE = &HFFFF ' OR -1& ' INFINITE, the functions time-out interval never elapses. Private Const STILL_ACTIVE = &H103 Public Function ShellAndWait(ByVal BatFile As String) Dim PID As Long Dim hProcess As Long Dim nRet As Long On Error Resume Next PID = Shell(BatFile, vbMinimizedNoFocus) If Err Then MsgBox "Could NOT exercute:= " & BatFile End End If On Error GoTo 0 hProcess = OpenProcess(SYNCHRONIZE, False, PID) nRet = WaitForSingleObject(hProcess, INFINITE) Do GetExitCodeProcess hProcess, nRet DoEvents Loop While nRet = STILL_ACTIVE CloseHandle hProcess End Function Sub OpenFileAndWait() Dim sApp As String sApp = "C:\windows\calc.exe" ShellAndWait sApp MsgBox "Finished running task!" End Sub Sub butonekle() ActiveSheet.Buttons.Add(10, 5, 50, 20).Select Selection.OnAction = "Makro1" End Sub Sub sayfa_send() ActiveSheet.Select ActiveSheet.Copy ActiveWorkbook.SaveAs Filename:="c:\Part of " & ThisWorkbook.Name & " " & strdate ActiveSheet.Cells.Copy ActiveSheet.Cells.PasteSpecial xlPasteValues ActiveSheet.Cells.ClearComments ActiveSheet.Buttons.Delete ActiveSheet.Range(Columns(71), Columns(256)).Delete ActiveWorkbook.Save ActiveWorkbook.SendMail "serdarguyuk@dianatravel.com.tr", "CAR HRE" fname = ActiveWorkbook.FullName ActiveWorkbook.Close Kill fname End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target = "AHMET" Then Run "Module1.Makro3" End If End Sub
bir makronun iinden baka bir makroyu armak iin Application.Run "kitap1.xls'!Sayfa1.baskamakro" gibi bir komut kullanabilirsiniz: run ("denememakrosu") eklindede olabilir: Sub MostRecent() Dim J As Integer For J = 1 To Application.RecentFiles.Count Cells(J, 1) = Application.RecentFiles(J).Name Next J End Sub
' Call DShortCut(ThisWorkbook.FullName) 'End Sub 'Modle Sub Dektop_Icon_anlegen() Call DShortCut(ThisWorkbook.FullName) End Sub Function DShortCut(strFullFilePathName As String) As Long ' Ursprngliche Version von Myrna Larson in VBS ' Fr VBA umgebaut von klausimausi64 ' Uses the Windows Scripting Host to create a .lnk ' shortcut on the user's desktop. ' Parameters: strFullFilePathName - String - The full name of ' the file to which the shortcut will point. ' Returns: 1 = success, 0 = target doesn't exist, -1 = other error ' Example: Call DShortCut ("C:\Program Files\Microsoft Office 97\Office\Examples\SAMPLES.XLS") Dim WSHShell As Object Dim WSHShortcut As Object Dim strDesktopPath As String Dim strFileName As String Dim strPath As String On Error GoTo ErrHandler ' Create a Windows Shell Object Set WSHShell = CreateObject("wscript.Shell") ' Get the file's name and path... strFileName = Dir(strFullFilePathName) strPath = Left(strFullFilePathName, Len(strFullFilePathName) - Len(strFileName)) ' Make sure file exists If Not Len(strFileName) = 0 Then ' Read desktop path using WshSpecialFolders object strDesktopPath = WSHShell.SpecialFolders.Item("Desktop") ' Create a shortcut object on the desktop Set WSHShortcut = WSHShell.CreateShortcut(strDesktopPath & "\" & strFileName & ".lnk") ' Set shortcut object properties and save it With WSHShortcut .TargetPath = WSHShell.ExpandEnvironmentStrings(strFullFilePathName) .WorkingDirectory = WSHShell.ExpandEnvironmentStrings(strPath) .WindowStyle = 4 .IconLocation = WSHShell.ExpandEnvironmentStrings(Application.Path & "\excel.exe , 0") .Save End With DShortCut = 1 Else DShortCut = 0 End If Continue: Set WSHShell = Nothing Exit Function ErrHandler: DShortCut = -1 Resume Continue End Function
Call DShortCut(ThisWorkbook.FullName) End Sub Function DShortCut(strFullFilePathName As String) As Long Dim WSHShell As Object Dim WSHShortcut As Object Dim strDesktopPath As String Dim strFileName As String Dim strPath As String On Error GoTo ErrHandler ' Create a Windows Shell Object Set WSHShell = CreateObject("wscript.Shell") ' Get the file's name and path... strFileName = Dir(strFullFilePathName) strPath = Left(strFullFilePathName, Len(strFullFilePathName) - Len(strFileName)) ' Make sure file exists If Not Len(strFileName) = 0 Then ' Read desktop path using WshSpecialFolders object strDesktopPath = WSHShell.SpecialFolders.Item("Desktop") ' Create a shortcut object on the desktop Set WSHShortcut = WSHShell.CreateShortcut(strDesktopPath & "\" & strFileName & ".lnk") ' Set shortcut object properties and save it With WSHShortcut .TargetPath = WSHShell.ExpandEnvironmentStrings(strFullFilePathName) .WorkingDirectory = WSHShell.ExpandEnvironmentStrings(strPath) .WindowStyle = 4 .IconLocation = WSHShell.ExpandEnvironmentStrings(Application.Path & "\excel.exe , 0") .Save End With DShortCut = 1 Else DShortCut = 0 End If Continue: Set WSHShell = Nothing Exit Function ErrHandler: DShortCut = -1 Resume Continue End Function
(ByVal hwnd As Long, ByVal nFolder As Long, _ ppidl As Long) As Long Declare Function SHGetPathFromIDList Lib "Shell32" _ (ByVal Pidl As Long, _ ByVal pszPath As String) As Long Declare Function SetWindowPos Lib "User32" _ (ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal X As Long, ByVal Y As Long, _ ByVal cx As Long, ByVal cy As Long, _ ByVal uFlags As Long) As Long Declare Function SetForegroundWindow Lib "User32" _ (ByVal hwnd As Long) As Long Declare Function GetForegroundWindow Lib "User32" () As Long Function ShortCut(Target As String, _ Optional Target_Type As Long) As Boolean Dim hwnd As Long Dim Pidl As Long Dim Bureau As String If Dir(Target & IIf(Target_Type = vbDirectory, "\", ""), _ Target_Type) = "" Then Exit Function SHGetSpecialFolderLocation 0, 0, Pidl Bureau = Space(260) SHGetPathFromIDList Pidl, Bureau Bureau = Left(Bureau, InStr(1, Bureau, vbNullChar) - 1) hwnd = GetForegroundWindow SetWindowPos hwnd, -1, 0, 0, 0, 0, 3 Shell "RunDLL32 AppWiz.Cpl,NewLinkHere " & Bureau & "\" SendKeys """" & Target & """~~", True SetForegroundWindow hwnd ShortCut = True End Function Sub Test() ' "C:\Temp" dizininde bir ksayol oluturur MsgBox IIf(ShortCut("C:\Temp", vbDirectory), _ "Shortcut created", "Can't find the directory") ' "C:\Temp\Zaza.xls" dosyas iin ksayol oluturur MsgBox IIf(ShortCut("C:\Temp\Zaza.xls"), _ "Shortcut created", "Can't find the file") End Sub Option Explicit Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Sub masaustunu_goster() keybd_event &H5B, 0, 0, 0 keybd_event 77, 0, 0, 0 keybd_event &H5B, 0, &H2, 0 keybd_event 77, 0, &H2, 0 End Sub Private sub userform activate Dim control For each control In form1.controls If TypeOf control Is MaskEdBox Then control.Mask= ##/##/#### Next End sub
Sub menkomutlara() Dim Ctrl As Office.CommandBarControl For Each Ctrl In Application.CommandBars.FindControls(Id:=847) Ctrl.Enabled = True 'True menleri aktif yapar Next Ctrl For Each Ctrl In Application.CommandBars.FindControls(Id:=889) Ctrl.Enabled = True 'True menleri aktif yapar Next Ctrl End Sub Sub menkomutlariptal() Dim Ctrl As Office.CommandBarControl For Each Ctrl In Application.CommandBars.FindControls(Id:=847) Ctrl.Enabled = False 'True menleri aktif yapar Next Ctrl For Each Ctrl In Application.CommandBars.FindControls(Id:=889) Ctrl.Enabled = False 'True menleri aktif yapar Next Ctrl End Sub With CommandBars(1).Controls.Add(msoControlPopup) .Caption = "YeniMen" With .Controls.Add(msoControlButton) .Caption = "Yeni Alt Men 1" .FaceId = 210 .BeginGroup = True .OnAction = "Goster" End With With .Controls.Add(msoControlButton) .Caption = "Yeni Alt Men 2" .FaceId = 211 .BeginGroup = True .OnAction = "Goster" End With End With End Sub Sub YeniMenuKaldir() CommandBars(1).Controls("YeniMen").Delete End Sub Sub Goster() Dim Msg, Style, Title Msg = "Yeni men eklediniz" Style = vbYes Title = "YeniMen" Response = MsgBox(Msg, Style, Title) End Sub 'Not: stenen yere koymak iin (mesela Biim mensnden nce koymak iin) With CommandBars(1).Controls.Add(msoControlPopup) satrn With CommandBars(1).Controls.Add(msoControlPopup, before:= 5) ile deitirin. Sayfa alrken en stte bulunan yazl (Dosya, Dzen,..) Men ubuunu gizler, Dosya kapatlrken de tekrar gsterir. 'ThisWorkbook modlne kopyala Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.CommandBars("Worksheet Menu Bar").Enabled = True End Sub Private Sub Workbook_Open() Application.CommandBars("Worksheet Menu Bar").Enabled = False End Sub 'Standard modle kopyala Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.CommandBars("Worksheet Menu Bar").Enabled = True End Sub Private Sub Workbook_Open() Application.CommandBars("Worksheet Menu Bar").Enabled = False End Sub
Sub Menu() MenuBars.Add "MyMenu" MenuBars("MyMenu").Activate End Sub Sub MenuBack() MenuBars("Worksheet").Activate MenuBars("MyMenu").Delete End Sub Sub Dme1_Tklat() Application.CommandBars.ActiveMenuBar.Enabled = True Application.DisplayFullScreen = True Application.CommandBars("Full Screen").Enabled = False End Sub
.OnAction = "msntar" .Style = msoButtonIconAndCaption .FaceId = 115 .State = msoButtonUp End With 'Dosyalarn Teknik Bakm With AnaAltMen.Controls.Add(msoControlButton, 1, , , True) .Caption = "Dosyalarn Teknik Bakm" .OnAction = "tekbak" .Style = msoButtonIconAndCaption .FaceId = 116 .State = msoButtonUp End With '.................................................................................................... 'Alt Men 9 Set AnaAltMen = AnaMen.Controls.Add(msoControlPopup, 1, , , True) With AnaAltMen .Caption = "Yedekleme lemleri" End With 'Yedek Alma lemi With AnaAltMen.Controls.Add(msoControlButton, 1, , , True) .Caption = "Yedek Alma lemi" .OnAction = "yedal" .Style = msoButtonIconAndCaption .FaceId = 117 .State = msoButtonUp End With 'Yedek Geri Dnme lemi With AnaAltMen.Controls.Add(msoControlButton, 1, , , True) .Caption = "Yedek Geri Dnme lemi" .OnAction = "yedgerd" .Style = msoButtonIconAndCaption .FaceId = 118 .State = msoButtonUp End With On Error Resume Next End Sub Sub auto_close() MenuBars(xlWorksheet).Reset End Sub
Sub AjouteMenus() MenuBars(xlWorksheet).Menus.Add Caption:="&MonMenu", before:=9 '(before:=9)modifi cette valeur pour placer le menu o vous voulez MenuBars(xlWorksheet).Menus("&MonMenu").MenuItems.Add _ Caption:="&SousMenu1", before:=1, OnAction:="Nom de la macro 1" 'Excute la macro 1 MenuBars(xlWorksheet).Menus("&MonMenu").MenuItems.Add _ Caption:="&SousMenu2", before:=1, OnAction:="Nom de la macro 2" 'Excute la macro 2 End Sub Sub SupprimeMenus() For Each MenuName In MenuBars(xlWorksheet).Menus If MenuName.Caption = "&MonMenu" Then MenuName.Delete End If Next End Sub Thisworkbooka Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.CommandBars("Symbolleiste_Klaus").Delete End Sub Private Sub Workbook_Open() On Error Resume Next Application.CommandBars.Add(Name:="Symbolleiste_Klaus").Visible = True Set myControl1 = Application.CommandBars("Symbolleiste_Klaus").Controls.Add(msoControlButton) With myControl1 .FaceId = 71 'HIER FACE-ID ANPASSEN .OnAction = "Klaus1" 'HIER DEINEN MAKRONAMEN ANPASSEN .Caption = "Klaus Makro 1" 'HIER DEINEN INFOTEXT ANPASSEN End With Set myControl2 = Application.CommandBars("Symbolleiste_Klaus").Controls.Add(msoControlButton) With myControl2 .FaceId = 72 'HIER FACE-ID ANPASSEN .OnAction = "Klaus2" 'HIER DEINEN MAKRONAMEN ANPASSEN .Caption = "Klaus Makro 2" 'HIER DEINEN INFOTEXT ANPASSEN End With End Sub 'Modle Sub Klaus1() MsgBox "http://www.excel-lex.de.vu" End Sub Sub Klaus2() MsgBox "http://www.kmbuss.de" End Sub
Set ML = Application.CommandBars("Worksheet Menu Bar") ' Name fr neues Men anlegen Set U1 = ML.Controls.Add(Type:=msoControlPopup, Before:=10) U1.Caption = "&EXCEL-LEX" U1.Tag = "MeinMen" ' dient zur eindeutigen Identifizierung des Mens ' 1. Menpunkt anlegen Set Punkt = U1.Controls.Add(Type:=msoControlButton) With Punkt .Caption = "&1. Menpunkt" .OnAction = "MsgBox1" .Style = msoButtonIconAndCaption .FaceId = 3278 End With ' neues Untermen wird hinzugefgt Set Punkt = U1.Controls.Add(Type:=msoControlPopup) With Punkt .Caption = "1.Untermen" End With Set U2 = Punkt ' Variable fr das 2. Untermen wird gesetzt ' Neuer Meneintrag im 2.Untermen Set Punkt = U2.Controls.Add(Type:=msoControlButton) With Punkt .Caption = "&2.Menpunkt" .OnAction = "MsgBox2" .Style = msoButtonIconAndCaption .FaceId = 488 End With Set Punkt = U2.Controls.Add(Type:=msoControlButton) With Punkt .Caption = "&3.Menpunkt" .OnAction = "MsgBox3" .Style = msoButtonIconAndCaption .FaceId = 1715 End With ' Weiterer Eintrag im 1.Untermen Set Punkt = U1.Controls.Add(Type:=msoControlButton) With Punkt .Caption = "&4.Menpunkt" .OnAction = "MsgBox4" .Style = msoButtonIconAndCaption .FaceId = 3200 End With End Sub Sub Menue_aus() Set ML = Application.CommandBars("Worksheet Menu Bar") On Error Resume Next ' Fehlerbehandlung ML.FindControl(Tag:="MeinMen").Delete End Sub Private Sub Workbook_Open() Dim cbMenu As CommandBar Dim cbSpecialMenu As CommandBarPopup Dim cbCommand As CommandBarControl Set cbMenu = Application.CommandBars("Worksheet Menu Bar") Set cbSpecialMenu = cbMenu.Controls.Add(Type:=msoControlPopup) cbSpecialMenu.Caption = "Mein Spezialmenu" Set cbCommand = cbSpecialMenu.Controls.Add(Type:=msoControlButton) cbCommand.Caption = "Mein Befehl" cbCommand.OnAction = "sil" End Sub Sub sil() Dim cbSpecialMenu As CommandBarControl On Error Resume Next Set cbSpecialMenu = Application.CommandBars("Worksheet Menu Bar").Controls("Mein Spezialmenu") cbSpecialMenu.Delete End Sub
Dim AnaMenu As CommandBarControl, AnaAltMenu As CommandBarControl Sheets("Sayfa1").Select Range("A1").Select Set AnaMenu = Application.CommandBars(1).Controls.Add(msoControlPopup, , , , True) With AnaMenu .Caption = "&Deneme Men" .Tag = "MyTag" .BeginGroup = False End With If AnaMenu Is Nothing Then Exit Sub Set AnaAltMenu = AnaMenu.Controls.Add(msoControlPopup, 1, , , True) With AnaAltMenu .Caption = "1.Ksm" End With With AnaAltMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "1.Ksm Yan Menleri-1-" .OnAction = "makrom" .Style = msoButtonIconAndCaption .FaceId = 3734 .State = msoButtonUp End With With AnaAltMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "1.Ksm Yan Menleri-2-" .OnAction = "makrom" .Style = msoButtonIconAndCaption .FaceId = 3735 .State = msoButtonUp End With With AnaAltMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "1.Ksm Yan Menleri-3-" .OnAction = "makrom" .Style = msoButtonIconAndCaption .FaceId = 3733 .State = msoButtonUp End With Set AnaAltMenu = AnaMenu.Controls.Add(msoControlPopup, 1, , , True) With AnaAltMenu .Caption = "2.Ksm" End With With AnaAltMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "2.Ksm Yan Menleri-1-" .OnAction = "makrom" .Style = msoButtonIconAndCaption .FaceId = 3733 .State = msoButtonUp End With On Error Resume Next End Sub Sub makrom() MsgBox "Deneme Mensne ait Makro alt" End Sub Sub auto_close() Application.CommandBars("Worksheet Menu Bar").Reset End Sub Sub ID_anzeigen() Dim intZ%, objY As CommandBar, objX As CommandBarControl [a1] = "ID": [b1] = "Name": [c1] = "Index": [d1] = "Symbolleiste" intZ = 2 For Each objY In CommandBars For Each objX In CommandBars(objY.Name).Controls Cells(intZ, 1) = objX.ID Cells(intZ, 2) = objX.Caption Cells(intZ, 3) = objX.Index Cells(intZ, 4) = objY.Name intZ = intZ + 1 Next Next End Sub
Sub StartClock() StartClockinMenu End Sub Sub StopClock() StopClockinMenu End Sub 'Modle2 ye Option Explicit Private Declare Function FindWindow _ Lib "user32" _ Alias "FindWindowA" _ (_ ByVal lpClassName As String, _ ByVal lpWindowName As String _ )_ As Long Private Declare Function SetTimer _ Lib "user32" _ (_ ByVal hWnd As Long, _ ByVal nIDEvent As Long, _ ByVal uElapse As Long, _ ByVal lpTimerFunc As Long _ )_ As Long Private Declare Function KillTimer _ Lib "user32" _ (_ ByVal hWnd As Long, _ ByVal nIDEvent As Long _ )_ As Long Private Declare Function GetCurrentVbaProject _ Lib "vba332.dll" _ Alias "EbGetExecutingProj" _ (_ hProject As Long _ )_ As Long Private Declare Function GetFuncID _ Lib "vba332.dll" _ Alias "TipGetFunctionId" _ (_ ByVal hProject As Long, _ ByVal strFunctionName As String, _ ByRef strFunctionID As String _ )_ As Long Private Declare Function GetAddr _ Lib "vba332.dll" _ Alias "TipGetLpfnOfFunctionId" _ (_ ByVal hProject As Long, _ ByVal strFunctionID As String, _ ByRef lpfnAddressOf As Long _ )_ As Long Private WindowsTimer As Long Private ClockCBControl As CommandBarButton Sub StartClockinMenu() Set ClockCBControl = _ Application.CommandBars(1).Controls.Add( _ Type:=msoControlButton, Temporary:=True) ClockCBControl.Style = msoButtonCaption ClockCBControl.Caption = Format(Now, "Long Time") fncWindowsTimer 1000 End Sub Sub StopClockinMenu() fncStopWindowsTimer ClockCBControl.Delete
Men ubuundaki 6. maddeyi (Aralar) gizler. Sub SupprimeIntituleOutils() CommandBars(1).Controls(6).Visible = False End Sub ' Men ubuundaki 6. maddeyi (Aralar) gsterir. Sub ReinstalleIntituleOutils() CommandBars(1).Controls(6).Visible = True End Sub Public Sub Me_006() Dim CmdB As CommandBar Dim i As Integer 'Dim i% i=1 With ActiveSheet .[A:B].ClearContents .[A1].Value = "Name" .[B1].Value = "Lokaler Name" End With For Each CmdB In Application.CommandBars If CmdB.Type = msoBarTypeNormal Then i=i+1 With ActiveSheet .Cells(i, 1).Value = CmdB.Name .Cells(i, 2).Value = CmdB.NameLocal End With End If Next CmdB ActiveSheet.Columns("A:B").AutoFit End Sub Ana Menlerde ' Aralar mensn pasif yapar. Sub AraclarMenusuPasif() CommandBars(1).Controls(6).Enabled = False End Sub ' Aralar mensn aktif yapar. Sub AraclarMenusuAktif() CommandBars(1).Controls(6).Enabled = True End Sub 'Alt Menlerde ' Aralar mensndeki 7. maddeyi (Koruma...) pasif yapar. Sub InhibeOutilsProtection() CommandBars(1).Controls(6).Controls(7).Enabled = False End Sub ' Aralar mensndeki 7. maddeyi (Koruma...) aktif yapar. Sub AfficheOutilsProtection() CommandBars(1).Controls(6).Controls(7).Enabled = True End Sub Sub TwoLines() MsgBox "Line 1" & vbCrLf & "Line 2" End Sub Sub Heure() Dim i As Byte For i = 0 To 23 Application.OnTime TimeValue(i & ":00:00"), "Affiche_Heure" Next i End Sub Sub Affiche_Heure() MsgBox "Il est " & Time End Sub Sub mesaj() MsgBox "yisinizdir naallah", , "naslsnz" End Sub MsgBox "Mesaj boxlarda satr ba yapamyorum." & vbCrlf & "Bunun bir yolu olmal !" & vbCrlf & "Acaba vbCrlf kullanrsam ne olur?", vbinformation
Yada Alt+Enter'in Ascii kodu olan chr(10) kullanlabilir. Sub A() MsgBox "A" & Chr(10) & "B" & Chr(10) & "C" & Chr(10) & "D" & Chr(10) End Sub Sub MsgAscii() Dim sayi1 As Integer For sayi1 = 1 To 255 msg = msg & (sayi1) & Chr(58) & Chr(sayi1) & Space(1) Next sayi1 MsgBox msg, 64, Chr(83) & Chr(252) & Chr(108) & Chr(101) _ & Chr(121) & Chr(109) & Chr(97) & Chr(110) & Chr(32) & Chr(85) _ & Chr(90) & Chr(85) & Chr(78) & Chr(75) & Chr(214) & Chr(80) & _ Chr(82) & Chr(220) End Sub Dim c As Range, rngSection As Range Dim cFirst As Range, cLast As Range Dim rowLast As Long, colLast As Integer Dim r As Long, iSection As Integer Dim iCopies As Variant Dim strCH As String Set c = Range("A1").SpecialCells(xlCellTypeLastCell) rowLast = c.Row colLast = c.Column iCopies = InputBox( _ "Number of Copies", "Changing Section Headers", 1) If iCopies = "" Then Exit Sub Set cFirst = Range("A1") ' initialization start cell For r = 2 To rowLast ' from first row to last row If ActiveSheet.Rows(r).PageBreak = xlPageBreakManual Then Set cLast = Cells(r - 1, colLast) Set rngSection = Range(cFirst, cLast) iSection = iSection + 1 Select Case iSection ' substitute your CenterSection Header data ... Case 1: strCH = "Section 1" Case 2: strCH = "Section 2" ' etc ' Case n: strCH = "Section n" End Select ActiveSheet.PageSetup.CenterHeader = strCH rngSection.PrintOut _ Copies:=iCopies, Collate:=True Set cFirst = Cells(r, 1) End If Next r ' Last Section ++++++++++++++++++++++++++++ Set rngSection = Range(cFirst, c) iSection = iSection + 1 ' substitute your Center Header data ... strCH = "Last Section ..." ' or strCH = "Section " & iSection ActiveSheet.PageSetup.CenterHeader = strCH rngSection.PrintOut _ Copies:=iCopies, Collate:=True End Sub
Sub MyMessage() MsgBox "Merhaba 1" MsgBox "Merhaba 2", vbInformation MsgBox "Merhaba 3", vbExclamation, "Buras Balk Ksm" MsgBox "Merhaba 4", vbCritical, "Buras Balk Ksm" MsgBox "Merhaba 5", vbDefaultButton1 MsgBox "Merhaba 6", vbDefaultButton2 MsgBox "Merhaba 7", vbDefaultButton3 MsgBox "Merhaba 8", vbDefaultButton4 MsgBox "Merhaba 9", vbMsgBoxHelpButton MsgBox "Merhaba 10", vbApplicationModal MsgBox "Merhaba 11", vbMsgBoxRight MsgBox "Merhaba 12", vbMsgBoxRtlReading MsgBox "Merhaba 13", vbMsgBoxSetForeground MsgBox "Merhaba 14", vbOKCancel MsgBox "Merhaba 15", vbOKOnly MsgBox "Merhaba 16", vbQuestion MsgBox "Merhaba 17", vbRetryCancel MsgBox "Merhaba 18", vbSystemModal MsgBox "Merhaba 19", vbYesNo MsgBox "Merhaba 20", vbYesNoCancel End Sub Sub msg_yes_no() iResult = MsgBox("Evet mi, Hayr m?", vbYesNo) If iResult = vbYes Then 'Evet iin buraya kod yazabilirsiniz MsgBox "Evet i setin" Else 'Hayr iin buraya kod yazabilirsiniz MsgBox "Hayr setin" End If End Sub Sub MsgBox() Dim WshShell Dim intAntwort As Integer Set WshShell = CreateObject("WScript.Shell") intAntwort = WshShell.Popup(WeekdayName(Weekday(Date, vbMonday)) _ & Chr(13) & _ Day(Date) & ". " & _ MonthName(Month(Date)) & " " & _ Year(Date) & Chr(13) & _ Time, 3, "pir") End Sub Sub Adjust() Dim Target As Range Dim J As Integer Dim sForm As String Dim sMod As String Set Target = ActiveSheet.Range(ActiveWindow.Selection.Address) sMod = InputBox("Formula to add?") If sMod > "" Then For J = 1 To Target.Cells.Count If Target.Cells(J).HasFormula Then sForm = Target.Cells(J).Formula sForm = "=(" & Mid(sForm, 2, 500) & ")" sForm = sForm & sMod Target.Cells(J).Formula = sForm Else sForm = "=" & Target.Cells(J).Value & sMod Target.Cells(J).Formula = sForm End If Next J End If End Sub
Sub msg1() MsgBox "Test MSG1", vbInformation, "Information fichier" End Sub Sub msg11() MsgBox "Test MSG11", 64, "Information fichier" End Sub 'Indique un message d'exclamation Sub msg2() MsgBox "Test MSG2", vbExclamation, "Information fichier" End Sub 'Idem avec la valeur 48 Sub msg22() MsgBox "Test MSG22", 48, "Information fichier" End Sub 'En plus clair Sub msg3() MsgBox prompt:="Il est l'heure de votre RDV", _ Buttons:=vbExclamation, Title:="ATTENTION" End Sub Sub Send_Excel_Message() Dim MyMessage As Object, MyOutApp As Object 'InitializeOutlook = True Set MyOutApp = CreateObject("Outlook.Application") Set MyMessage = MyOutApp.CreateItem(0) With MyMessage .To = "mahmut_bayram@mynet.com" .Subject = "Testmeldung von Excel2000 " & Date & Time '.body = "Selamun Aleykm" & vbCrLf & "Naslsnz Mahmut Bey" .HTMLBody = "Afiyettesinizdir" & vbCrLf & "naallah." .Display .Save SendKeys "%S" End With 'MyOutApp.Quit bataki iaret kaldrrsanz mesaj gnderen uygulamay kapatr. Set MyOutApp = Nothing Set MyMessage = Nothing End Sub Sub Macro1() MsgBox ("This is Macro1") Call Macro2 End Sub Sub TestValeurVide() Dim MaValeur, MonTest MaValeur = Empty 'il y a une valeur MonTest = IsEmpty(MaValeur) ' Test si ma valeur est vide MsgBox MonTest 'Retourne Vrai MaValeur = Null 'il n'y a pas de valeur MonTest = IsEmpty(MaValeur)' Test si ma valeur est vide (EstVide) MsgBox MonTest 'Retourne Faux MaValeur = Null 'il n'y a pas de valeur MonTest = Not IsEmpty(MaValeur) ' Test si ma valeur n'est pas vide (Non EstVide) MsgBox MonTest 'Retourne Vrai End Sub Sub Valeurnum() Dim MaValeur, MaValeur2, MonTest, MonTest2 MaValeur = "4578" MonTest = IsNumeric(MaValeur) 'Retourne Vrai MsgBox MonTest MaValeur = "4578,456" MonTest = IsNumeric(MaValeur) 'Retourne Vrai MsgBox MonTest MaValeur2 = "daniel" MonTest2 = IsNumeric(MaValeur2) 'Retourne Faux MsgBox MonTest2 End Sub
Sub ValeurDate() Dim MaDate, NonDate, TestDate, TestDate2 MaDate = "02 Mai 2002": NonDate = "Daniel" TestDate = IsDate(MaDate) 'Retourne Vrai MsgBox TestDate TestDate2 = IsDate(NonDate) 'Retourne Faux MsgBox TestDate2 End Sub Seili kolonlardaki yazlar birletirir. En stteki satr birletirir. Sub JoinText() myCol = Selection.Columns.Count For i = 1 To myCol ActiveCell = ActiveCell.Offset(0, 0) & ActiveCell.Offset(0, i) ActiveCell.Offset(0, i) = "" Next i End Sub Sub MetinliSatirSil() NbRw = Application.CountA(Columns("A:A")) For Rw = NbRw To 1 Step -1 If Application.IsText(Cells(Rw, 1)) Then Rows(Rw).Delete Next Rw End Sub Onun yerine, TextBox nesnesinden "cursor - imle" ktnda bu iin yaplmasn istersen; Kod: Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "#,### TL") End Sub
Ve, eer az nce rastladm senin dier bir mesajnda bu iin yaplmasn istersen; Kod: Private Sub TextBox1_Change() RefreshTxtBx End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "#,### TL") End Sub ' Private Sub TextBox2_Change() RefreshTxtBx End Sub ' Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox2 = Format(TextBox2, "#,### TL") End Sub ' Private Sub RefreshTxtBx() Dim Val1 As Double, Val2 As Double On Error Resume Next Val1 = TextBox1 Val2 = TextBox2 On Error GoTo 0 TextBox3 = Format(Val1 + Val2, "#,### TL") End Sub
Sadece say yazmak iinde aadaki linki inceleyiniz. visual basic kodu: -------------------------------------------------------------------------------Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "###-### ## ##") End Sub --------------------------------------------------------------------------------
tutarda sadece saysal deer (saynn 1.234,56 eklinde) yazlmas iin visual basic kodu: -------------------------------------------------------------------------------Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If IsNumeric(TextBox1) = True Then TextBox1 = Format(TextBox1, "###,###.##") Exit Sub End If TextBox1 = "GRLEN DEER HATALIDIR" End Sub
Sub BuyukHarf() For Each c In Selection.Cells c.Value=Ucase$(c.Value) Next c End Sub Metni kk harf yapmak iinse u makroyu kullann: Sub KucukHarf() For Each c In Selection.Cells c.Value=Lcase$(c.Value) Next c End Sub 'VERLEN HCRE LTNE GRE SAYFAYA YAZILANLARI BYK HARFE EVRR. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim RaBereich As Range, RaZelle As Range Application.EnableEvents = False Set RaBereich = Range("a1:1000") Application.EnableEvents = False For Each RaZelle In Range(Target.Address) If Not Intersect(RaZelle, RaBereich) Is Nothing Then RaZelle.Value = UCase(RaZelle.Value) End If Next RaZelle Application.EnableEvents = True Set RaBereich = Nothing End Sub 'VERLEN HCRE LTNE GRE SAYFAYA YAZILANLARIN BA HARFN BYK HARFE EVRR. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim RaBereich As Range, RaZelle As Range Application.EnableEvents = False Set RaBereich = Range("a1:1000") Application.EnableEvents = False For Each RaZelle In Range(Target.Address) If Not Intersect(RaZelle, RaBereich) Is Nothing Then If RaZelle <> "" Then RaZelle.Value = UCase(Mid(RaZelle.Value, 1, 1)) _ & LCase(Mid(RaZelle.Value, 2, Len(RaZelle.Value) - 1)) End If End If Next RaZelle Application.EnableEvents = True Set RaBereich = Nothing End Sub
Sub BuyukHarf() For Each c In Selection.Cells c.Value=Ucase$(c.Value) Next c End Sub Metni kk harf yapmak iinse u makroyu kullann: Sub KucukHarf() For Each c In Selection.Cells c.Value=Lcase$(c.Value) Next c End Sub 'VERLEN HCRE LTNE GRE SAYFAYA YAZILANLARI BYK HARFE EVRR. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim RaBereich As Range, RaZelle As Range Application.EnableEvents = False Set RaBereich = Range("a1:1000") Application.EnableEvents = False For Each RaZelle In Range(Target.Address) If Not Intersect(RaZelle, RaBereich) Is Nothing Then RaZelle.Value = UCase(RaZelle.Value) End If Next RaZelle Application.EnableEvents = True Set RaBereich = Nothing End Sub 'VERLEN HCRE LTNE GRE SAYFAYA YAZILANLARIN BA HARFN BYK HARFE EVRR. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim RaBereich As Range, RaZelle As Range Application.EnableEvents = False Set RaBereich = Range("a1:1000") Application.EnableEvents = False For Each RaZelle In Range(Target.Address) If Not Intersect(RaZelle, RaBereich) Is Nothing Then If RaZelle <> "" Then RaZelle.Value = UCase(Mid(RaZelle.Value, 1, 1)) _ & LCase(Mid(RaZelle.Value, 2, Len(RaZelle.Value) - 1)) End If End If Next RaZelle Application.EnableEvents = True Set RaBereich = Nothing End Sub
Sub TextCaseChange() Dim RgText As Range Dim oCell As Range Dim Ans As String Dim strTest As String Dim Char As Long Dim sCap As Integer, lCap As Integer, i As Integer ' You need to select a Range to Alter 1st! Again: Ans = Application.InputBox("[L]owercase" & vbCr & "[U]ppercase" & vbCr & _ "[S]entence" & vbCr & "[T]itles" & vbCr & "[C]apsSmall", _ "Type in a Letter", Type:=2) If Ans = "False" Then Exit Sub If InStr(1, "LUSTC", UCase(Ans), vbTextCompare) = 0 Or Len(Ans) > 1 Then GoTo Again On Error GoTo NoText If Selection.Count = 1 Or Selection.MergeCells = True Then If Selection.HasFormula = True Then GoTo NoText Set RgText = Selection Else Set RgText = Selection.SpecialCells(xlCellTypeConstants, 2) End If On Error GoTo 0 For Each oCell In RgText Select Case UCase(Ans) Case "L": oCell = LCase(oCell.Text) Case "U": oCell = UCase(oCell.Text) Case "S": ' need to look @ handling spaces in 1st letters!! ' Done Char = GetfirstChar(oCell.Text) oCell = UCase(Left(oCell.Text, Char)) & _ LCase(Right(oCell.Text, Len(oCell.Text) - Char)) Case "T": oCell = Application.WorksheetFunction.Proper(oCell.Text) Case "C" lCap = oCell.Characters(1, 1).Font.Size sCap = Int(lCap * 0.85) 'Small caps for everything. oCell.Font.Size = sCap oCell.Value = UCase(oCell.Text) strTest = oCell.Value 'Large caps for 1st letter of words. strTest = Application.Proper(strTest) For i = 1 To Len(strTest) If Mid(strTest, i, 1) = UCase(Mid(strTest, i, 1)) Then oCell.Characters(i, 1).Font.Size = lCap End If Next i End Select Next Exit Sub NoText: MsgBox "No Text in your selection @ " & Selection.Address End Sub Function GetfirstChar(strTxt As String) As Long ' Gets 1st Character that is NOT a Space Dim x As Long Dim s As String For x = 1 To Len(strTxt) s = UCase(Mid(strTxt, x, 1)) If (s Like "[A-Z]") Then GetfirstChar = x Exit Function End If Next End Function
Sub SayfaAdlariniDegistir() Dim I As Integer Application.ScreenUpdating = False For I = 1 To 3 Worksheets(I).Name = "YeniAd" & I Next I End Sub Bir userform ekle. Forma bir "Windows Media Player" nesnesi (BE penceresindeki Tools-->Additional Controls...'dan seerek Toolbox'a ekleyin) ve bir "Com Sub FormGoster() UserForm1.Show End Sub 'Formun kod sayfasna da aadaki kodlar ekle. Private Sub CommandButton1_Click() MediaPlayer1.Stop Unload Me End Sub Private Sub UserForm_Initialize() MediaPlayer1.Filename = Range("A2").Value MediaPlayer1.AutoStart = True End Sub 'Excel alma sayfasna bir buton koyarak FormGoster makrosunu bu butona atyoruz. Butona tkladmzda userform alarak sayfadaki "A2" hcresinde Private Declare Function mciExecute Lib "winmm.dll" _ (ByVal lpstrCommand As String) As Long Sub PlayMIDI() MIDIFile = "xfiles.mid" MIDIFile = ThisWorkbook.Path & "\" & MIDIFile mciExecute ("play " & MIDIFile) End Sub Sub StopMIDI() MIDIFile = "xfiles.mid" MIDIFile = ThisWorkbook.Path & "\" & MIDIFile mciExecute ("stop " & MIDIFile) End Sub
Kod: 'Windows API function declaration Private Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Long, ByVal dwFlags As Long) As Long Function Alarm(Cell, Condition) Dim WAVFile As String Const SND_ASYNC = &H1 Const SND_FILENAME = &H20000 On Error GoTo ErrHandler If Evaluate(Cell.Value & Condition) Then WAVFile = ThisWorkbook.Path & "\sound.wav" 'Edit this statement Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME) Alarm = True Exit Function End If ErrHandler: Alarm = False End Function Kod: =Alarm(A1;">=1000")
imdi benim sorunum yle , E stununda tarihler var.Bu tarihlerden 10 gn nce alarm versin ve F stunundaki kiilere Microsoft Outlookdan uyar e-m _________________ Haluk Moderatr --------------------------------------------------------------------------------
Excel ile e-mail gnderilecekse e-mail client olarak MS Outlook'un kullanlmas her zaman daha iyidir. nk MS Outlook da bir Office program olduu iin
Aadaki kodu altrmadan nce Excel VBE'de Tools | References ksmndan MS Outlook 9.0 Object Libray referansnn eklenmesi gerekir. (MS Outlook v
PC'nin tarihi ile E stunundaki tarihleri kontrol edip, 10 gnlk fark grd yerde F stunundaki geerli e-mail adresine bir e-mail, MS Outlook ile aad Kod: Sub MultiEmail() Dim OutApp As Outlook.Application Dim NewMail As Outlook.MailItem Dim noE As Integer, i As Integer noE = Cells(65536, 5).End(xlUp).Row For i = 1 To noE If Cells(i, 5) = Date - 10 Then Set OutApp = New Outlook.Application Set NewMail = CreateItem(olMailItem) With NewMail .To = Cells(i, 6).Text .Subject = "Deneme" .Body = "Bu e-mail deneme amacyla gnderilmitir." .Save .Send End With Set NewMail = Nothing Set OutApp = Nothing End If Next End Sub
Eer bu kodun altrld PC'de ilgili gvenlik yamas kurulmu ise Windows kullancy ikaz eder ve baka bir programn e-mail gndermeye altna da
Sub PlayMIDI() Dim Player Player = Shell("C:\Program Files\Windows Media Player\wmplayer.exe") C:\Songs\regypti.mid", 6) AppActivate Player End Sub Sub Play_Sound() Dim Player Player = Shell("C:\Program Files\Windows Media Player\wmplayer.exe,C:\canyon.mid", 6) AppActivate Player End Sub Sub PlayMIDI() Dim Player Player = Shell("C:\Progra~1\Window~1\mplayer2.exe C:\Songs\regypti.mid", 6) AppActivate Player End Sub ' ThisWorkbook ksmna yaz. Option Explicit Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.OnKey " ", "" End Sub Private Sub Workbook_Open() bStart = False Application.OnKey " ", "MyTimer" End Sub ' Modle yaz. Private Declare Function timeGetTime Lib "winmm.dll" () As Long Public Public Public Public bStart As Boolean iStartTime As Long iEndTime As Long iTotalTime As Long
Public Sub StartStop_MyTimer() '// START iin butona tkla '// STOP iin butona tekrar tkla bStart = Not (bStart) If bStart Then iStartTime = timeGetTime Else iEndTime = timeGetTime iTotalTime = iEndTime - iStartTime With Sheets("Sheet1").Range("A65536").End(xlUp).Offset(1, 0) .Value = iTotalTime .Offset(0, 1).Value = "milliseconds" End With End If End Sub Sub Mini_Mail() Shell "C:\Program Files\Microsoft Office\Office10\OUTLOOK.exe" ActiveWorkbook.SendMail Recipients:="mahmut_bayram@mynet.com", Subject:="Test" End Sub Sub ModulGizle() Module(1).Visible = xlVeryHidden End Sub Sub ModulGoster() Module(1).Visible = True End Sub Sub Loeschen() With Workbooks("Kitap1.xls").VBProject .VBComponents.Remove .VBComponents("Modul1") End With End Sub
BU KOD MODL NE YAZILAN KODU SAYFA NDE AKTF HALE GETRR. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Call Makro1 End Sub BU KOD MODL NE YAZILAN KODU SAYFA NDE AKTF HALE GETRR. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Call Makro1 End Sub Private Sub TextBox25_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) On Error Resume Next If TextBox5 = Empty Then : Exit Sub Else TextBox25.Value = WorksheetFunction.Round((TextBox5.Value * 0.7), 2) End If End Sub (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _ ByValuReturnLength As Long, ByVal hwndCallback As Long) As Long Public Declare Function GetShortPathName Lib "kernel32" Alias _ "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As _ String, ByVal cchBuffer As Long) As Long Sub LanceMP3() X = ThisWorkbook.Path joueMP3 (X & "\monfichier.mp3") End Sub
Public Sub joueMP3(ByVal Mp3 As String) Dim Tmp As Long, Tmp2 As String 'Screen.MousePointer = vbHourglass Tmp2 = NomCourt(Mp3) Tmp = mciSendString("close MP3_Device", vbNullString, 0&, 0&) Tmp = mciSendString("open " & Tmp2 & " type MPEGVideo alias MP3_Device", _ vbNullString, 0&, 0&) If Tmp = 0 Then Tmp = mciSendString("play Mp3_Device", vbNullString, 0&, 0&) If Tmp <> 0 Then Screen.MousePointer = 0 MsgBox "Incapable de jouer ce Mp3" 'Else ' Tmp = mciSendString("close MP3_Device", vbNullString, 0&, 0&) End If Else 'Screen.MousePointer = 0 MsgBox "Incapable de jouer ce Mp3" End If 'Screen.MousePointer = 0 End Sub Public Sub StopMP3() Dim Tmp As Long Tmp = mciSendString("close MP3_Device", vbNullString, 0&, 0&) End Sub Private Function NomCourt(ByVal Fichier As String) As String Dim Tmp As String * 255, Tmp2 As Byte Tmp2 = GetShortPathName(Fichier, Tmp, Len(Tmp)) If Tmp2 > 0 Then NomCourt = Left(Tmp, Tmp2) End If End Function
Option Explicit ' Modul ' bentigte API-Deklarationen Private Declare Function mciSendString Lib "winmm.dll" _ Alias "mciSendStringA" ( _ ByVal lpstrCommand As String, _ ByVal lpstrReturnString As String, _ ByVal uReturnLength As Long, _ ByVal hwndCallback As Long) As Long Private Declare Function GetShortPathName Lib "kernel32" _ Alias "GetShortPathNameA" ( _ ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, _ ByVal cchBuffer As Long) As Long ' Ermittelt die Lnge einer MP3-Datei Sub Lnge_MP3() Dim song As String Dim zeile As Integer zeile = ActiveCell.Row song = Cells(zeile, 1).Value '"C:\My Music\MP3\ABBA - Mamma Mia.mp3" MsgBox ("Titellnge: " & Chr(13) & Chr(13) & FormatTime(GetMP3Length(song)) & " min.") End Sub ' in Millisekunden Function GetMP3Length(ByVal strFileName As String) As Long Dim strBuffer As String Dim lRet As Long Dim sReturn As String ' Da die mciSendString Funktion mit langen Dateinamen ' nicht korrekt arbeitet, muss zuvor der kurze ' 8.3 Dateiname der MP3-Datei ermittelt werden. strBuffer = Space$(255) lRet = GetShortPathName(strFileName, strBuffer, Len(strBuffer)) If lRet <> 0 Then strFileName = Left$(strBuffer, InStr(strBuffer, vbNullChar) - 1) End If ' MP3-Datei ffnen mciSendString "open " & strFileName & _ " type MPEGVideo alias mp3audio", 0, 0, 0 ' Lnge der Datei in Millisekunden auslesen sReturn = Space$(256) lRet = mciSendString("status mp3audio length", _ sReturn, Len(sReturn), 0&) ' MP3-Datei schliessen mciSendString "close mp3audio", 0, 0, 0 GetMP3Length = Val(sReturn) End Function ' Fr das Umwandeln der Zeitrckgabe (Millisekunden) in ein besser ' lesbares Format (Minuten:Sekunden) knnen Sie zustzlich nachfolgende ' Funktion einsetzen: ' Millisekunden in lesbares Zeitformat umwandeln Function FormatTime(ByVal lMSec As Long) _ As String Dim iMin As Integer Dim iSec As Integer iSec = Int(lMSec / 1000) iMin = Int(iSec / 60) iSec = iSec - (iMin * 60) FormatTime = Format$(iMin, "00") & ":" & _ Format$(iSec, "00") End Function
'VBE sayfasna gein ve bo bir modln en bana(declare ksmna) aadaki api kodlarn kopyalayn. Public Const NV_CLOSEMSGBOX As Long = &H5000& Public Declare Function SetTimer& Lib "user32" (ByVal hWnd&, ByVal nIDEvent&, _ ByVal uElapse&, ByVal lpTimerFunc&) Public Declare Function FindWindow& Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName$, ByVal lpWindowName$) Public Declare Function LockWindowUpdate& Lib "user32" (ByVal hwndLock&) Public Declare Function SetForegroundWindow& Lib "user32" (ByVal hWnd&) Public Declare Function MessageBox& Lib "user32" Alias "MessageBoxA" _ (ByVal hWnd&, ByVal lpText$, ByVal lpCaption$, ByVal wType&) Public Declare Function KillTimer& Lib "user32" (ByVal hWnd&, ByVal nIDEvent&) Public Const API_FALSE As Long = 0& Public Sub TimerProc(ByVal hWnd&, ByVal uMsg&, ByVal idEvent&, ByVal dwTime&) KillTimer hWnd, idEvent Dim hMessageBox& hMessageBox = FindWindow("#32770", "Otomatikman kapanan Mesaj kutusu") If hMessageBox Then Call SetForegroundWindow(hMessageBox) SendKeys "{enter}" End If Call LockWindowUpdate(API_FALSE) End Sub 'Daha sonra ilgili alma kitabnn ThisWorkbook kod sayfasna aadaki kodlar kopyalayn. Private Sub Workbook_SheetActivate(ByVal Sh As Object) SetTimer hWnd, NV_CLOSEMSGBOX, 10000&, AddressOf TimerProc mes = "u anda " & ActiveSheet.Name & " atnz." + Chr(10) mes = mes + "Bu mesaj kutusu 10 saniye sonra kapanacak." + Chr(10) Call MessageBox(hWnd, mes, _ "Otomatikman kapanan Mesaj kutusu", MB_ICONQUESTION Or MB_TASKMODAL) End Sub
'Artk sayfa geilerinde karnza kendiliinden kapanan Mesaj Kutusu kacak. 'Burada 10000 says Mesaj Kutusunun ekranda kalma sresini ifade ediyor,bu sayyla oynayarak Mesaj Kutusunun istediiniz anda kapanmasn salayabi 'Ayrca bu Mesaj Kutusunu inisiyatifinize gre, kodlarnz ierisinde de kullanabilirsiniz,oras sizin hayal gcnze kalm artk. Sub Kapanan_MsgBox() CreateObject("WScript.Shell").Popup "Merhaba.", 3, "Bu mesaj kutusu 3 saniye iinde kapanacak." End Sub Sub sonkezsor() soru = MsgBox("Eminmisiniz?", Buttons:=vbQuestion + vbYesNo) If soru = vbYes Then ..................... End If End Sub Sub EingabeUeberInputbox() Dim wert01 As String wert01 = InputBox("Wert eingeben", "Bitte geben Sie einen Wert ein") Range("a1").Value = wert01 End Sub Msgbox'da - Gn - Tarih - Saat gsterir Sub MsgBox() Dim WshShell Dim intAntwort As Integer Set WshShell = CreateObject("WScript.Shell") intAntwort = WshShell.Popup(WeekdayName(Weekday(Date, vbMonday)) _ & Chr(13) & _ Day(Date) & ". " & _ MonthName(Month(Date)) & " " & _ Year(Date) & Chr(13) & _ Time, 3, "www.excel.web.tr") End Sub
Sub MsgBox() Dim WshShell Dim intAntwort As Integer Set WshShell = CreateObject("WScript.Shell") intAntwort = WshShell.Popup(WeekdayName(Weekday(Date, vbMonday)) _ & Chr(13) & _ Day(Date) & ". " & _ MonthName(Month(Date)) & " " & _ Year(Date) & Chr(13) & _ Time, 3, "pir") End Sub Private Sub CommandButton3_Click() MultiPage1.Value = MultiPage1.Value + 1 End Sub Private Sub MultiPage1_Change() Select Case MultiPage1.SelectedItem.Caption Case "Page1": Sheets("Sayfa1").Select Case "Page2": Sheets("Sayfa2").Select Case "Page3": Sheets("Sayfa3").Select Case "Page4": Sheets("Sayfa4").Select End Select End Sub ncelikle Page1'in index'inin 0 ve page2'nin index'inin 1 olduunu bilmelisiniz. Aadaki kodu yazn. Private Sub MultiPage1_Click(ByVal Index As Long) Select Case Index Case 0 makro1 Case 1 makro2 End Select End Sub Private Sub UserForm_Initialize() MultiPage1.Value = 0 End Sub Private Sub MultiPage1_Click(ByVal Index As Long) If Index = 1 Then CommandButton6.Enabled = False CommandButton7.Enabled = False sor = InputBox("FREY GRNZ", "FRE GR") If sor = "ifre" Then CommandButton6.Enabled = True CommandButton7.Enabled = True Exit Sub End If MsgBox "HATALI FRE" End If End Sub Private Sub CommandButton1_Click() MultiPage1.Value = MultiPage1.Value + 1 End Sub '// Birinci sayfayi gosterir MultiPage1.Value = 0 '// Ikinci sayfayi gosterir MultiPage1.Value = 1 Userforma bir scrollbar ekleyin ve aadaki kodu scrollbara yazn. Private Sub ScrollBar1_Change() MultiPage1.Value = ScrollBar1.Value End Sub 'Eer hep page alsn diyorsanz, bu durumda hangi nesneyi kullanyorsanz ona aadaki kodu yazmak yeterlidir.
MultiPage1.Value = 2 Gerekten bu durum ok enterasan. Form zerinde hereyi yapabiliyorsunuz fakat MultiPage nesnesinin zemin rengini deitirmek iin bir zelliin olmad Bu durumda sorulan sorunun cevabn bir kurnazlk yaparak bulmak gerekiyor.
Tm kontrolleri yerletirdikten sonra MultiPage nesnesi zerine bir Image nesnesi yerletirin ve tm kontrollerin altna gnderin ve Image nesnesinin zem Bu ilemi en son yapn ki dzenlemelerde bir sorunla karlamayn.
Private Sub MultiPage1_Click(ByVal Index As Long) Select Case Index Case 0: Sheets(1).Select Case 1: Sheets(2).Select End Select End Sub Private Sub MultiPage1_Click(ByVal Index As Long) Select Case Index Case 0: Sheets(1).Select Case 1: Sheets(2).Select End Select End Sub Bir alandaki deerlerin toplam formln sayfadaki herhangi bir ccreye yazdrr. Sub addAmtAbs() Set myRange = Range("A1:A3") myCount = Application.Count(myRange) ActiveCell.Formula = "=SUM(A1:A" & myCount & ")" End Sub
Dim nCtlP As CommandBarPopup, nCtlB As CommandBarButton For Each CmdB In Application.CommandBars If CmdB.Type = msoBarTypeMenuBar And _ CmdB.Name = "Meine Menueleiste" Then CmdB.Delete End If Next CmdB Set nCmdB = Application.CommandBars.Add _ (Name:="Meine Menueleiste", Position:=msoBarTop, _ MenuBar:=True, Temporary:=True) With nCmdB .Protection = msoBarNoMove .Protection = msoBarNoChangeDock .Protection = msoBarNoChangeVisible .Protection = msoBarNoCustomize .Protection = msoBarNoVerticalDock .Visible = True End With Set nCtlP = nCmdB.Controls.Add(Type:=msoControlPopup) With nCtlP .Caption = "Mein Menue &1" End With Set nCtlB = nCtlP.Controls.Add(ID:=247) With nCtlB .Style = msoButtonCaption End With Set nCtlB = nCtlP.Controls.Add(ID:=109) With nCtlB .Style = msoButtonAutomatic End With Set nCtlB = nCtlP.Controls.Add(ID:=4) With nCtlB .BeginGroup = True .Style = msoButtonAutomatic End With Set nCtlP = nCmdB.Controls.Add(Type:=msoControlPopup) With nCtlP .Caption = "Mein Menue &2" End With Set nCtlB = nCtlP.Controls.Add(ID:=1) With nCtlB .Caption = "Mein VBA-Makro &1" .OnAction = "Me_001_Code01" .Style = msoButtonCaption End With Set nCtlB = nCtlP.Controls.Add(ID:=1) With nCtlB .BeginGroup = True .FaceId = 239 .Caption = "Mein VBA-Makro &2" .OnAction = "Me_001_Code02" .Style = msoButtonIconAndCaption End With End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Call Me_001_Delete End Sub Public Sub Me_001_Code01() MsgBox "Die Option 'Mein VBA-Makro 1' wurde gewhlt!", _ vbInformation, "Code-Beispiel (Me_001)" End Sub Public Sub Me_001_Code02() MsgBox "Die Option 'Mein VBA-Makro 2' wurde gewhlt!", _ vbInformation, "Code-Beispiel (Me_001)" End Sub Public Sub Me_001_Delete() On Error Resume Next Application.CommandBars("Meine Menueleiste").Delete On Error GoTo 0 End Sub
Private Declare Function mciSendString Lib "winmm.dll" Alias _ "mciSendStringA" (ByVal lpstrCommand As String, ByVal _ lpstrReturnString As String, ByVal uReturnLength As Long, _ ByVal hwndCallback As Long) As Long Private isPlaying As Boolean Public Sub Ap_002_Play() Dim mp3File As String 'Dim mp3File$ mp3File = Chr$(34) & "C:\mp3\muamma.mp3" & Chr$(34) If isPlaying = True Then Call mciSendString("Stop MM", 0&, 0&, 0&) Call mciSendString("Close MM", 0&, 0&, 0&) Call mciSendString("Open " & mp3File & " Alias MM", 0&, 0&, 0&) Call mciSendString("Play MM", 0&, 0&, 0&) Else Call mciSendString("Open " & mp3File & " Alias MM", 0&, 0&, 0&) Call mciSendString("Play MM", 0&, 0&, 0&) isPlaying = True End If End Sub Public Sub Ap_002_Stop() If isPlaying = False Then Exit Sub Call mciSendString("Stop MM", 0&, 0&, 0&) Call mciSendString("Close MM", 0&, 0&, 0&) End Sub
Dim nCtlB As CommandBarButton For Each CmdB In Application.CommandBars If CmdB.Type = msoBarTypePopup And _ CmdB.Name = "Mein Kontextmenue" Then CmdB.Delete End If Next CmdB Set nCmdB = Application.CommandBars.Add _ (Name:="Mein Kontextmenue", Position:=msoBarPopup, _ Temporary:=True) Set nCtlB = nCmdB.Controls.Add(ID:=1) With nCtlB .Caption = "Mein VBA-Makro &1" .OnAction = "Me_002_Code" .Style = msoButtonCaption End With Set nCtlB = nCmdB.Controls.Add(ID:=1) With nCtlB .FaceId = 239 .Caption = "Mein VBA-Makro &2" .OnAction = "Me_002_Code" .Style = msoButtonIconAndCaption End With Set nCtlB = nCmdB.Controls.Add(ID:=247) With nCtlB .BeginGroup = True .Style = msoButtonCaption End With Set nCtlB = nCmdB.Controls.Add(ID:=109) With nCtlB .Style = msoButtonAutomatic End With Set nCtlB = nCmdB.Controls.Add(ID:=4) With nCtlB .BeginGroup = True .Style = msoButtonAutomatic End With End Sub Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, _ ByVal Target As Excel.Range, Cancel As Boolean) Cancel = True On Error GoTo Fehler Application.CommandBars("Mein Kontextmenue").ShowPopup Exit Sub Fehler: Cancel = False End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Call Me_002_Delete End Sub Public Sub Me_002_Code() MsgBox "Die Option 'Mein VBA-Makro " & _ Application.CommandBars("Mein Kontextmenue") _ .Controls(Application.Caller(1)).Index & _ "' wurde gewhlt!", _ vbInformation, "Code-Beispiel (Me_002)" End Sub Public Sub Me_002_Delete() On Error Resume Next Application.CommandBars("Mein Kontextmenue").Delete On Error GoTo 0 End Sub
Dim i As Byte, sat As Long Sheets("Kayt Giri").Select Set s1 = Sheets("ARV") Set s2 = Sheets("Kayt Giri") kod = s2.[c4] Set varm = s1.Range("b3:b65536").Find(kod) If varm Is Nothing Then sat = s1.Cells(65536, "B").End(xlUp).Row + 1 Else sat = s1.Range("b3:b65536").Find(kod).Row mevcut=1 End If s1.Cells(sat, "A").Value = sat - 2 For i = 4 To 28 s1.Cells(sat, i - 2).Value = Cells(i, "C").Value Next i Set s1 = Nothing Set s2 = Nothing if mevcut=1 then MsgBox "Deitirildi" else MsgBox "Desen bilgileri eklendi..!!" end if Private Sub CommandButton2_Click() For Each ayni In Range("b2:b1000") If ayni.Value = CStr(TextBox2.Value) Then DUR4 = MsgBox("GRM OLDUUNUZ VERG NUMARASI KAYITLARDA BULUNMAKTADIR", vbYes, "YANLI") TextBox2.Value = "" Exit Sub End If Next End Sub Private Sub CommandButton1_Click() If TextBox2.Value <> "" Then Sheets("Sayfa1").Activate Cells(1, 1).Select Do While ActiveCell.Value <> "" If Trim(ActiveCell.Value) = Trim(Me.TextBox1.Value) Then If MsgBox(Me.TextBox1 & " isimli ii kaytl" & " Yeniden kayt yaplsn m?", vbYesNo) = vbNo Then Exit Sub End If ActiveCell.Offset(1, 0).Activate Loop ActiveCell.Value = TextBox1.Value ActiveCell.Offset(0, 1).Value = TextBox2.Value End If End Sub Sub ift_kaytlar_kaldr() Cells.Sort Key1:=Range("A1") totalrows = ActiveSheet.UsedRange.Rows.Count Count = 1 For Row = totalrows To 2 Step -1 If Cells(Row, 1).Value = Cells(Row - 1, 1).Value Then Rows(Row).Delete Count = Count + 1 End If Next Row End Sub Sub RemoveDuplicates() Cells.Sort Key1:=Range("A1") totalrows = ActiveSheet.UsedRange.Rows.Count Count = 1 For Row = totalrows To 2 Step -1 If Cells(Row, 1).Value = Cells(Row - 1, 1).Value Then Rows(Row).Delete Count = Count + 1 Else Cells(Row, 3).Value = Count Count = 1 End If Next Row Cells(1, 3).Value = Count End Sub
Sub mukerrer() For a = 1 To [a65536].End(xlUp).Row If WorksheetFunction.CountIf(Columns(1), Cells(a, 1)) > 1 Then Cells(a, 1).Interior.ColorIndex = 3 Next End Sub Sub SommeNgative() For Each Cell In Range("A1:A10") If Cell.Value < 0 Then total = total + Cell End If Next MsgBox "Total des valeurs ngatives " & total Range("A11") = total End Sub Nesne deikeni kullanmak kodlarn daha hzl ve anlalabilir olmasn salar. Bir nesne deikeni oluturmak iin Set parametresi kullanlr. 'Normal deiken atamas: 'Dependents = Workbooks("Taxbook").Worksheets("Sheet1").Range("A5").Value 'Nesne deikeni atamas: 'Dim Dependents as Range 'Set Dependents = Workbooks("Taxbook").Worksheets("Sheet1").Range("A5") 'Nesne deikeni atamas yapldktan sonra bu gerek bir nesne gibi alr. Mesela, A5 hcresindeki deer aadaki ifadeyle deitirilebilir: 'Dependents.Value = 3 'Aadaki kodlarla normal deikenle, nesne deikeni arasndaki hz farkn gsteren bir test yaplmtr. Sub Macro1() ' no object variable, daha yava Dim i As Integer StartTime = Timer For i = 1 To 5000 ThisWorkbook.Sheets("Sayfa1").Range("A1:B12").Value = i Next i MsgBox Timer - StartTime End Sub Sub Macro2() ' with object variable, daha hzl Dim i As Integer Dim MyCell As Range StartTime = Timer Set MyCell = ThisWorkbook.Sheets("Sayfa1").Range("A1:B12") For i = 1 To 5000 MyCell.Value = i Next i MsgBox Timer - StartTime End Sub Sub Dialog_41() Application.Dialogs(xlDialogInsertObject).Show End Sub zerinde dndm tam bir zm olmasada u ekilde yaplabilir. Sorunuz ok daha iyi neriler kacaktr mutlaka.
textboxlarn bulunduu userformun iine aadaki kodu yaznz. Fakat bunu sadece userform_click olaynda gerekletirebildim. Yani formatlarn deitiril Kod: Private Sub UserForm_Click() For a = 1 To 16 UserForm1.Controls("TextBox" & a) = Format(UserForm1.Controls("TextBox" & a), "###.#######") Next a End Sub dier bir zmde;eer textboxlardan sonra rnein bir command buton seilecekse ayn kodlar bu butonun iine yazlabilir. Kod: Private Sub CommandButton1_Enter() For a = 1 To 16 UserForm1.Controls("TextBox" & a) = Format(UserForm1.Controls("TextBox" & a), "###.#######") Next a End Sub Baka nerileri akas bende merakla bekliyorum.
Dim strCurrentPrinter As String, strNetworkPrinter As String strNetworkPrinter = GetFullNetworkPrinterName("HP LaserJet 8100 Series PCL") If Len(strNetworkPrinter) > 0 Then ' found the network printer strCurrentPrinter = Application.ActivePrinter ' change to the network printer Application.ActivePrinter = strNetworkPrinter Worksheets(1).PrintOut ' print something ' change back to the previously active printer Application.ActivePrinter = strCurrentPrinter End If End Sub Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String ' returns the full network printer name ' returns an empty string if the printer is not found ' e.g. GetFullNetworkPrinterName("HP LaserJet 8100 Series PCL") ' might return "HP LaserJet 8100 Series PCL on Ne04:" Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long strCurrentPrinterName = Application.ActivePrinter i=0 Do While i < 100 strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":" On Error Resume Next ' try to change to the network printer Application.ActivePrinter = strTempPrinterName On Error GoTo 0 If Application.ActivePrinter = strTempPrinterName Then ' the network printer was found GetFullNetworkPrinterName = strTempPrinterName i = 100 ' makes the loop end End If i=i+1 Loop ' remove the line below if you want the function to change the active printer Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer End Function
Sub normal() Application.DisplayFullScreen = False End Sub Public id Sub starten() id = Shell(Range("A1").Value, vbNormalFocus) End Sub Sub beenden() AppActivate id SendKeys "%{F4}", True End Sub NOT DEFTERN ALITIRIR Sub notdefteri() Call Shell("notepad.exe.", 1) End Sub NOT DEFTERN ALITIRIR Sub notdefteri() Call Shell("notepad.exe.", 1) End Sub Sub externesProgrammAusExcelAufrufen() Status = Shell("notepad.exe", 1) End Sub 'notepad.exe 'Calc.exe = 'MSPaint.exe 'sol.exe Shell "notepad.exe c:\foldername\filename.txt", vbMaximizedFocus
Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim chemXlt As String chemXlt = Application.TemplatesPath & "NumAuto.xlt" If ActiveWorkbook.Path = "" Then Workbooks.Open (chemXlt) [NumFact] = [NumFact] - 1 ActiveWorkbook.Close True End If End Sub Private Sub Workbook_Open() If ActiveWorkbook.Path = "" Then [NumFact] = [NumFact] + 1 ActiveWorkbook.Saved = True ActiveWorkbook.SaveCopyAs _ Application.TemplatesPath & "NumAuto.xlt" End If End Sub Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByValbScan As Byte, ByVal dwFlags As Long, _ ByVal dwExtraInfo As Long) Public Const VK_NUMLOCK = &H90 Sub Num_Lock_On() keybd_event VK_NUMLOCK, 1, 0, 0 End Sub Sub Num_Lock_Off() keybd_event VK_NUMLOCK, 0, 0, 0 End Sub Sub Test() Dim objShell As Object, MyFolder As Object, SysFolder As Object Dim FSO As Object Dim Sys32Path As String, MyOcx As String Set objShell = CreateObject("Shell.Application") Set MyFolder = objShell.Namespace(&H25&) Set SysFolder = MyFolder.Self Sys32Path = SysFolder.Path & Application.PathSeparator MyOcx = ThisWorkbook.Path & "\Ocx\Test.ocx" If Dir(MyOcx) = Empty Then MsgBox MyOcx & " bulunamad, kontrol edin !" Exit Sub End If Set FSO = CreateObject("Scripting.FileSystemObject") FSO.CopyFile MyOcx, Sys32Path Set FSO = Nothing Set SysFolder = Nothing Set MyFolder = Nothing Set objShell = Nothing End Sub Sub assist() Application.Assistant.Visible = True Assistant.Animation = msoAnimationIdle Set SB = Assistant.NewBalloon SB.Animation = msoAnimationCheckingSomething SB.BalloonType = msoBalloonTypeButtons SB.Heading = " H A L L O ! ! ! " SB.Text = _ "Ich bin Dein persnlicher Assistent" If SB.Show = msoBalloonButtonOK Then Assistant.Visible = False End If End Sub
Sub assist() Application.Assistant.Visible = True Assistant.Animation = msoAnimationIdle Set SB = Assistant.NewBalloon SB.Animation = msoAnimationCheckingSomething SB.BalloonType = msoBalloonTypeButtons SB.Heading = "istediiniz uyar!!" SB.Text = "Ben senin kiisel yardmcnm :)" If SB.Show = msoBalloonButtonOK Then Assistant.Visible = False End If End sub TextBox13.Value = TextBox1*1 + TextBox2*1 + TextBox3*1+........ Public RunWhen As Double Public Const cRunIntervalSeconds = 120 ' 2 dakika Public Const cRunWhat = "The_Sub" Sub StartTimer() ' Timer' balatr RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _ schedule:=True End Sub Sub The_Sub() ' Buraya kodlar yazlacak StartTimer ' Tekrar etmesi iin End Sub Sub StopTimer() ' Timer' durdurur On Error Resume Next Application.OnTime earliesttime:=RunWhen, _ procedure:=cRunWhat, schedule:=False End Sub Public RunWhen As Variant 'programmation horaire Public Const cRunIntervalSeconds = 30 ' 30 secondes Public Const cRunWhat = "LitMessage" 'nom de la sub excuter Sub LanceLeLecteurDeMessage() 'Programmation horaire = Maintenant + 30 secondes RunWhen = TimeValue(Now + TimeSerial(0, 0, cRunIntervalSeconds)) Application.OnTime RunWhen, cRunWhat End Sub Sub StoppeLeLecteurDeMessage() 'Arrte le process en lui repassant la dernire 'programmation horaire On Error Resume Next Application.OnTime RunWhen, cRunWhat, , False End Sub Sub LitMessage() Dim e 'ici le code "actif" toutes les 30 secondes e = MsgBox("Pas de nouveau message !" & vbLf _ & "Voulez-vous arrter la veille du rseau ?", _ vbQuestion + vbYesNo + vbDefaultButton2, _ "Vrification des messages") If e = 7 Then 'Clic sur NON 'Relancer le OnTime (et donc une nouvelle 'programmation horaire) LanceLeLecteurDeMessage Else 'Arrter le OnTime StoppeLeLecteurDeMessage End If End Sub Bu komutu kullandn zaman program iersinde kullandn deikenleri kullanmadan nce tipini tanmlamak zorundasn
Private Sub CommandButton2_Click() Application.Visible = True UserForm1.Hide ActiveSheet.PageSetup.PrintArea = "$A$1:$H$20" ActiveSheet.PrintPreview EnableChanges:=False ActiveSheet.PrintOut copies:=2, Preview:=False 'copies:=1 kopya saysn artrmak iin Application.Visible = False UserForm1.Show End Sub Aadaki gibi bir kodla kaldrabilirsiniz. visual basic kodu: -------------------------------------------------------------------------------OptionButton1.Value = False OptionButton2.Value = False . . . Private Sub OptionButton2_Click() If OptionButton2.Value = True Then 'iaretlediinde manuel girmesinler diye TextBox10.Enabled = False TextBox10.Value = "Dkman" Else TextBox10.Value = Empty End If End Sub Private Sub OptionButton1_Click() 'manuel girmeleri iin true TextBox10.Enabled = True TextBox10.Value = "" End Sub Aklama: alma Sayfanzda herhangi bir hcreye 1 yazdnzda bire karlk gelen Cmle otomatik yazlr (En hzl siz yazacaksnz ) Kod: Private Sub Worksheet_Change(ByVal Target As Excel.Range) If IsEmpty(Target) Then Exit Sub If Target = "1" Then Target = "le Milli Eitim Mdrl" If Target = "2" Then Target = "Ahmet Akn KKKAYA" If Target = "3" Then Target = "Ordu li Kabata lesi" If Target = "4" Then Target = "Kabata" End Sub Sub Dialog_07() Application.Dialogs(xlDialogAutoCorrect).Show End Sub Otomatik dzeltme listesini sayfada listeler. Sub Lire() Dim Corrliste Corrliste = Application.AutoCorrect.ReplacementList [A1].Resize(UBound(Corrliste, 1), 2) = Corrliste End Sub Sub Makro2() With Application .Calculation = xlManual End With End Sub Sub Makro3() With Application .Calculation = xlAutomatic End With End Sub Sub Makro4() Calculate End Sub
Dim RunWhen As Double Const RunWhat = "Info" ' Sub Auto_Open() StartTimer End Sub ' Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, 5) Application.OnTime earliesttime:=RunWhen, procedure:=RunWhat, schedule:=True End Sub ' Sub Info() ' Aadaki satrda yer alan MsgBox fonksiyonu yerine, ' altrlmasn istediiniz baka bir makronun adn yazarak ' o makronun altrlmasn salayabilirsiniz. MsgBox "Dikkat, sayfayi gncelleyin !" StartTimer End Sub ' Sub StopTimer() On Error Resume Next Application.OnTime earliesttime:=RunWhen, procedure:=RunWhat, schedule:=False End Sub ' Sub Auto_Close() StopTimer End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$B$8" And Target.Value = 20 Then Cells.Select Selection.Copy Worksheets.Add.Name = Range("A4") ActiveSheet.Paste ActiveWorkbook.Save End If End Sub =ALTTOPLAM(9;B3:B1000) Sub FilterAufheben() If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData End Sub Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Range) CommandButton1.Caption = Range("A1").Value & Chr(13) & Chr(13) & " gefilterte Zeilen" End Sub 'sayfadaki buton bura ile ilikilendirilecek Private Sub CommandButton1_Click() Filter_setzen CommandButton1.Caption = Range("A1").Value & Chr(13) & Chr(13) & " gefilterte Zeilen" End Sub 'modle Sub Filter_setzen() Range("c1").Select SendKeys "%{Down}" Range("D1").Select Range("C1").Select End Sub Sub SayfaSecOnceki() On Error Resume Next If ActiveSheet.Index = Worksheets.Count Then Worksheets(-1).Select Else Worksheets(ActiveSheet.Index - 1).Select End If End Sub Me.Hide Sheets("test").Select ActiveWindow.SelectedSheets.PrintPreview Me.Show
Private Sub CommandButton1_Click() Sheets("Sayfa1").Select With ActiveSheet.PageSetup .PaperSize = xlPaperA5: .CenterHorizontally = True: .Orientation = xlPortrait .Zoom = False: .FitToPagesWide = 1: .FitToPagesTall = 1 End With Unload Me ActiveWindow.SelectedSheets.PrintOut Copies:=1 End Sub Private Sub CommandButton1_Click() Sheets("Sayfa1").Select With ActiveSheet.PageSetup .PaperSize = xlPaperA5: .CenterHorizontally = True: .Orientation = xlPortrait .Zoom = False: .FitToPagesWide = 1: .FitToPagesTall = 1 End With Unload Me ActiveWindow.SelectedSheets.PrintOut Copies:=1 End Sub 'korunacak dosyalar baa ta Sheets("koru01").Move Sheets("koru02").Move Sheets("koru03").Move Sheets("koru04").Move Sheets("koru05").Move Before:=Sheets(1) Before:=Sheets(2) Before:=Sheets(3) Before:=Sheets(4) Before:=Sheets(5)
For i = Sheets.Count To 1 Step -1 'For i = 1 To Sheets.Count If Sheets(i).Name <> cs_kr1 And Sheets(i).Name <> cs_kr2 And _ Sheets(i).Name <> cs_kr3 And Sheets(i).Name <> cs_kr4 And _ Sheets(i).Name <> cs_kr5 Then Application.DisplayAlerts = False Sheets(i).Delete Application.DisplayAlerts = True Else Set s1 = Nothing: Set s2 = Nothing: Set s3 = Nothing: Set s4 = Nothing: Set s5 = Nothing: Exit Sub End If Next i MsgBox "Arivlenen dosyadan, " & vbCr & _ cs_kr1 & " / " & cs_kr2 & " / " & vbCr & _ cs_kr3 & " / " & cs_kr4 & " / " & vbCr & _ cs_kr5 & vbCr & " alma sayfalar silinmitir.", _ vbInformation, vbInformation, "BLG-01" End Sub korunmacak dosyalar sona ta sn = Sheets.Count Sheets("koru01").Move Sheets("koru02").Move Sheets("koru03").Move Sheets("koru04").Move Sheets("koru05").Move After:=Sheets(sn) After:=Sheets(sn) After:=Sheets(sn) After:=Sheets(sn) After:=Sheets(sn)
For i = Sheets.Count To 1 Step -1 'For i = 1 To Sheets.Count If Sheets(i).Name = cs_kr1 Then Application.DisplayAlerts = False: Sheets(i).Delete: Application.DisplayAlerts = True ElseIf Sheets(i).Name = cs_kr2 Then Application.DisplayAlerts = False: Sheets(i).Delete: Application.DisplayAlerts = True ElseIf Sheets(i).Name = cs_kr3 Then Application.DisplayAlerts = False: Sheets(i).Delete: Application.DisplayAlerts = True ElseIf Sheets(i).Name = cs_kr4 Then Application.DisplayAlerts = False: Sheets(i).Delete: Application.DisplayAlerts = True ElseIf Sheets(i).Name = cs_kr5 Then Application.DisplayAlerts = False: Sheets(i).Delete: Application.DisplayAlerts = True Else Set s1 = Nothing: Set s2 = Nothing: Set s3 = Nothing: Set s4 = Nothing: Set s5 = Nothing: Exit Sub End If Next i End Sub Sub Dateipfad() Worksheets(1).PageSetup.LeftFooter = ThisWorkbook.FullName End Sub Function iade2005(tutar) iade2005 = Round(Switch(tutar > 6600, (tutar - 6600) * 0.04 + 462, tutar > 3300, (tutar - 3300) * 0.06 + 264, tutar <= 3300, (tutar) * 0.08), 2) End Function
Sub Dialog_19() Application.Dialogs(xlDialogCustomViews).Show End Sub Sub zel_Klasr_smi_Al() Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.GetSpecialFolder(0) '0 Windows,1 Sistem,2 Geici Klasrlerinin yerini verir. MsgBox f End Sub Sub Pied_Page() Dim Repert As String Dim Fichier As String Repert = ActiveWorkbook.Path Fichier = ActiveWorkbook.Name With ActiveSheet.PageSetup .LeftFooter = Repert .RightFooter = Fichier End With End Sub Sub Euro() Selection.NumberFormat = "#,##0.00 " & ChrW(8364) End Sub Sub Euro0() Selection.NumberFormat = "#,##0 " & ChrW(8364) End Sub Sub EuroRot() Selection.NumberFormat = "#,##0.00 " & ChrW(8364) & " ;[RED]-#,##0.00 " & _ ChrW(8364) End Sub aadaki kod iinizi grecektir. Kod: For i = 2 To Cells(65536, 1).End(xlUp).Row son = 1 For j = 2 To Cells(1, 1).End(xlToRight).Column Cells(i, j) = Mid(Cells(i, 1), son, Cells(1, j)) son = son + Cells(1, j) Next j Next i
yapmanz gereken a2 den itibaren aa doru verilerinizi yaptrmak. ve b1, c1, d1, e1 ....... gerektii kadar alnmas gereken para boyutlarn girmek. y Sub FarkliKaydet() 'Application.DisplayAlerts = False Workbooks(ActiveWorkbook.Name).SaveAs Filename:=ThisWorkbook.FullName, FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _ False, CreateBackup:=True 'Application.DisplayAlerts = True End Sub
Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type Private Const MAX_PATH = 260 Private Const FILE_ATTRIBUTE_DIRECTORY = &H10 Private Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cFileName As String * MAX_PATH cAlternate As String * 14 End Type Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long Private nCount& 'Main code ================= Private Sub GetDirectoryListing(ByVal Root$) ' Function to calculate bytes used in Root$ and all subdirectories of Root$. ' Root$ should be entered in the form c:\Dir Dim FData As WIN32_FIND_DATA Dim fHand& Dim sPath$ Dim StillOK& Dim ByteTotal& Dim nPos% Dim DirName$, FileName$ sPath$ = Root$ + "\*.*" fHand& = FindFirstFile(sPath$, FData) If fHand& <= 0 Then Exit Sub End If ByteTotal& = 0 Do If (FData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then nPos% = InStr(FData.cFileName, Chr$(0)) DirName$ = Left$(FData.cFileName, nPos% - 1) If DirName$ <> "." And DirName$ <> ".." Then GetDirectoryListing Root$ + "\" + DirName$ End If Else nCount& = nCount& + 1 nPos% = InStr(FData.cFileName, Chr$(0)) FileName$ = Left$(FData.cFileName, nPos% - 1) Cells(nCount&, 1).Value = Root$ + "\" + FileName$ _ '>>>>>>>>>>>>>>>>>>>> '& gt;> ' If you don't want the path just use: ' Cells(nCount&,1).value = FileName$ End If StillOK& = FindNextFile(fHand&, FData) Loop Until StillOK = 0 fHand& = FindClose(fHand&) End Sub Public Sub GetFileList() Dim Path$ nCount& = 0 Path$ = InputBox("Enter the root for the file listing (e.g. 'c:\dir' orc:") If Len(Path$) = 0 Then Exit Sub GetDirectoryListing Path$ End Sub
size iki ayr seenek neriyorum rnek1: Sub Makro1() Range("A2").Select 10 ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate b = ActiveCell.Value satirno = ActiveCell.Row If b <> "" Then GoTo 10 End If Cells(satirno, 1) = Textbox1.Value End Sub rnek2: Sub Makro2() For a = 3 To 1000 b = Cells(a, 1).Value If b = "" Then Cells(a, 1) = Textbox1.Value GoTo 10 End If Next a 10 End Sub Sub kreisbogen() 'zeichnet Kreisbogen mit angegebenem Winkel Application.ScreenUpdating = False winkel = InputBox("Winkel ?") If winkel = Empty Or Not IsNumeric(winkel) Then Exit Sub ActiveSheet.Drawings.Add(100, 100, 100, 100, False) _ .Select For i = 0 To winkel k = 3.14159265358979 * i / 180 Selection.AddVertex 100 + 100 * Sin(k), 100 + 100 * Cos(k) i=i+1 Next Selection.AddVertex 100, 100 Application.ScreenUpdating = True End Sub Declare Function ExitWindowsEx& Lib "user32" _ (ByVal uFlags&, ByVal wReserved&) Global Global Global Global Const Const Const Const EWX_FORCE = 8 EWX_LOGOFF = 0 EWX_REBOOT = 2 EWX_SHUTDOWN = 1
Sub calistir() Dim Kapatma_Zamani As Variant Kapatma_Zamani = InputBox("Windows'un ne zaman kapanmasn istersiniz?", , _ Format(Now + TimeSerial(0, 1, 0), "hh:mm:ss")) If Kapatma_Zamani = "" Then Exit Sub Application.OnTime TimeValue(Kapatma_Zamani), "Windowsu_Kapat" End Sub Sub Windowsu_Kapat() Dim LResult LResult = ExitWindowsEx(EWX_SHUTDOWN, 0&) End Sub Sub BrowsePDFDocument() Dim strDocument As String strDocument = Application.GetOpenFilename("PDF Files,*.pdf,All Files,*.*", 1, "Open File", , False) ' get pdf document name If Len(strDocument) < 6 Then Exit Sub ActiveWorkbook.FollowHyperlink strDocument End Sub
Alias "GetTempFileNameA" (ByVal lpszPath As String, _ ByVal lpPrefixString As String, ByVal wUnique As Long, _ ByVal lpTempFileName As String) As Long Declare Function FindExecutable Lib "shell32.dll" _ Alias "FindExecutableA" (ByVal lpFile As String, _ ByVal lpDirectory As String, ByVal lpResult As String) As Long Function GetExecutablePath(strFileType As String) As String Dim strFileName As String, f As Integer, strExecutable As String, r As Long If Len(strFileType) = 0 Then Exit Function ' no file type strFileName = String$(255, " ") strExecutable = String$(255, " ") GetTempFileName CurDir, "", 0&, strFileName ' get a temporary file name strFileName = Application.Trim(strFileName) strFileName = Left$(strFileName, Len(strFileName) - 3) & strFileType ' add the given file type f = FreeFile Open strFileName For Output As #f ' create the temporary file Close #f r = FindExecutable(strFileName, vbNullString, strExecutable) ' look for an associated executable Kill strFileName ' remove the temporary file If r > 32 Then ' associated executable found strExecutable = Left$(strExecutable, InStr(strExecutable, Chr(0)) - 1) Else ' no associated executable found strExecutable = vbNullString End If GetExecutablePath = strExecutable End Function Sub OpenPDFDocument() Dim strDocument As String, strExecutable As String strDocument = Application.GetOpenFilename("PDF Files,*.pdf,All Files,*.*", 1, "Open File", , False) ' get pdf document name If Len(strDocument) < 6 Then Exit Sub strExecutable = GetExecutablePath("pdf") ' get the path to Acrobat Reader If Len(strExecutable) > 0 Then Shell strExecutable & " " & strDocument, vbMaximizedFocus ' open pdf document End If End PrintingTest() Sub Sub Dim sFileName As String 'Change here to an appropriate file name sFileName = "C:\V080506.pdf" 'Prints three copies. PrintPDF2 sFileName, 3 MsgBox "Data has been sent. " & vbLf & _ "Please close the instance of Acrobat Reader after printing." End Sub -------------------------------------------------------------------------------Sub PrintPDF2(ByVal FileName As String, Optional Copies As Long = 1) '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '++ Prints the PDF files using a command line. '++ Written by Masaru Kaji aka Colo '++ Syntax '++ FileName : Required String expression that specifies a file name '++ - may include directory or folder, and drive.. '++ Copies : Optional Long. The number of copies to print. '++ If omitted one copy is printed. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Const PrinterName As String = """Microsoft Office Document Image Writer""" Const DriverName As String = """Microsoft Office Document Image Writer""" Const PortName As String = """Microsoft Office Document Image Writer port:""" Dim cnt As Long Set myShell = CreateObject("WScript.Shell") For cnt = 1 To Copies myShell.Run ("AcroRd32.exe /t " & FileName & " " & PrinterName & " " & DriverName & " " & PortName) Next End Sub Sub Dialog_06() Application.Dialogs(xlDialogArrangeAll).Show End Sub
Sub ButunPencerelerMinimize() Dim Pencere As Window For Each Pencere In Windows If Pencere.Visible = False Then Pencere.Visible = True Pencere.WindowState = xlMinimized Next End Sub Sub GotoCol1() With Application ActiveWindow.FreezePanes = False Range("H1").Select ActiveWindow.FreezePanes = True .Goto Range("IV1") .Goto Range("Z1") End With End Sub Sub GotoCol2() With Application ActiveWindow.FreezePanes = False Range("H1").Select ActiveWindow.FreezePanes = True .Goto Reference:=Range("Z1"), Scroll:=True End With End Sub
Dim i As Long Dim lngStart As Long lngStart = Timer With Workbooks(1).Sheets(1) For i = 1 To 65536 .Cells(i, 1).Value = "Selamn Aleykm!" Next i End With MsgBox (Timer - lngStart) & " saniye" End Sub Sub performanstesti() Dim i As Long Dim lngStart As Long lngStart = Timer For i = 1 To 65536 ActiveWorkbook.Sheets(1).Cells(i, 1).Value = "Mahmut BAYRAM" Next i MsgBox (Timer - lngStart) & " Saniye Vay be!" End Sub Sub PerformanceTest() Dim i As Long Dim lngStart As Long Dim rngZellen As Range lngStart = Timer Set rngZellen = Workbooks(1).Sheets(1).Cells For i = 1 To 65536 rngZellen(i, 1).Value = "Hello World!" Next i MsgBox (Timer - lngStart) & " Sekunden" End Sub Sub PerformanceTest() Dim i As Long Dim lngStart As Long Dim rngZellen As Range lngStart = Timer Set rngZellen = Workbooks(1).Sheets(1).Range("A1:A65536").Rows rngZellen.Value = "Hello World!" MsgBox (Timer - lngStart) & " Sekunden" End Sub
Global rng, kosul As Range Global adres As String Function toplam(sht As Worksheet, malzeme As String, sart As String) Set rng = sht.Range("C3:C5000").Find(malzeme, Lookat:=xlWhole) Do If rng.Offset(0, 1) = sart Then toplam = toplam + rng.Offset(0, 2) Set rng = sht.Range(rng, Range("C5000")).FindNext If rng.Address = adres Then Exit Do adres = rng.Address Loop Set rng = Nothing End Function Sub gncelle() Dim ara As String Set kosul = Range(InputBox("Gncellenecek tarihin hcre adresini girin")) Application.ScreenUpdating = False ara = ActiveSheet.Name Set Set Set Set Set kitap = ThisWorkbook siparisler = Workbooks.Open("G:\Deneme\Sipari.xls") sevkiyat = Workbooks.Open("G:\Deneme\Sevkiyat.xls") hammadde = Workbooks.Open("G:\Deneme\Hammadde.xls") emirler = Workbooks.Open("G:\Deneme\Emirler.xls")
siparisler.Activate kosul.Offset(0, 1) = toplam(siparisler.Sheets("Gnlk"), ara, kosul.Value) hammadde.Activate kosul.Offset(0, 2) = toplam(hammadde.Sheets("Gnlk"), ara, kosul.Value) sevkiyat.Activate kosul.Offset(0, 3) = toplam(sevkiyat.Sheets("Gnlk"), ara, kosul.Value) emirler.Activate kosul.Offset(0, 4) = toplam(emirler.Sheets("Gnlk"), ara, kosul.Value) siparisler.Close False hammadde.Close False sevkiyat.Close False emirler.Close False kitap.Activate End Sub Sub Makro2() Dim tablo As PivotTable Dim alan As PivotField For Each tablo In ActiveSheet.PivotTables For Each alan In tablo.DataFields alan.Function = xlCount Next Next End Sub Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.PivotTables("PivotTable4").RefreshTable End Sub Sub Refresh_Pivot() ActiveSheet.PivotTables("PivotTable").PivotSelect "b", xlDataAndLabel ActiveSheet.PivotTables("PivotTable").RefreshTable End Sub ActiveSheet.PivotTables("PivotTable").RefreshTable Private Sub ConnectionApp_PivotTableOpenConnection(ByVal Target As PivotTable) MsgBox "The PivotTable connection has been opened." End Sub Private Sub ConnectionApp_PivotTableCloseConnection(ByVal Target As PivotTable) MsgBox "The PivotTable connection has been closed." End Sub
For Each wks In Worksheets For Each pt In wks.PivotTables pt.RefreshTable Next pt Next wks End Sub Sub Refresh_Pivot() ActiveSheet.PivotTables("PivotTable").PivotSelect "b", xlDataAndLabel ActiveSheet.PivotTables("PivotTable").RefreshTable End Sub Sub Dme1_Tklat() Range("A1") = Range("A1") + 1 ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _ :=True Range("A1") = Range("A1") + 1 ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _ :=True End Sub Alttaki prosedr kullanldnda anahtar butonlar nizleme penceresinde gzkmeyecektir. Sub PrtPvw() ActiveSheet.PrintPreview False 'False, Deiiklie izin vermez. ActiveWindow.View = xlNormalView End Sub Sub Auto_Open() Msgbox "Hello" End Sub Sub kapa() MsgBox "Bu program pir dzenlemitir.", , "KAPATILIYOR" ActiveWorkbook.Close True End Sub Function Puan(Notu As Integer) Select Case Notu Case Is > 100: Puan = "Hatal not" Case Is >= 90: Puan = "AA" Case Is >= 85: Puan = "BA" Case Is >= 75: Puan = "BB" Case Is >= 70: Puan = "CB" Case Is >= 60: Puan = "CC" Case Is >= 55: Puan = "DC" Case Is >= 50: Puan = "DD" Case Is >= 40: Puan = "FD" Case Is >= 0: Puan = "FF" Case Else: Puan = "Hatal not" End Select End Function 'puan(b2) eklinde kullanlacaktr. Bu fonksiyonlar imdilik sadece bu dosyada alacaktr. Baka bir dosya aldnda bu fonkisyon Kullac Tanml foksiyo
'Dosyamz kaydettikten sora Excel'i kapatp tekrar aalm. Aralar ->Eklentiler mensne tklayalm ve eklentiler penceresinden kaydettiimiz dosyann ism
'Burada xlstart klasrnden de bahsetmek yerinde olacaktr. XLSTART klasrne kaydedilen excel dosyalar Excel her altrldnda otomatik olarak alr
Dim y$(9) Dim m$(4) Dim v(15) Dim c(3) b$(0) b$(1) b$(2) b$(3) b$(4) b$(5) b$(6) b$(7) b$(8) b$(9) y$(0) y$(1) y$(2) y$(3) y$(4) y$(5) y$(6) y$(7) y$(8) y$(9) = "" = "Bir" = "ki" = "" = "Drt" = "Be" = "Alt" = "Yedi" = "Sekiz" = "Dokuz" = "" = "On" = "Yirmi" = "Otuz" = "Krk" = "Elli" = "Altm" = "Yetmi" = "Seksen" = "Doksan" = "Trilyon" = "Milyar" = "Milyon" = "Bin" = ""
a$ = Str(sayi) If Left$(a$, 1) = " " Then pozitif = 1 Else pozitif = 0 a$ = Right$(a$, Len(a$) - 1) For x = 1 To Len(a$) If (Asc(Mid$(a$, x, 1)) > Asc("9")) Or (Asc(Mid$(a$, x, 1)) < Asc("0")) Then GoTo hata Next x If Len(a$) > 15 Then GoTo hata a$ = String(15 - Len(a$), "0") + a$ For x = 1 To 15 v(x) = Val(Mid$(a$, x, 1)) Next x s$ = "" For x = 0 To 4 c(1) = v((x * 3) + 1) c(2) = v((x * 3) + 2) c(3) = v((x * 3) + 3) If c(1) = 0 Then e$ = "" ElseIf c(1) = 1 Then e$ = "Yz" Else e$ = b$(c(1)) + "Yz" End If e$ = e$ + y$(c(2)) + b$(c(3)) If e$ <> "" Then e$ = e$ + m$(x) If (x = 3) And (e$ = "BirBin") Then e$ = "Bin" s$ = s$ + e$ Next x If s$ = "" Then s$ = "Sfr" If pozitif = 0 Then s$ = "Eksi" + s$ yaz$ = s$ GoTo tamam hata: yaz$ = "Hata" tamam: End Function
Function yaziyla(sayi As Currency) As String Dim b(9) As String Dim y(9) As String Dim m(4) As String Dim v(15) Dim c(3) b(0) b(1) b(2) b(3) b(4) b(5) b(6) b(7) b(8) b(9) y(0) y(1) y(2) y(3) y(4) y(5) y(6) y(7) y(8) y(9) = "" = "Bir" = "ki" = "" = "Drt" = "Be" = "Alt" = "Yedi" = "Sekiz" = "Dokuz" = "" = "On" = "Yirmi" = "Otuz" = "Krk" = "Elli" = "Altm" = "Yetmi" = "Seksen" = "Doksan" = "Trilyon " = "Milyar " = "Milyon " = "Bin " = ""
a$ = Str(sayi) If Left$(a$, 1) = " " Then pozitif = 1 Else pozitif = 0 a$ = Right$(a$, Len(a$) - 1) For x = 1 To Len(a$) If (Asc(Mid$(a$, x, 1)) > Asc("9")) Or (Asc(Mid$(a$, x, 1)) < Asc("0")) Then GoTo hata Next x If Len(a$) > 15 Then GoTo hata a$ = String(15 - Len(a$), "0") + a$ For x = 1 To 15 v(x) = Val(Mid$(a$, x, 1)) Next x s$ = "" For x = 0 To 4 c(1) = v((x * 3) + 1) c(2) = v((x * 3) + 2) c(3) = v((x * 3) + 3) If c(1) = 0 Then e$ = "" ElseIf c(1) = 1 Then e$ = "Yz" Else e$ = b(c(1)) + "Yz" End If e$ = e$ + y(c(2)) + b(c(3)) If e$ <> "" Then e$ = e$ + m(x) If (x = 3) And (e$ = "BirBin ") Then e$ = "Bin" s$ = s$ + e$ Next x If s$ = "" Then s$ = "Sfr" If pozitif = 0 Then s$ = "Eksi " + s$ yaziyla = s$ GoTo tamam hata: yaziyla = "Hata" tamam: End Function
sayi(0, 1) = "": sayi(0, 2) = "": sayi(0, 3) = "" sayi(1, 1) = "YZ": sayi(1, 2) = "ON": sayi(1, 3) = "BR" sayi(2, 1) = "KYZ": sayi(2, 2) = "YRM": sayi(2, 3) = "K" sayi(3, 1) = "YZ": sayi(3, 2) = "OTUZ": sayi(3, 3) = "" sayi(4, 1) = "DRTYZ": sayi(4, 2) = "KIRK": sayi(4, 3) = "DRT" sayi(5, 1) = "BEYZ": sayi(5, 2) = "ELL": sayi(5, 3) = "BE" sayi(6, 1) = "ALTIYZ": sayi(6, 2) = "ALTMI": sayi(6, 3) = "ALTI" sayi(7, 1) = "YEDYZ": sayi(7, 2) = "YETM": sayi(7, 3) = "YED" sayi(8, 1) = "SEKZYZ": sayi(8, 2) = "SEKSEN": sayi(8, 3) = "SEKZ" sayi(9, 1) = "DOKUZYZ": sayi(9, 2) = "DOKSAN": sayi(9, 3) = "DOKUZ" basamak(5) = "TRLYON" basamak(4) = "MLYAR" basamak(3) = "MLYON" basamak(2) = "BN" basamak(1) = "" lira = Int(rakam) kurus = Round(rakam - lira, 2) * 100 If Len(lira) > 15 Then MsgBox ("Bu fonksiyon en fazla 15 haneli saylar iin alr.") End End If kalan = lira yaziyacevir = "" For x = 1 To 5 a = 15 - 3 * x If Len(lira) > a Then grup(6 - x) = Int(kalan / 10 ^ a) kalan = kalan - (grup(6 - x) * 10 ^ a) End If Next x If grup(5) > 0 Then oku(1) = Int(grup(5) / 100) baskalan = grup(5) - oku(1) * 100 oku(2) = Int(baskalan / 10) oku(3) = baskalan - oku(2) * 10 yaziyacevir = sayi(oku(1), 1) + sayi(oku(2), 2) + sayi(oku(3), 3) + basamak(5) End If If grup(4) > 0 Then oku(1) = Int(grup(4) / 100) baskalan = grup(4) - oku(1) * 100 oku(2) = Int(baskalan / 10) oku(3) = baskalan - oku(2) * 10 yaziyacevir = yaziyacevir + sayi(oku(1), 1) + sayi(oku(2), 2) + sayi(oku(3), 3) + basamak(4) End If If grup(3) > 0 Then oku(1) = Int(grup(3) / 100) baskalan = grup(3) - oku(1) * 100 oku(2) = Int(baskalan / 10) oku(3) = baskalan - oku(2) * 10 yaziyacevir = yaziyacevir + sayi(oku(1), 1) + sayi(oku(2), 2) + sayi(oku(3), 3) + basamak(3) End If If grup(2) = 1 Then yaziyacevir = yaziyacevir + "BN" End If If grup(2) > 1 Then oku(1) = Int(grup(2) / 100) baskalan = grup(2) - oku(1) * 100 oku(2) = Int(baskalan / 10) oku(3) = baskalan - oku(2) * 10 yaziyacevir = yaziyacevir + sayi(oku(1), 1) + sayi(oku(2), 2) + sayi(oku(3), 3) + basamak(2) End If If grup(1) > 0 Then oku(1) = Int(grup(1) / 100) baskalan = grup(1) - oku(1) * 100 oku(2) = Int(baskalan / 10) oku(3) = baskalan - oku(2) * 10 yaziyacevir = yaziyacevir + sayi(oku(1), 1) + sayi(oku(2), 2) + sayi(oku(3), 3) + basamak(1) End If yaziyacevir = yaziyacevir + " YTL." If kurus > 0 Then oku(2) = 0 If Len(kurus) > 1 Then
Option Explicit '**************** ' Main Function * '**************** Function SpellNumber(ByVal MyNumber) Dim Dollars, Cents, Temp Dim DecimalPlace, Count ReDim Place(9) As String Place(2) = " Thousand " Place(3) = " Million " Place(4) = " Billion " Place(5) = " Trillion " ' String representation of amount MyNumber = Trim(Str(MyNumber)) ' Position of decimal place 0 if none DecimalPlace = InStr(MyNumber, ".") 'Convert cents and set MyNumber to dollar amount If DecimalPlace > 0 Then Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2)) MyNumber = Trim(Left(MyNumber, DecimalPlace - 1)) End If Count = 1 Do While MyNumber <> "" Temp = GetHundreds(Right(MyNumber, 3)) If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars If Len(MyNumber) > 3 Then MyNumber = Left(MyNumber, Len(MyNumber) - 3) Else MyNumber = "" End If Count = Count + 1 Loop Select Case Dollars Case "" Dollars = "No Dollars" Case "One" Dollars = "One Dollar" Case Else Dollars = Dollars & " Dollars" End Select Select Case Cents Case "" Cents = " and No Cents" Case "One" Cents = " and One Cent" Case Else Cents = " and " & Cents & " Cents" End Select SpellNumber = Dollars & Cents End Function '******************************************* ' Converts a number from 100-999 into text * '******************************************* Private Function GetHundreds(ByVal MyNumber) Dim Result As String If Val(MyNumber) = 0 Then Exit Function MyNumber = Right("000" & MyNumber, 3) 'Convert the hundreds place If Mid(MyNumber, 1, 1) <> "0" Then Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred " End If 'Convert the tens and ones place If Mid(MyNumber, 2, 1) <> "0" Then Result = Result & GetTens(Mid(MyNumber, 2)) Else Result = Result & GetDigit(Mid(MyNumber, 3)) End If
148 Nolu D Genelge ile ilgilyse alman,TextBoxlarda deil Hcrelerde bu ilemi yapman tavsiye ederim.stediin Kod; Kod: Private Sub TextBox1_Change() TextBox1.Text = Format(TextBox1.Text, "0000") End Sub Private Sub CommandButton1_Click() Dim a As Integer Sheets("liste").Select Columns("a:m").Copy Sheets("raporlama").Select Columns("a").PasteSpecial Application.CutCopyMode = False Sheets("liste").Select For a = 13 To 1 Step -1 If Controls("checkbox" & a).Value = False Then Sheets("raporlama").Columns(a).Delete Next End Sub Sub RandomNumbers() Dim Number() Dim MyRange As Range Dim c As Range Set MyRange = Selection LastNumber = 100000 ReDim Number(LastNumber) For i = 1 To LastNumber Number(i) = i Next i For Each c In MyRange Placement = Int(Rnd() * LastNumber + 1) c.Value = Number(Placement) dummy = Number(LastNumber) Number(LastNumber) = Number(Placement) Number(Placement) = dummy LastNumber = LastNumber - 1 Next c End Sub Sub Kura_Sonuc() For i = 1 To 15 'Kuraya Katlacak Kii says Randomize MsgBox Int(Rnd(1) * 100) 'Kuraya Katlacak Kii Says Next End Sub Sub RandomNo() Randomize MyNumber = Int((49 - 1 + 1) * Rnd + 1) MsgBox ("The random number is ") & (MyNumber) End Sub Sub Aleatoire() Dim NbreAlea As Integer Randomize NbreAlea = Int((10 * Rnd) + 1) Range("A1") = NbreAlea End Sub
Evvvel D1 hcresine retmek istediiniz rakamlarn st snrn yaznz. D2 hcresine ise ka adet say reteceinizi yaznz. Sub rastgele() Dim i As Integer Dim bul As Range Randomize If Range("D1").Value < Range("D2") Then MsgBox "D1 hcresinin deeri D2 hcresinden kk olmamal" Exit Sub ElseIf Range("D1").Value = "" Or Range("D2") = "" Then MsgBox "Ama olmaz ki D1 ya da D2 Hcreleri bo olmaz" Exit Sub End If Cells(1, 1).Value = Int((Range("D1") * Rnd) + 1) For i = 2 To Range("D2") Cells(i, 1).Value = Int((Range("D1") * Rnd) + 1) For Each bul In Range("A1:A" & Cells(i - 1, 1).Row) If Cells(i, 1).Value = bul.Value Then Cells(i, 1).Value = Int((Range("D1") * Rnd) + 1) End If Next bul Next i End Sub Sub DEN() Dim MyValue MyValue = Int((6 * Rnd) + 1) MsgBox MyValue End Sub 1-49 arasnda rastgele say retmek. Sub RandomNo() Randomize MyNumber = Int((49 - 1 + 1) * Rnd + 1) MsgBox ("The random number is ") & (MyNumber) End Sub Sub Kura_Sonuc() For i = 1 To 15 'Kuraya Katlacak Kii says Randomize MsgBox Int(Rnd(1) * 100) 'Kuraya Katlacak Kii Says Next End Sub Sub RandomNumbers() Dim Number() Dim MyRange As Range Dim c As Range Set MyRange = Selection LastNumber = 100000 ReDim Number(LastNumber) For i = 1 To LastNumber Number(i) = i Next i For Each c In MyRange Placement = Int(Rnd() * LastNumber + 1) c.Value = Number(Placement) dummy = Number(LastNumber) Number(LastNumber) = Number(Placement) Number(Placement) = dummy LastNumber = LastNumber - 1 Next c End Sub Sub rast1() Dim rastgele As Integer ilk: rastgele = Int(Rnd() * 11) If rastgele <= 0 Or rastgele > 11 Then GoTo ilk If Cells(rastgele, 1).Interior.ColorIndex = 6 Then GoTo ilk Cells(rastgele, 1).Select Cells(rastgele, 1).Interior.ColorIndex = 6 End Sub
Sub Random() Dim Satir As Integer Static Say As Integer Static Dizi(1 To 10) If Say = 10 Then Say = 0: Erase Dizi devam: Randomize Satir = Int((Rnd * 10) + 1) If IsError(Application.Match(Satir, Dizi(), 0)) And Say < 10 Then Say = Say + 1 Dizi(Say) = Satir Cells(Satir, 1).Select Cells(Satir, 1).Interior.ColorIndex = 5 Else: GoTo devam End If End Sub Sub Rastgele() say = WorksheetFunction.CountA([A:A]) b = Int((say * Rnd) + 1) MsgBox Range("A" & b) Range("A" & b).EntireRow.Delete End Sub Sub referanskontrol() On Error GoTo 10 For a = 1 To ThisWorkbook.VBProject.References.Count aranan = ThisWorkbook.VBProject.References.Item(a).Name If aranan = "Outlook" Then MsgBox "ARANAN REFERANS ARETLDR" Exit Sub End If Next sor = MsgBox("REFERANS BULUNARAK ARETLENSN M?", vbYesNo) If sor = vbYes Then ThisWorkbook.VBProject.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 1, 0 MsgBox "REFERANS ARETLEND" Exit Sub 10 MsgBox "REFERANS MEVCUT DEL" End Sub Yazmak iin; Kod: Sub WriteReg() Dim WSH_Shell As Object RegKey = "HKCU\Software\Microsoft\Internet Explorer\Main\Ornek " Set WSH_Shell = CreateObject("WScript.Shell") WSH_Shell.RegWrite RegKey, 1, "REG_DWORD" End Sub Silmek iin; Kod: Sub DelReg() Dim WSH_Shell As Object RegKey = "HKCU\Software\Microsoft\Internet Explorer\Main\Ornek " Set WSH_Shell = CreateObject("WScript.Shell") WSH_Shell.RegDelete RegKey End Sub
Const HKEY_CURRENT_USER = &H80000001 Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As L Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Lon Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpRese Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Function RegQueryStringValue(ByVal hKey As Long, ByVal strValueName As String) As String Dim lResult As Long, lValueType As Long, strBuf As String, lDataBufSize As Long 'retrieve nformation about the key lResult = RegQueryValueEx(hKey, strValueName, 0, lValueType, ByVal 0, lDataBufSize) If lResult = 0 Then If lValueType = REG_SZ Then 'Create a buffer strBuf = String(lDataBufSize, Chr$(0)) 'retrieve the key's content lResult = RegQueryValueEx(hKey, strValueName, 0, 0, ByVal strBuf, lDataBufSize) If lResult = 0 Then 'Remove the unnecessary chr$(0)'s RegQueryStringValue = Left$(strBuf, InStr(1, strBuf, Chr$(0)) - 1) End If ElseIf lValueType = REG_BINARY Then Dim strData As Integer 'retrieve the key's value lResult = RegQueryValueEx(hKey, strValueName, 0, 0, strData, lDataBufSize) If lResult = 0 Then RegQueryStringValue = strData End If End If End If End Function Function GetString(hKey As Long, strPath As String, strValue As String) Dim Ret 'Open the key RegOpenKey hKey, strPath, Ret 'Get the key's content GetString = RegQueryStringValue(Ret, strValue) 'Close the key RegCloseKey Ret End Function Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String) Dim Ret 'Create a new key RegCreateKey hKey, strPath, Ret 'Save a string to the key RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData) 'close the key RegCloseKey Ret End Sub Sub SaveStringLong(hKey As Long, strPath As String, strValue As String, strData As String) Dim Ret 'Create a new key RegCreateKey hKey, strPath, Ret 'Set the key's value RegSetValueEx Ret, strValue, 0, REG_BINARY, CByte(strData), 4 'close the key RegCloseKey Ret End Sub Sub DelSetting(hKey As Long, strPath As String, strValue As String) Dim Ret 'Create a new key RegCreateKey hKey, strPath, Ret 'Delete the key's value RegDeleteValue Ret, strValue 'close the key RegCloseKey Ret End Sub Private Sub Command1_Click() Dim strString As String 'Ask for a value strString = InputBox("Please enter a value between 0 and 255 to be saved as a binary value in the registry.", App.Title) If strString = "" Or Val(strString) > 255 Or Val(strString) < 0 Then MsgBox "Invalid value entered ...", vbExclamation + vbOKOnly, App.Title Exit Sub End If 'Save the value to the registry SaveStringLong HKEY_CURRENT_USER, "KPD-Team", "BinaryValue", CByte(strString) End Sub Private Sub Command2_Click()
A stununa girilen say Renk indeksini ieren B stununda bulunursa, hcre o renge boyanr. Aadaki kodu sayfann kod sayfasna yaznz. alma Kitab Private Sub Worksheet_Change(ByVal Target As Range) Dim var As Variant If Target.Column <> 1 Then Exit Sub var = Application.Match(Target.Value, Worksheets("ColorIndex").Columns(1), 0) If Not IsError(var) Then Target.Interior.ColorIndex = Worksheets("ColorIndex").Cells(var, 2) End If End Sub y=0 g=0 p=0 oth = 0 For Each cell In Selection Select Case cell.Interior.ColorIndex Case 36 'yellow y=y+1 Case 35 'green g=g+1 Case 38 'pink p=p+1 Case Else oth = oth + 1 End Select Next cell msg = y & " Yellow" msg = msg & vbCrLf & g & " Green" msg = msg & vbCrLf & p & " Pink" msg = msg & vbCrLf & oth & " Other" msg = msg & vbCrLf & "Total: " & Selection.Count MsgBox (msg) End Sub Function SUMIFCOLOUR(TheRange As Range, TheColourCell As Range) As Variant Dim TempRange As Range Dim Result Dim Colour Application.Volatile On Error GoTo BailOut Colour = TheColourCell.Interior.Color For Each TempRange In TheRange If Colour = TempRange.Interior.Color Then Result = Result + TempRange.Value Next BailOut: SUMIFCOLOUR = Result End Function Function COUNTIFCOLOUR(TheRange As Range, TheColourCell As Range) As Varian Dim TempRange As Range Dim Result Dim Colour Application.Volatile On Error GoTo BailOut Colour = TheColourCell.Interior.Color For Each TempRange In TheRange If Colour = TempRange.Interior.Color Then Result = Result + 1 Next BailOut: COUNTIFCOLOUR = Result End Function Sub Dialog_12() Application.Dialogs(xlDialogColorPalette).Show End Sub
Option Explicit Sub macro1() Dim i As Long Dim j As Long Dim sVal Dim bHide As Boolean j = 65000 For i = 1 To j If j < 0 Then Exit For bHide = False 'sVal = Trim(Range("I" & i).Value) sVal = Range("I" & i).Select If Selection.Interior.ColorIndex <> 36 Then bHide = True End If If bHide Then Rows(i & ":" & i).Select Range("A" & i).Activate Selection.EntireRow.Hidden = True j=j-1 End If Next i End Sub
'AyniRenkSay: Erimde, belirtilen hcre ile ayn renkte ka adet hcre olduunu hesaplar. 'AyniRenkTopla: Erimde, belirtilen hcre ile ayn renkteki hcrelerdeki deerleri toplar. Option Explicit Option Base 1 Function AyniRenkSay(ColorRange As Range, Target As Range) As Long Dim c As Range For Each c In Target If c.Interior.ColorIndex = ColorRange.Interior.ColorIndex Then AyniRenkSay = AyniRenkSay + 1 End If Next End Function Function RenkAnalizi(Target As Range, Optional sType As String = "metin") Dim aIdx As Variant Dim aClr As Variant Dim ret As Variant aIdx = Array(1, 53, 52, 51, 49, 11, 55, 56, 9, 46, 12, _ 10, 14, 5, 47, 16, 3, 45, 43, 50, 42, 41, _ 13, 48, 7, 44, 6, 4, 8, 33, 54, 15, 38, 40, _ 36, 35, 34, 37, 39, 2) aClr = Array("Siyah", "Kahverengi", "Zeytin Yeili", "Koyu Yeil", _ "Koyu Deniz Mavisi", "Koyu Mavi", "Indigo", "Gri %80", _ "Koyu Krmz", "Turuncu", "Koyu Sar", "Yeil", "Deniz Mavisi", _ "Mavi", "Gri Mavi", "Gri %50", "Krmz", "Ak Turuncu", _ "Limon Rengi", "Deniz Yeili", "Ak Deniz Mavisi", "Ak Mavi", _ "Mor", "Gri %40", "Pembe", "Altn", "Sar", "Parlak Yeil", _ "Turkuaz", "Gk Mavisi", "Erik Rengi", "Gri %25", "Gl", _ "Tan", "Ak Sar", "Ak Yeil", "Ak Turkuaz", _ "Soluk Mavi", "Ak Eflatun", "Beyaz") ret = Application.Match(Target.Interior.ColorIndex, aIdx, 0) sType = LCase(sType) Select Case sType Case "metin" RenkAnalizi = IIf(IsError(ret), "Custom Color or No Color", aClr(ret)) Case "indis" RenkAnalizi = IIf(IsError(ret), CLng(xlNone), aIdx(ret)) Case "rgb" RenkAnalizi = IIf(IsError(ret), GetRGB(xlNone), GetRGB(CLng(aIdx(ret)))) End Select End Function Function AyniRenkTopla(ColorRange As Range, Target As Range) Dim c As Range Dim rColor As Range For Each c In Target If c.Interior.ColorIndex = ColorRange.Interior.ColorIndex Then If rColor Is Nothing Then Set rColor = c Else Set rColor = Union(rColor, c) End If End If Next If rColor Is Nothing Then AyniRenkTopla = 0 Else AyniRenkTopla = Application.WorksheetFunction.Sum(rColor) End If End Function Function GetRGB(lColor As Long) As Variant Dim r As Long Dim g As Long Dim b As Long r = lColor Mod 256 g = Int(lColor / 256) Mod 256 b = Int(lColor / 256 / 256) GetRGB = "#" & Right("0" & Hex(r), 2) & _ Right("0" & Hex(g), 2) & _ Right("0" & Hex(b), 2) End Function
Sub RenkleriListele() For i = 1 To 56 With Cells(i, 1) .Interior.ColorIndex = i ' Dolgu Rengi .Font.ColorIndex = 3 'Yaztipi rengini 3 yazdk krmz yani ama istersen VbRed eklinde de yazabilirdik .HorizontalAlignment = xlCenter ' Yazy ortala .Value = i 'Hcrenin iine renk kodunu yaz End With Next i End Sub Sub RenkleriListele() For i = 1 To 56 With Cells(i, 1) .Interior.ColorIndex = i ' Dolgu Rengi .Font.ColorIndex = 3 ' Yaztipi rengi 3 veya VbRed .HorizontalAlignment = xlCenter ' Yazy ortala .Value = i ' Hcre iine renk kodunu yaz End With Next i End Sub Sub Renkler() Dim i As Integer On Error Resume Next For i = 1 To 56 Cells(i, 1).Interior.ColorIndex = i Cells(i, 2).Value = Cells(i, 1).Interior.ColorIndex Cells(i, 3).Value = Cells(i, 1).Interior.Color Next i End Sub Sub CountColor() Dim irow, icol As Integer Cells(1, 1) = 0 For irow = 1 To 20 For icol = 1 To 10 If Cells(irow, icol).Interior.ColorIndex _ <> xlColorIndexNone Then Cells(1, 1) = Cells(1, 1) + 1 End If Next icol Next irow End Sub
Range1, ParamArray Range2()) As Double Dim objCell As Range ' Best to use this even if it does ' slow Excel down somewhat. Application.Volatile ' Initialise. SumIfColours = 0 ' Process first argument. ' Restrict the range to stop the loop looking ' at huge swathes of empty cells. For Each objCell In Intersect(Range1, _ Range1.Parent.UsedRange) If Application.IsNumber(objCell.Value) And _ objCell.Interior.ColorIndex = cellTextColour Then _ SumIfColours = SumIfColours + objCell.Value Next objCell ' Process additional arguments (if any) If UBound(Range2) <> 0 Then For intArgument = 1 To UBound(Range2) For Each objCell In Intersect(Range2(intArgument), _ Range2(intArgument).Parent.UsedRange) If Application.IsNumber(objCell.Value) And _ objCell.Interior.ColorIndex = cellTextColour Then _ SumIfColours = SumIfColours + objCell.Value Next objCell Next intArgument End If End Function D21 veya A1:D20 hcreleri dnda bir hcreye aadaki frml yazn. =SumIfColours(3;$A$1:$D$20)
Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim myRange As Range Dim intLowerlimit As Integer Dim intUpperlimit As Integer Set myRange = Range("A2:B5,D6:E8") ' Snrlar yazn intLowerlimit = 1 ' istediiniz alt limit intUpperlimit = 8 ' istediiniz ust limit If Not Intersect(Target, myRange) Is Nothing Then If Not IsNumeric(Target.Value) Then MsgBox ("Sadece rakam girebilirsiniz!") Cells(Target.Row, 6).Value = "Rakam deil!" Cells(Target.Row, 6).Font.Color = RGB(255, 0, 0) ElseIf Not (Target.Value / 1 = Target.Value \ 1) Then MsgBox ("Geerli deil") Cells(Target.Row, 6).Value = "Dogru degil" Cells(Target.Row, 6).Font.Color = RGB(255, 0, 0) ElseIf Target.Value < intLowerlimit Then MsgBox ("Say limit altnda!1-8 aras olmas gerekiyor " _ & intLowerlimit & " ve " & intUpperlimit) Cells(Target.Row, 6).Value = "Limit altnda" Cells(Target.Row, 6).Font.Color = RGB(255, 0, 0) ElseIf Target.Value > intUpperlimit Then MsgBox ("Say ust limitten fazla! " _ & intLowerlimit & " and " & intUpperlimit) Cells(Target.Row, 6).Value = "Say limit deeri ustunde!" Cells(Target.Row, 6).Font.Color = RGB(255, 0, 0) Else Cells(Target.Row, 6).Value = "Dogru" Cells(Target.Row, 6).Font.Color = RGB(0, 255, 0) End If End If End Sub
Sayfann kod blmne Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Dim pw As String If Target.Column = 3 And Target.Row = 2 Or Target.Row = 5 Then ' C2 ve C5 i sar yap pw = InputBox("Bitte Passwort eingeben !") If pw <> "pir" Then Range("a1").Select Exit Sub Else End If End If End Sub Option Explicit Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Sub Command1_Click() Call keybd_event(vbKeySnapshot, 0, 0, 0) ' Hali hazrda bulunan ekrann fotorafn yakalad DoEvents ' Clipboarda ekilen Resmin Kopyalanmas iin Bilgisayar beklet End Sub sub ekle() activesheet.pictures.insert(c:\...\resim.jpeg) Sub Dialog_42() Application.Dialogs(xlDialogInsertPicture).Show End Sub Sub insertImg() Dim fichImg fichImg = Application.GetOpenFilename("Fichier image(*.gif;*.jpg;*.bmp),*.gif;*.jpg;*.bmp" _ , , "Choix de l'image", , False) 'false selection simple If fichImg = False Then Exit Sub ActiveSheet.Pictures.Insert(fichImg).Select End Sub Sub Dialog_16() Application.Dialogs(xlDialogCopyPicture).Show End Sub
Sub Grafikteil_ausblenden() ActiveSheet.Shapes("Picture 1").Select Selection.ShapeRange.PictureFormat.Brightness = 0.5 Selection.ShapeRange.PictureFormat.Contrast = 0.5 Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic Selection.ShapeRange.PictureFormat.CropLeft = 0# Selection.ShapeRange.PictureFormat.CropRight = 0# Selection.ShapeRange.PictureFormat.CropTop = 0# Selection.ShapeRange.PictureFormat.CropBottom = 0# Range("A1").Select End Sub Sub Grafikteil_einblenden() ActiveSheet.Shapes("Picture 1").Select Selection.ShapeRange.PictureFormat.Brightness = 0.5 Selection.ShapeRange.PictureFormat.Contrast = 0.5 Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic Selection.ShapeRange.PictureFormat.CropLeft = 0# Selection.ShapeRange.PictureFormat.CropRight = 0# Selection.ShapeRange.PictureFormat.CropTop = 0# Selection.ShapeRange.PictureFormat.CropBottom = 34.02 Range("A1").Select End Sub Sub CouleurRGB() Range("a1").Interior.Color = RGB(0, 0, 0) Range("a2").Interior.Color = RGB(255, 0, 0) End Sub
' Custom data type for undoing Type SaveRange Val As Variant Addr As String End Type ' Stores info about current selection Public OldWorkbook As Workbook Public OldSheet As Worksheet Public OldSelection() As SaveRange Sub ZeroRange() ' Inserts zero into all selected cells ' Abort if a range isn't selected If TypeName(Selection) <> "Range" Then Exit Sub ' The next block of statements ' Save the current values for undoing ReDim OldSelection(Selection.Count) Set OldWorkbook = ActiveWorkbook Set OldSheet = ActiveSheet i=0 For Each cell In Selection i=i+1 OldSelection(i).Addr = cell.Address OldSelection(i).Val = cell.Formula Next cell ' Insert 0 into current selection Application.ScreenUpdating = False Selection.Value = 0 ' Specify the Undo Sub Application.OnUndo "Undo the ZeroRange macro", "UndoZero" End Sub Sub UndoZero() ' Undoes the effect of the ZeroRange sub ' Tell user if a problem occurs On Error GoTo Problem Application.ScreenUpdating = False ' Make sure the correct workbook and sheet are active OldWorkbook.Activate OldSheet.Activate ' Restore the saved information For i = 1 To UBound(OldSelection) Range(OldSelection(i).Addr).Formula = OldSelection(i).Val Next i Exit Sub ' Error handler Problem: MsgBox "Can't undo" End Sub B1 hcresindeki metin iin; A1 hcresine yazlacak forml: =SOLDAN(B1;BUL("s";B1;1)-1) C1 hcresine yazlacak forml: =SADAN(B1;BUL("s";B1;1)-1) s harfini gzard ettik. Eer onu da almak isterseniz -1'leri silin Sub MASA1() Cells(3, 3) = "=NOW()" Cells(3, 3).Select Selection.NumberFormat = "h:mm" Cells(3, 4) = Cells(3, 3).Value - Cells(3, 2).Value Range("E1").Select End Sub
sub saat () Do Range("a1") = Format(Now(), "dd mm yyyy") Range("a2") = Format(Now(), "hh:mm:ss") DoEvents Loop End Sub LABEL KUTULARINA SAAT&TARH EKLER Private Sub tarih_Click() Label1.Caption = time Label2.Caption = Date End Sub 'TARH&SAAT' AYNI ANDA GSTERR. Private Sub Label3_Click() Label1.Caption = Now() End Sub LABEL KUTULARINA SAAT&TARH EKLER Private Sub tarih_Click() Label1.Caption = time Label2.Caption = Date End Sub 'TARH&SAAT' AYNI ANDA GSTERR. Private Sub Label3_Click() Label1.Caption = Now() End Sub Sub StartClock() Range("A2:C" & Rows.Count).ClearContents Range("A2") = Time End Sub Sub PrintClock() Dim intRow As Integer intRow = Cells(Rows.Count, 1).End(xlUp).Row + 1 Cells(intRow, 1) = Time Cells(intRow, 2) = Cells(intRow, 1) - Range("A2") Cells(intRow, 3) = Cells(intRow, 1) - Cells(intRow - 1, 1) End Sub
(_ ByVal lpClassName As String, _ ByVal lpWindowName As String _ )_ As Long Private Declare Function SetTimer _ Lib "user32" _ (_ ByVal hWnd As Long, _ ByVal nIDEvent As Long, _ ByVal uElapse As Long, _ ByVal lpTimerFunc As Long _ )_ As Long Private Declare Function KillTimer _ Lib "user32" _ (_ ByVal hWnd As Long, _ ByVal nIDEvent As Long _ )_ As Long Private Declare Function GetCurrentVbaProject _ Lib "vba332.dll" _ Alias "EbGetExecutingProj" _ (_ hProject As Long _ )_ As Long Private Declare Function GetFuncID _ Lib "vba332.dll" _ Alias "TipGetFunctionId" _ (_ ByVal hProject As Long, _ ByVal strFunctionName As String, _ ByRef strFunctionID As String _ )_ As Long Private Declare Function GetAddr _ Lib "vba332.dll" _ Alias "TipGetLpfnOfFunctionId" _ (_ ByVal hProject As Long, _ ByVal strFunctionID As String, _ ByRef lpfnAddressOf As Long _ )_ As Long Private WindowsTimer As Long Private ClockCBControl As CommandBarButton Sub StartClockinMenu() Set ClockCBControl = _ Application.CommandBars(1).Controls.Add( _ Type:=msoControlButton, Temporary:=True) ClockCBControl.Style = msoButtonCaption ClockCBControl.Caption = Format(Now, "Long Time") fncWindowsTimer 1000 End Sub Sub StopClockinMenu() fncStopWindowsTimer ClockCBControl.Delete End Sub Private Function fncWindowsTimer( _ TimeInterval As Long _ ) As Boolean Dim WindowsTimer As Long WindowsTimer = 0 If Val(Application.Version) > 8 Then WindowsTimer = SetTimer _ (_ hWnd:=FindWindow("XLMAIN", Application.Caption), _ nIDEvent:=0, _
Private Sub CommandButton1_Click() TextBox3 = Hour(TextBox2) * 3600 + Minute(TextBox2) * 60 + Second(TextBox2) End Sub Sub Datum() Dim tag Dim uhr tag = Date uhr = Time MsgBox "Heute ist der " & Date & "," & Chr$(13) & Chr$(13) & " es ist " & Time & " Uhr.", vbOKOnly, "www.excel-lex.de.vu" End Sub Sub Druck_Bestimmte_Seite() ActiveWindow.View = xlPageBreakPreview Dim seitenzahl As String seitenzahl = InputBox(" Geben Sie die Nr. der" & Chr(13) & Chr(13) & "auszudruckenden Seite ein:", "Seitenzahl eingeben") If seitenzahl = "" Then MsgBox "Keine Seite ausgewhlt" Exit Sub Else ActiveWindow.SelectedSheets.PrintOut From:=seitenzahl, To:=seitenzahl, Copies:=1, Collate _ :=True ActiveWindow.View = xlNormalView End If End Sub Sub Dme1_Tklat() Dim Klasor As String Dim Dosya As String Dim i As Integer Range("A1:A65536").Clear Klasor = "C:\Dosyalar" Dosya = Dir(Klasor & "\*.xls") Do While Dosya <> "" Cells(i + 1, 1) = Left(Dosya, Len(Dosya) - 4) i=i+1 Dosya = Dir Loop End Sub Private Function FileNameOnly(pname) As String ' Bir yol/dosya ad dizisinden dosya adn dndrr Dim i As Integer, length As Integer, temp As String length = Len(pname) temp = "" For i = length To 1 Step -1 If Mid(pname, i, 1) = Application.PathSeparator Then FileNameOnly = temp Exit Function End If temp = Mid(pname, i, 1) & temp Next i FileNameOnly = pname End Function HideShow prosedr herhangi bir parametre kabul etmiyor. alma kitabnn tm pencerelerini grnrse gizli, gizli ise grnr yapyor Private Sub UserForm_Initialize() HideShow End Sub Sub HideShow() Dim Wnd As Window For Each Wnd In ThisWorkbook.Windows Wnd.Visible = Not Wnd.Visible Next Wnd End Sub Private Sub UserForm_Terminate() HideShow End Sub
Gizleme veya gsterme parametresini True veya False olarak siz belirliyorsunuz. Bo brakrsanz True/Gster kabul ediliyor Private Sub UserForm_Initialize() HideShow False End Sub Sub HideShow(Optional IsVisible As Boolean = True) Dim Wnd As Window For Each Wnd In ThisWorkbook.Windows Wnd.Visible = IsVisible Next Wnd End Sub Private Sub UserForm_Terminate() HideShow True 'veya sadece 'HideShow End Sub Private Sub TextBox1_Change() If Not (IsNumeric(TextBox1)) Then SendKeys "{bs}" End Sub Private Sub TextBox2_Change() If Right(TextBox2, 1) Like "[0-9]" Then SendKeys "{bs}" End Sub Sub Makro1() x = WorksheetFunction.CountA(Range("A1:A65000")) For a = 1 To x b = Cells(a, 1).Value For c = a + 1 To x d = Cells(c, 1).Value If b = d Then Cells(c, 1).ClearContents End If Next c Next a End Sub Sub RakamYaz() Dim vWert As Variant Do While vWert = "" Or Not IsNumeric(vWert) vWert = InputBox("Wert:") If IsNumeric(vWert) Then Exit Do MsgBox "Ltfen Sadece Rakam Yazn!" Loop MsgBox "Teekkr Ederim!" End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii <> 8 Then 'Allow BACKSPACE through 'Only digits are valid characters. If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then KeyAscii = 0 'Set character to null if out of range Beep End If End If End Sub Sub print_area() Range(ActiveCell, ActiveCell.End(xlDown)).Select ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address End Sub
Yeni popup menu ierii Sub PopupMenuyeMaddeEkle() With Application.CommandBars("Cell").Controls.Add(msoControlButton) .Caption = "YeniMadde" .BeginGroup = True .FaceId = 343 .OnAction = "Goster" End With End Sub 'Yeni popup menu ieriini kaldr Sub PopupMenuResetle() Application.CommandBars("Cell").Reset End Sub ' YeniMadde'ye tklannca yaplacak eylem kodlar Sub Goster() Dim Mesaj, Stil, Baslik Mesaj = "Yen popup men maddesi" Stil = vbYes Baslik = "Popup Menye Yeni Madde Ekle" Sonuc = MsgBox(Mesaj, Stil, Baslik) End Sub Sub PopUpMenuMaddeEkle() With Application.CommandBars("Cell") With .Controls.Add(msoControlPopup) .Caption = "YeniMenu" .BeginGroup = False ' Alt-menu 1 (YeniMenu 1.1) .Controls.Add (msoControlButton) .Controls(1).Caption = "YeniMenu 1.1" With .Controls(1) .OnAction = "Goster" .FaceId = 351 End With ' Alt-menu 2 (YeniMenu 1.2) .Controls.Add (msoControlButton) .Controls(2).Caption = "YeniMenu 1.2" With .Controls(2) .OnAction = "Goster" .FaceId = 352 End With End With End With End Sub ' Popup meny resetler Sub PopupMenuResetle() Application.CommandBars("Cell").Reset End Sub ' YeniMenuye tklandnda yaplacak eylemler Sub Goster() Dim Msg, Stil, Baslik Msg = "Yeni Popup Men maddesine tkladnz." Stil = vbYes Baslik = "Yeni Men" Response = MsgBox(Msg, Stil, Baslik) End Sub
Sayfann kod blmne Option Explicit Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) '************************************************** '* pir * '* 07.10.2005 * '************************************************** Dim Bereich As Range Dim Z Set Bereich = Range("B3:C20") If Intersect(Target, Bereich) Is Nothing Then Exit Sub ' Abbruch, wenn Aktion nicht im Zielbereich If Target.Interior.ColorIndex = 3 Then Target.Interior.ColorIndex = xlNone Else Target.Interior.ColorIndex = 3 End If Cancel = True End Sub With CommandBars("Ply").Controls.Add .FaceId = 14 .Caption = "Russis neuer Eintrag" .OnAction = "MeinMakro" End With End Sub Veya Sub Kontextmen_ergnzen() Dim Mb As CommandBarControl Set Mb = Application.CommandBars("Cell").Controls.Add With Mb .Caption = "Mein Meneintrag" .FaceId = 49 .OnAction = "Mein_Makro" .BeginGroup = True End With End Sub Sub Mein_Makro() MsgBox ("asdasd") End Sub Her 2 Meny de silme Sub Kontextmen_Tabellenreiter_zuruecksetzen() CommandBars("Ply").Reset End Sub Sub Kontextmen_zurcksetzen() Application.CommandBars("Cell").Reset End Sub Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Excel.Range, Cancel As Boolean) Set pir = Application.ShortcutMenus(xlWorksheetCell).MenuItems("ToolBar") With pir .OnAction = "makro" End With End Sub Sub makro() Selection.PasteSpecial Paste:=xlValues End Sub
Sub CreationMenuContext() With Application.CommandBars("Cell").Controls.Add(msoControlButton) .Caption = "Avez-vous un chat?" .BeginGroup = True .OnAction = "Question" End With End Sub Sub Question() MsgBox ("Oui !") End Sub Sub delMenuContext() Application.CommandBars("Cell").Reset End Sub Sub PanZehir() CommandBars("Cell").Reset End Sub Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 39 Then Me.TextBox2.SetFocus End Sub Private Sub Worksheet_BeforeRightClick( _ ByVal Target As Range, _ Cancel As Boolean) Static c As Long If IsEmpty(Cells(1, 1)) Then c = 0 c=c+1 Cells(c, 1) = Now Cells(c, 2) = Now - Cells(1, 1) If c <> 1 Then Cells(c, 3) = Now - Cells(c, 1).Offset(-1, 0) End Sub Sub HeaderDate() ActiveSheet.PageSetup.RightHeader = Format(Date, "m/d/yy") End Sub Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub UserForm_Initialize() Dim hWnd As Long hWnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _ "X", "D") & "Frame", Me.Caption) SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF End Sub Ayrdnz Kelimeyi Silmek istiyorsanz..Yani "Ahmet Eve Geldi Yemek deil"Kelimesinden "deil"kelimesini karp silmek istorsanz. Kod: Sub ayr() For i = 1 To Cells(65536, 1).End(xlUp).Row a = Split(Cells(i, 1), " ") For j = 0 To UBound(a) - 1 Cells(i, 4) = Cells(i, 4) Next j Cells(i, 3) = a(UBound(a)) Range("c1").Select Selection.ClearContents Next i End Sub Kodlar iyi incelerseniz C1'yazlan yer Kod: Cells(i, 3) = a(UBound(a))
thisworkbook a yazn ve A1 hcresinde =pir(A1) veya =pir2(A1) yazn Function pir(Mahmut) For I = 0 To Len(Mahmut) - 1 Verkehrt = Verkehrt & Mid(Mahmut, _ Len(Mahmut) - I, 1) Next I pir = Right(Mahmut, InStr(1, _ Verkehrt, " ", 0)) End Function Function pir2(Bayram) For I = 0 To Len(Bayram) - 1 Verkehrt = Verkehrt & Mid(Bayram, _ Len(Bayram) - I, 1) Next I pir2 = Left(Bayram, InStr(1, _ Verkehrt, " ", 0)) End Function A1 hcresinde 17:39:55 eklinde olan saati 17:39,917 eklinde gsterir. Kullanm; '=milhours(A1) eklindedir. Function milHours(dteTime As Date) Dim intSec As Integer intSec = Second(dteTime) intSec = intSec / 60 * 1000 milHours = Format(Hour(dteTime), "00") & ":" & _ Format(Minute(dteTime), "00") & "," & intSec End Function S5:S35 aralndaki son dolu satr tesbiti sonsat = Range("s36").End(3).Row If sonsat < 5 Then sonsat = 5 MsgBox "Line 1" & vbCrLf & "Line 2" Sub strekle() Set s1 = Sheets("Sayfa2") For i = 1 To 12100 s1.Cells(i, 1).Activate s1.Rows(i + 1 & ":" & i + 32).Select Selection.Insert Shift:=xlDown i = i + 32 Next i End Sub Sub InsertRow() Dim Rng Rng = InputBox("Enter number of rows required.") Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Rng - 1, 0)).Select Selection.EntireRow.Insert End Sub Sub gizle() Dim pir As Integer For pir = 11 To 306 Step 6 Rows(pir).EntireRow.Hidden = Not Rows(pir).EntireRow.Hidden Next pir End Sub Sub blenden() Dim Loi As Integer For Loi = 11 To 306 Step 6 Rows(Loi).EntireRow.Hidden = Not Rows(Loi).EntireRow.Hidden Next Loi End Sub Sub MehrereZeilenMarkieren() Range("1:1,3:3,5:5,9:9,11:11").Select End Sub Sub sonsatrakadarsrala() sonsatir = Range("a1").End(xlDown).Row Range(Cells(1, 1), Cells(sonsatir, 2)).Select Selection.Sort _ Key1:=Worksheets("Sheet1").Columns("A"), _ Header:=xlGuess End Sub
Sub Tumsutuna_Kadar_Srala() Columns("A:b").Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub Sub Makro1() Columns("A:A").Select Range("A1:B4").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _ xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("B1").Select End Sub Sub Makro1() Columns("A:A").Select Range("A1:B4").Sort Key1:=Range("A1") End Sub Sub MsqEntetLigCol() 'masque les en-ttes de ligne et colonne ActiveWindow.DisplayHeadings = False End Sub Sub EntetLigCol() 'affiche les en-ttes de ligne et colonne ActiveWindow.DisplayHeadings = True End Sub
Sub satirgizle() Dim i As Integer For i = 1 To 15 If Sheets("Sayfa1").Cells(i, 1).Value <> "" Then Rows(i).Hidden = False Else Sheets("Sayfa1").Rows(i).Hidden = True End If Next i End Sub A Stunundaki Bo Satrlar Gizler Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim i As Integer For i = 1 To 300 '1 satr ile 300. satr aras If IsEmpty(Cells(i, 1)) Then '1. Satr 1. Stun yani A1 hcresi Rows(i).Hidden = True End If Next i Application.ScreenUpdating = True End Sub C Stunundaki Bo Satrlar Gizler Sub bidahabossatgizle() For i = 6 To 160 If Range("c" & i) = "" Then _ Range("c" & i).EntireRow.Hidden = True Next Bo olan Stunlar Gizle Sub satirgizle() Dim i As Integer For i = 1 To 15 If Sheets("Sayfa1").Cells(i, 1).Value <> "" Then Rows(i).Hidden = False Else Sheets("Sayfa1").Rows(i).Hidden = True End If Next i End Sub Toplamlar Sfra eit olan satrlar gizler Sub sfrgizle() For Each rngRow In ActiveSheet.UsedRange.Rows If Application.Sum(rngRow) = 0 Then rngRow.EntireRow.Hidden = True End If Next rngRow End Sub Sub HideRowsandColumns() Dim LastRow As Object Dim LastColumn As Object Set LastRow = Range(Range("A65536"), Range("A65536").End(xlUp).Offset(1, 0)) Set LastColumn = Range(Range("IV1"), Range("IV1").End(xlToLeft).Offset(0, 1)) LastRow.EntireRow.Hidden = True LastColumn.EntireColumn.Hidden = True End Sub
GZLEMEK N: Sub gizle() For i = 1 To ActiveWorkbook.Sheets.Count Sheets(i).Select ActiveWindow.DisplayHeadings = False Next End Sub
' GSTERMEK N: Sub goster() For i = 1 To ActiveWorkbook.Sheets.Count Sheets(i).Select ActiveWindow.DisplayHeadings = True Next End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Set rng = Columns("C:C") If Not (Intersect(Target, rng) Is Nothing) Then rng.ColumnWidth = 30 Else rng.ColumnWidth = 10.71 End If End Sub Sub zeilenhoehe() Dim hoehe As Single, aktuell As Single, text As String, antwort As String aktuell = Selection.RowHeight / 29.5 text = "Aktuelle Zeilenhhe: " & Format(aktuell, "###0.00 cm") & Chr(13) & "Geben Sie die gewnschte Zeilenhhe fr die aktuelle Zeile oder Markierun antwort = InputBox(text, "Neue Zeilenhhe festlegen", Format(aktuell, "###0.00")) If antwort <> "" Then hoehe = CSng(antwort) Selection.RowHeight = hoehe * 29.5 End If End Sub
Sub spaltenbreite() Dim breite As Single, aktuell As Single, text As String, antwort As String aktuell = (Selection.ColumnWidth + 0.71) / 5.1425 text = "Aktuelle Spaltenbreite: " & Format(aktuell, "###0.00 cm") & Chr(13) & "Geben Sie die gewnschte Spaltenbreite fr die aktuelle Spalte oder Mar antwort = InputBox(text, "Neue Spaltenbreite festlegen", Format(aktuell, "###0.00")) If antwort <> "" Then breite = CSng(antwort) Selection.ColumnWidth = -0.71 + 5.1425 * breite End If End Sub
MsgBox FilteredRowsCount(ActiveSheet) & " data was found." MsgBox FilteredRowsCount2(ActiveSheet) & " data was found." End Sub -------------------------------------------------------------------------------Function FilteredRowsCount(ByVal Sh As Worksheet) Dim Target As Range Dim c As Range Dim i As Long 'If the Filter is not used If Sh.FilterMode = False Then FilteredRowsCount = 0 Exit Function End If Set Target = Sh.AutoFilter.Range For Each c In Target.SpecialCells(xlCellTypeVisible).Areas i = i + c.Rows.Count Next FilteredRowsCount = i - 1 '-1 stands for remove header row End Function -------------------------------------------------------------------------------Function FilteredRowsCount2(ByVal Sh As Worksheet) Dim Target As Range 'If the Filter is not used If Sh.FilterMode = False Then FilteredRowsCount2 = 0 Exit Function End If Set Target = Sh.AutoFilter.Range FilteredRowsCount2 = _ Target.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1 End satir() Sub Function Dim yukseklik As Single, mevcut As Single, text As String, cevap As String 'mevcut satr yksekliini bul mevcut = Selection.RowHeight / 29.5 'mesaj iriini hazrla text = "Mevcut satr ykseklii: " & Format(mevcut, "###0.00 cm") & Chr(13) & "Yeni satr yksekliini girin (cm):" 'InputBox gster cevap = InputBox(text, "Yeni satr ykseklii belirle", Format(mevcut, "###0.00")) 'cevaba gre yeni satr ykseklii deitir If cevap <> "" Then yukseklik = CSng(cevap) Selection.RowHeight = yukseklik * 29.5 End If End Sub Sub sutun() Dim genislik As Single, mevcut As Single, text As String, cevap As String 'mevcut stun geniliini bul mevcut = (Selection.ColumnWidth + 0.71) / 5.1425 'mesaj iriini hazrla text = "Mevcut satr genilii: " & Format(mevcut, "###0.00 cm") & Chr(13) & "Yeni stun geniliini girin:" 'InputBox gster cevap = InputBox(text, "Yeni satr geniliini girin (cm)", Format(mevcut, "###0.00")) 'cevaba gre yeni stun geniliini deitir If cevap <> "" Then genislik = CSng(cevap) Selection.ColumnWidth = -0.71 + 5.1425 * genislik End If End Sub
'///////////////////////////////////////////////////// '// Amended 14th Feb 2003 - suggestion by Juan Pablo G. '// International versons may NOT recognise TRUE '// Suggestion use =1 which evaluates to TRUE, '// in fact any number that <> 0 '//////////////////////////////////////////////////// Const iInternational As Integer = Not (0) Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim iColor As Integer '// Amended routine found on this Web site '// Note: Don't use IF you have Conditional '// formating that you want to keep! '// On error resume in case '// user selects a range of cells On Error Resume Next iColor = Target.Interior.ColorIndex '// Leave On Error ON for Row offset errors If iColor < 0 Then iColor = 28 Else iColor = iColor + 1 End If '// Need this test incase Font color is the same If iColor = Target.Font.ColorIndex Then iColor = iColor + 1 Cells.FormatConditions.Delete '// Horizontal color banding With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:=iInternational 'Or just 1 '"TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With '// Vertical color banding With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & Target.Offset(-1, 0).Address) .FormatConditions.Add Type:=2, Formula1:=iInternational 'Or just 1 '"TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With End CommandButton1_Click() Sub Sub Dim hucre As Range Dim i As Integer BASADON: Set hucre = Application.InputBox("hcre girin", Type:=8) If (hucre.Row = 1 And hucre.Column = 1) Or (hucre.Row = 1 And hucre.Column = 2) Then cevap = MsgBox("Adres Kaynak ile ayn olmamal" & vbCrLf & "Deitirmek stiyormusunuz?", vbYesNo) If cevap = 6 Then GoTo BASADON Else Exit Sub End If End If If MsgBox("Kolona yazacaksanz EVET" & vbCrLf & "Satra yazacaksanz HAYIR", vbYesNo) = 6 Then For i = 0 To [B1] - [A1] Cells(hucre.Row + i, hucre.Column) = [A1] + i Next i Else For i = 0 To [B1] - [A1] Cells(hucre.Row, hucre.Column + i) = [A1] + i Next i End If hucre.Select End Sub
Sub ZeilenHoehe() Dim rCM rCM = InputBox("Bitte die gewnschte Zeilenhhe in cm angeben:") If rCM = "" Then Exit Sub Selection.RowHeight = rCM / 0.035 End Sub Sub SelectEntireSheet() Cells.Select End Sub Sub SatirSay() 'Stunlar iin Rows yerine Columns yaz mycount = Selection.Rows.Count MsgBox mycount End Sub Sub SayfaSay() mycount = Application.Sheets.Count MsgBox mycount End Sub Sub Finde() Selection.SpecialCells(xlBlanks).Areas(1).Cells(1).Select End Sub Sub CopyRow() Worksheets("Sheet1").Rows(1).Copy Worksheets("Sheet2").Select Worksheets("Sheet2").Rows(1).Select Worksheets("Sheet2").Paste End aralama() Sub Sub Range("A2:C10").Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlNo, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Dim deger As Variant Dim deger1 As Variant ba: deg = 0 deger = ActiveCell.Value dng: ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate deger1 = ActiveCell.Value satirno = ActiveCell.Row deg = Cells(satirno - 1, 3).Value + deg If deger <> deger1 Then ActiveCell.EntireRow.Insert Range("A1:C1").Copy ActiveCell.PasteSpecial Cells(satirno - 1, 4) = "TOPLAM:" Cells(satirno - 1, 5) = deg ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate GoTo ba End If deer = deer1 If deger1 = "" Then Range(Cells(satirno - 2, 1), Cells(satirno - 2, 3)).Delete GoTo 10 End If GoTo dng 10 End Sub Sub Kopyala() Range("N2:P2").Select Selection.Copy Range("N3:P19").Select ActiveSheet.Paste Application.CutCopyMode = False End Sub
Sub SATIRSL() Dim x, i For i = 1 To 5 '* For x = 2 To [D65526].End(3).Row Step 1 If Cells(x, 4) Like "*de*" Then Rows(x).Delete End If Next x Next i End Sub Private Sub Workbook_Open() Sheets("veri").ScrollArea = "a1:a10" End Sub Sub satirgizle() Dim i As Integer For i = 1 To 15 If Sheets("Sayfa1").Cells(i, 1).Value <> "" Then Rows(i).Hidden = False Else Sheets("Sayfa1").Rows(i).Hidden = True End If Next i End Sub 'A Stunundaki Bo Satrlar Gizler Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim i As Integer For i = 1 To 300 '1 satr ile 300. satr aras If IsEmpty(Cells(i, 1)) Then '1. Satr 1. Stun yani A1 hcresi Rows(i).Hidden = True End If Next i Application.ScreenUpdating = True End Sub 'C Stunundaki Bo Satrlar Gizler Sub bidahabossatgizle() For i = 6 To 160 If Range("c" & i) = "" Then _ Range("c" & i).EntireRow.Hidden = True Next 'Bo olan Stunlar Gizle Sub satirgizle() Dim i As Integer For i = 1 To 15 If Sheets("Sayfa1").Cells(i, 1).Value <> "" Then Rows(i).Hidden = False Else Sheets("Sayfa1").Rows(i).Hidden = True End If Next i End Sub 'Toplamlar Sfra eit olan satrlar gizler Sub sfrgizle() For Each rngRow In ActiveSheet.UsedRange.Rows If Application.Sum(rngRow) = 0 Then rngRow.EntireRow.Hidden = True End If Next rngRow End Sub Sub Test() Range("A1:A10") = Application.Transpose(Range("B1:K1")) End Sub Sub TEMZLE() ARALIK = "A" & ActiveCell.Row & ":D" & ActiveCell.Row Range(ARALIK).ClearContents End Sub Sub Macro1() Range("A1:E32").Select Selection.Sort Key1:=Range("A1") End Sub
Sheets("deneme").Activate For sss = 2 To Cells(65536, "a").End(3).Row If Cells(sss, 1) = "" Then Rows(Cells(sss, "a").Row).Group Next sss Sub listele() sut = Sheets("Sayfa1").Range("A1").End(xlToRight).Column sat = Sheets("Sayfa1").Range("A1").End(xlDown).Row yazsat = 1: yazsut = 1 For i = 2 To sat For y = 1 To sut Sheets("Sayfa2").Cells(yazsat, yazsut) = Sheets("Sayfa1").Cells(i, y) yazsat = yazsat + 1 Next y yazsut = yazsut + 2 If yazsut > 5 Then yazsut = 1 yazsat = yazsat + 1 Else: yazsat = yazsat - 4 End If Next i End Sub Sub saveas() dosya = "IS " & Range("A1") & " " & Range("B1") dosya = WorksheetFunction.Substitute(dosya, "/", ".") ' / lar nokta yapsn. ChDrive "D" ChDir "D:\STOK" ActiveWorkbook.saveas Filename:=dosya End Sub Sub yenisayfayedekle() Dim i As String If ActiveSheet.Range("a1").Value <> "" Then i = ActiveSheet.Range("a1").Value ActiveSheet.Select ActiveSheet.Copy Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:= _ "C:\yedek1\" & i & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False Workbooks(i & ".xls").Activate ActiveWorkbook.Close ThisWorkbook.Close Application.DisplayAlerts = True Else: Exit Sub End If End Sub Yeni dosyay kapatmamz lazm Sub Makro1() Application.DisplayAlerts = False 'dosyann zerine yazaymm diye sormamasn direk stne kaydetmesini salar ad = [a1] Sheets("Sayfa1").Copy ' sayfann yeni bir workbook''a kopyasn alr ActiveWorkbook.SaveAs Filename:="C:\Documents And Settings\ersin\Belgelerim\" & ad Workbooks(ad).Close 'yeni oluturulan dosyay kapatr End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If SaveAsUI Then Cancel = True End If End Sub Makro her altnda A1 hcresindeki say 1 artar. Sub Count() mycount = Range("a1") + 1 Range("a1") = mycount End Sub Sub sahife_list() Dim pir As Worksheet Dim i As Integer For Each pir In Worksheets Range("A1").Offset(i) = pir.Name i=i+1 Next End Sub
1.Sayfa hari tm sayfalar gizle Sub xlVeryHidden_All_Sheets() On Error Resume Next Dim sh As Worksheet For Each sh In Worksheets sh.Visible = xlVeryHidden Next End Sub Private Sub Kaydet() Dim Sh1 As Worksheet, Sh2 As Worksheet Dim Dolusay1, Dolusay2 Set Sh1 = Worksheets("Sayfa1") Set Sh2 = Worksheets("Sayfa2") Dolusay1 = WorksheetFunction.CountA(Sh1.Range("A:A")) Dolusay2 = WorksheetFunction.CountA(Sh2.Range("A:A")) Sh1.Range("A1:A" & Dolusay1).EntireRow.Copy Sh2.Range("A" & Dolusay2 + 1) End izelge() Sub Sub Dim Tarih Dim isim As String Dim Son As Integer Dim satir, sutun, i Dim tarihalani As Range, isimalani As Range, tarih1 As Range, isim1 As Range On Error Resume Next Son = Sheets("sayfa2").Range("a65536").End(xlUp).Row Set tarihalani = Sheets("sayfa2").Range("c1:ag1") Set isimalani = Sheets("sayfa2").Range("a3:a" & Son + 15) Tarih = Sheets("sayfa1").Range("A1").Value For i = 13 To Sheets("sayfa1").Range("b65536").End(xlUp).Row isim = Sheets("sayfa1").Range("B" & i).Value Set tarih1 = tarihalani.Find(Tarih, lookat:=xlWhole) Set isim1 = isimalani.Find(isim) If tarih1 Is Nothing Then MsgBox "Aradnz isim ve ya tarih bulunamad.", vbCritical, "Arama Sonucu." Exit Sub Else sutun = tarih1.Column satir = isim1.Row Sheets("sayfa2").Cells(satir, sutun) = Sheets("sayfa1").Cells(i, 4) End If Next i End Sub Sayfa Adn verir Sub SayfaAd() ActiveSheet.name=Range("a1").value End Sub 'A1 Hcresine Sayfa ismini verir Sub Hcread() Range("a1").value=ActiveSheet.name End Sub Sub Test2() If Not Sheets("Sayfa1").Range("A1") = Empty Then For i = 1 To Worksheets.Count If Sheets(i).Name = Sheets("Sayfa1").Range("A1") Then MsgBox "Bu isimli bir sayfa mevcut..... !" Exit Sub End If Next Set NewSh = Worksheets.Add(After:=Sheets(Sheets.Count)) NewSh.Name = Sheets("Sayfa1").Range("A1") End If Set NewSh = Nothing End Sub
Private Sub ListBox1_Click() If ListBox1.ListIndex = -1 Then CommandButton1.Enabled = False Else CommandButton1.Enabled = True End If Label1.Caption = UCase(ListBox1.Value) End Sub ' Private Sub UserForm_Initialize() Dim i As Integer Dim j As Integer Label1.Caption = "" If Worksheets.Count = 1 Then Exit Sub For i = 1 To Worksheets.Count Sheets(i).Name = LCase(Sheets(i).Name) For j = i + 1 To Worksheets.Count If LCase(Worksheets(j).Name) < LCase(Worksheets(i).Name) Then Worksheets(j).Move Before:=Worksheets(i) End If Next j Next i For i = 1 To Sheets.Count ListBox1.AddItem Sheets(i).Name Next Sheets("ana sayfa").Move Before:=Sheets(1) End Sub Sub ListelemeYap() 'Sheetlere gre listeleme yapar' Sheets.Add With Sheets(1) For i = 1 To Sheets.Count Cells(i, 1) = Sheets(i).Name .Hyperlinks.Add Anchor:=Cells(i, 1), _ Address:="", SubAddress:=Sheets(i).Name & "!A1" Sheets(i).Range("A1") = Sheets(1).Name Sheets(i).Hyperlinks.Add Anchor:=Sheets(i).Range("A1"), _ Address:="", SubAddress:=Sheets(1).Name & "!A1" Next End With End Sub Sub Makro1() Sheets("Sayfa2").Tab.ColorIndex = 33 End Sub Private Sub OptionButton1_Click() Dim i As Integer Dim j As Integer Label1.Caption = "" If Worksheets.Count = 1 Then Exit Sub For i = 1 To Worksheets.Count Sheets(i).Name = LCase(Sheets(i).Name) For j = i + 1 To Worksheets.Count If LCase(Worksheets(j).Name) < LCase(Worksheets(i).Name) Then Worksheets(j).Move Before:=Worksheets(i) End If Next j Next i For i = 1 To Sheets.Count ListBox1.AddItem Sheets(i).Name Next Sheets("ana sayfa").Move Before:=Sheets(1) End Sub Private Sub Worksheet_Activate() MsgBox "Abarini kimi grirem", vbInformation, "Ho gelmien la kro" End Sub Private Sub Worksheet_Activate() datum = Format(Date, "yyyy-mm-dd") Worksheets("Tabelle1").PageSetup.LeftHeader = datum End Sub Private Sub Worksheet_Activate() Makroname 'Makroname write End Sub
Sub sayfasirala() Application.ScreenUpdating = False Sheets.Add ActiveSheet.Move After:=Sheets(Sheets.Count) Set s1 = Sheets(Sheets.Count) For a = 1 To Sheets.Count - 1 s1.Cells(a, "a") = Sheets(a).Name s1.[a:a].Sort Key1:=s1.[a1] deg = Sheets(a).Name If IsNumeric(deg) = True Then deg = Val(Sheets(a).Name) say = WorksheetFunction.Match(deg, s1.[a:a], 0) Sheets(a).Move Before:=Sheets(say) Next Application.DisplayAlerts = False s1.Delete End alfabetik_sirala() Sub Sub Application.ScreenUpdating = False Sheets(1).Select Say = Sheets.Count If Say < 2 Then Exit Sub Sheets.Add ActiveSheet.Name = "Liste" For X = 2 To Sheets.Count Sheets("Liste").Cells(X - 1, 1) = Sheets(X).Name If Sheets(X).Visible = False Then Sheets(X).Visible = True Sheets("Liste").Cells(X - 1, 2) = "Gizli" End If Next Columns("A:B").Sort Key1:=Range("A1"), Order1:=xlAscending [A1].Select For Y = 2 To Sheets.Count Sheets("" & Cells(Y - 1, 1)).Move Before:=Sheets(Y) Sheets("Liste").Select If Sheets("Liste").Cells(Y - 1, 2) = "Gizli" Then Sheets("" & Cells(Y - 1, 1)).Visible = False End If Next Application.DisplayAlerts = False Sheets("Liste").Delete Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub Sub cogalt() For a = 1 To 10 Sheets("Sayfa1").Copy After:=Sheets(Sheets.Count) Sheets(Sheets.Count).Name = a Next End Sub Sub sheets_preview() Dim Sh As Worksheet For Each Sh In Worksheets If Sh.Visible = True Then Sh.PrintPreview End If Next Sh End Sub
Sub SAYFA_EKLE() Application.ScreenUpdating = False Say = Worksheets.Count For X = Say To Say + 14 Sheets("ANASAYFA").Select Sheets("ANASAYFA").Copy After:=Sheets(Worksheets.Count) ActiveSheet.Shapes("Button 1").Delete ActiveSheet.Name = Format(X, "0000") ActiveSheet.[AA1].Select Selection.NumberFormat = "@" With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With ActiveSheet.[AA1] = ActiveSheet.Name Next Sheets("ANASAYFA").Select Application.ScreenUpdating = True End Sub Sub ekle() Dim x As Object Dim neu$, mldg$, title$ Dim ergebnis%, stil% neu = InputBox("Bitte Namen des neuen Arbeitsblattes eingeben:") For Each x In ActiveWorkbook.Sheets If x.Name = neu Then mldg = "Blattname existiert bereits!" stil = vbCritical + vbOKOnly title = "Achtung" ergebnis = MsgBox(mldg, stil, title) Exit Sub End If Next x Sheets.Add ActiveSheet.Name = neu Sheets(neu).Select With ActiveSheet.PageSetup .LeftMargin = Application.CentimetersToPoints(1) .RightMargin = Application.CentimetersToPoints(1) End With End Sub Sub NeuesTabBlatt() Dim NewName As String ActiveSheet.Copy Before:=Sheets(1) 'ganz links anordnen 'ActiveSheet.Copy Before:=ActiveSheet 'links neben Original anordnen NewName = InputBox("Geben Sie einen Tabellenblattnamen ein") On Error Resume Next ActiveSheet.Name = NewName End Sub
Sub Combine() Dim J As Integer On Error Resume Next Sheets(1).Select Worksheets.Add ' add a sheet in first place Sheets(1).Name = "Combined" ' copy headings Sheets(2).Activate Range("A1").EntireRow.Select Selection.Copy Destination:=Sheets(1).Range("A1") ' work through sheets For J = 2 To Sheets.Count ' from sheet 2 to last sheet Sheets(J).Activate ' make the sheet active Range("A1").Select Selection.CurrentRegion.Select ' select all cells in this sheets ' select all lines except title Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select ' copy cells selected in the new sheet on last line Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2) Next End Sub Public newShtName As String Public addShtCount As Long Public Sub DeleteSheets() Dim currentSheet As String Dim varAnswer As String Dim wsSheet As Worksheet Dim strName As String currentSheet = ActiveSheet.Name varAnswer = MsgBox("This will delete all sheets except for the sheet named '" _ + currentSheet + "'" + (Chr(13)) + (Chr(13)) + _ "Click Yes to irreversibly erase the other sheets, or No to cancel this procedure", _ vbYesNo, "Warning - This Procedure Can Not Be Undone!") If varAnswer = vbNo Then Exit Sub Else: Application.DisplayAlerts = False With ActiveSheet For Each wsSheet In Worksheets strName = wsSheet.Name If strName <> currentSheet Then wsSheet.Delete End If Next wsSheet End With End If Application.DisplayAlerts = True addShtCount = 0 End Sub Public Sub AddSheets() addShtCount = addShtCount + 1 Dim straddShtCount As String straddShtCount = addShtCount newShtName = "EZA" + straddShtCount Worksheets.Add ActiveSheet.Name = newShtName End Sub
Option Explicit Sub DeleteSheets() Dim Answer As String, Sheet As Worksheet Answer = MsgBox("This will delete all sheets except for the sheet named '" & _ ActiveSheet.Name & "'" & vbNewLine & vbNewLine & _ "Click Yes to irreversibly erase the other sheets, or No to cancel " & _ "this procedure", vbYesNo, "Warning - This Procedure Can Not Be Undone!") If Answer = vbNo Then Exit Sub Else Application.DisplayAlerts = False For Each Sheet In Worksheets If Sheet.Name <> ActiveSheet.Name Then Sheet.Delete Next Application.DisplayAlerts = True End If End Sub Sub AddSheets() Dim N As Long Worksheets.Add after:=Sheets(Sheets.Count) ActiveSheet.Name = "EZA" & Sheets.Count - 1 For N = 1 To Sheets.Count ThisWorkbook.VBProject.VBComponents(Sheets(N).CodeName).Name = "Sheet" & N Next End Sub Sub SayfaEkleAdlandir() Dim cpt As Integer cpt = 1 Do While cpt < 4 ' 3 sayfa ekler ' Sayfa ekler Application.Sheets.Add After:=Sheets.Item(Sheets.Count), Type:=xlWorksheet ' Sayfay yeniden adlandr Application.ActiveSheet.Name = "Hafta " & CStr(cpt) cpt = cpt + 1 Loop End Sub Sayfa eklemek iin aadaki kodu deneyin. 1.sayfay kopyalar. visual basic kodu: Private Sub CommandButton2_Click() Sheets(1).Copy After:=Sheets(Sheets.Count) End Sub ZELLKLER MENSNDEN SAYFA GZLEME LEMLER VSBLE: 0-XLSHEETHDDE 2-XLSHEETVERY 1-XLSHEETVSBLE
' Sayfa1 sayfasn grnr yapyoruz Sheets("Sayfa1").Visible = True ' Sayfa1 haricinde hepsini gizliyoruz For Each Worksheet In ActiveWorkbook.Worksheets If Worksheet.Name <> "Sayfa1" Then Worksheet.Visible = False End If Next ' alma Kitabn koruyoruz ActiveWorkbook.Protect Password:="sifre", Structure:=True, Windows:=True End Sub Private Sub Workbook_Open() ' alma Kitab korumasn kaldryoruz ActiveWorkbook.Unprotect Password:="sifre" ActiveWorkbook.Unprotect ' Btn sayfalar grnr Yapyoruz For Each Worksheet In ActiveWorkbook.Worksheets Worksheet.Visible = True Next ' Sayfa1 sayfasn gizliyoruz Sheets("Sayfa1").Visible = False End Sub
Sub QuickMap() If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub ' Create object variables for cell subsets On Error Resume Next Set FormulaCells = Range("A1").SpecialCells _ (xlFormulas, xlNumbers + xlTextValues + xlLogical) Set TextCells = Range("A1").SpecialCells(xlConstants, xlTextValues) Set NumberCells = Range("A1").SpecialCells(xlConstants, xlNumbers) On Error GoTo 0 ' Add a new sheet and format it Sheets.Add With Cells .ColumnWidth = 2 .Font.Size = 8 .HorizontalAlignment = xlCenter End With Application.ScreenUpdating = False ' Do the formula cells If Not IsEmpty(FormulaCells) Then For Each Area In FormulaCells.Areas With ActiveSheet.Range(Area.Address) .Value = "F" .Interior.ColorIndex = 3 End With Next Area End If ' Do the text cells If Not IsEmpty(TextCells) Then For Each Area In TextCells.Areas With ActiveSheet.Range(Area.Address) .Value = "T" .Interior.ColorIndex = 4 End With Next Area End If ' Do the numeric cells If Not IsEmpty(NumberCells) Then For Each Area In NumberCells.Areas With ActiveSheet.Range(Area.Address) .Value = "N" .Interior.ColorIndex = 6 End With Next Area End If End Sub Private Sub CommandButton2_Click() On Error Resume Next Dim Sayfa As Variant Sayfa = InputBox("Sayfa Numarasn Giriniz", "UYARI", "1") Sheets(Sayfa).Select End Sub Sub sayfa_isim() Dim Count%, Sayfa$ Sayfa = "Toplam Sayfa Adedi: " & Sheets.Count & Chr$(13) For Count = 1 To Sheets.Count Sayfa = Sayfa & Chr$(13) & "Ad" & Count & ": " & _ Sheets(Count).Name Next MsgBox Sayfa, vbOKOnly + vbInformation, "Sayfa simleri" End Sub ThisWorkbook'a Application.DisplayAlerts = False Tekrar: For i = 1 To Worksheets.Count If Worksheets(i).Name = "x" Or Worksheets(i).Name = "y" Then GoTo ATLA Worksheets(i).Delete GoTo Tekrar: ATLA: Next i Application.DisplayAlerts = True End Sub
Sub SheetNamesDownRows() Dim iSheet As Long For iSheet = 1 To ActiveWorkbook.Worksheets.Count ActiveCell.Offset(iSheet - 1, 0) = "'" & Worksheets(iSheet).Name Next iSheet End Sub Sub Auto_Open() Dim i As Integer Dim j As Integer If Worksheets.Count = 1 Then Exit Sub For i = 1 To Worksheets.Count - 1 For j = i + 1 To Worksheets.Count If Worksheets(j).Name < Worksheets(i).Name Then Worksheets(j).Move before:=Worksheets(i) End If Next j Next i End Sub Sub TrieFeuilles() Dim I As Integer Dim J As Integer Dim Min As Integer Dim ModeCalcul As Integer ModeCalcul = Application.Calculation Application.Calculation = xlCalculationManual Application.ScreenUpdating = False With ActiveWorkbook.Worksheets For I = 1 To .Count - 1 Min = I For J = I + 1 To .Count If .Item(J).Name < .Item(Min).Name Then Min = J Next J If Min <> I Then .Item(Min).Move before:=Worksheets(I) Next I End With Application.Calculation = ModeCalcul Application.ScreenUpdating = True End Sub Sub TriChaqueFeuilles() Dim X As Variant Dim I As Variant For Each X In ActiveWorkbook.Sheets For I = 2 To ActiveWorkbook.Sheets.Count If Sheets(I - 1).Name > Sheets(I).Name Then Sheets(I - 1).Move After:=Sheets(I) End If Next Next End Sub Sub Maj_Onglets() Dim i As Integer For i = 1 To Sheets.Count Sheets(i).Name = UCase(Sheets(i).Name) Next i End Sub For Each sayfa In Worksheets ad.AddItem sayfa.Name Next sayfa Sub Menu() Application.CommandBars("Workbook tabs").ShowPopup 930, 30 End Sub Private Sub sayfa_say() Dim i As Integer For i = 1 To Worksheets.Count Cells(i, 1).Value = Sheets(i).Name Next i End Sub
Sub Schutzabfrage() Dim wks As Worksheet Dim i As Integer For i = 1 To Worksheets.Count If Sheets(i).ProtectContents = False Then MsgBox (i & ". Blatt" & Chr(13) & Chr(13) & "(" & Sheets(i).Name & ") " & Chr(13) & Chr(13) & " ist ungeschtzt!") End If Next i End Sub Sub GetSheets() Dim j As Integer Dim NumSheets As Integer NumSheets = Sheets.Count For j = 1 To NumSheets Cells(j, 1) = Sheets(j).Name Next j End Sub Sub Tabellennamen_auslesen() For i = 1 To Worksheets.Count Sheets("Hier Namen auslesen").Cells(i, 1).Value = Sheets(i).Name Next End Sub Sub Sayfa_sirala() Dim x As Integer Dim y As Boolean Do y = True For x = 1 To Sheets.Count - 1 If Val(Sheets(x).Name) > Val(Sheets(x + 1).Name) Then Sheets(x + 1).Move Before:=Sheets(x) y = False End If Next x Loop Until y = True ActiveSheet.Next.Select End Sub Sub FeuilleMSG() Dim Lst() As String Dim I As Integer ReDim Lst(Sheets.Count - 1) For I = 0 To Sheets.Count - 1 Lst(I) = Sheets(I + 1).Name MsgBox Lst(I) Next I End Sub Sub Umbenennen() Dim Tabelle As Worksheet i=1 For Each Tabelle In ActiveWorkbook.Worksheets Tabelle.Name = "NeuerName" & i i=i+1 Next Tabelle End Sub Sub SortSheets() Dim i As Integer, j As Integer For i = 1 To Sheets.Count For j = 1 To Sheets.Count - 1 If UCase$(Sheets(j).Name) < UCase$(Sheets(j + 1).Name) Then Sheets(j).Move after:=Sheets(j + 1) End If Next j Next i End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("a1")) Is Nothing Then Range("a2").Select End If If Target = Range("A1") Then ActiveSheet.Name = Target End Sub
Sub say() For i = 1 To Sheets.Count With Sheets(i) .Select .Name = [A2] End With Next i End Sub Sub scroll_down() Count = 1 Do Until Count = 200 ActiveWindow.SmallScroll Down:=1 Application.Wait Now + (TimeValue("00:00:03") * 0.2) Count = Count + 1 Loop Cells(1, 1).Select End Sub Aktif Sayfay Kopyala ve Yeni Bir alma Kitab a ve smini "YeniSayfa" Ver ve kopyalanan yaptr. Sub YeniKitap() Dim Sh As Worksheet Set Sh = ActiveSheet ActiveSheet.Copy ActiveSheet.Name = "YeniSayfa" Sh.Range("A1:Z10").Copy Range("A2") End Sub Sub YENYE() On Error Resume Next Application.ScreenUpdating = False Dim sadi, ssayi sadi = [C2] ssayi = Worksheets.Count For i = 1 To ssayi If Sheets(i).Name = sadi Then Exit Sub Next i Worksheets.Add After:=Worksheets(ssayi) Worksheets(ssayi + 1).Name = sadi Sheets("KOPYA").Select Cells.Select Selection.Copy Sheets(ssayi + 1).Select Cells.Select ActiveSheet.Paste Range("H2").Select Range("H2").Value = sadi Sheets("KOPYA").Select Application.CutCopyMode = False Range("H2").Select Sheets(i).Select Application.ScreenUpdating = True End Sub Sub Dme8_Tklat() Dim NewName As String ActiveSheet.Copy Before:=Sheets(2) 'ActiveSheet.Copy Before:=ActiveSheet NewName = Sheets(2).Range("c6").Value On Error Resume Next ActiveSheet.Name = NewName ActiveSheet.DrawingObjects.Delete End Sub
Sub Kopyala() Sheets("Sayfa1").Visible = True Sheets("Sayfa1").Copy After:=Worksheets(Worksheets.Count) 10 NewPageName = InputBox("Kopyalamak zere Olduunuz Sayfann Adn Belirleyiniz...!!!") For a = 1 To Sheets.Count If UCase(Sheets(a).Name) = UCase(NewPageName) Then MsgBox "Setiiniz sayfa ad mevcuttur yeniden deneyin." GoTo 10 End If Next ActiveWindow.ActiveSheet.Name = NewPageName End Sub Private Sub impression() Dim NumLigne As Long Sheets("Base").Select NumLigne = Range("H2").Value + 16 Dim ZoneImpression As String ZoneImpression = "$B$7:$K$" & NumLigne ActiveSheet.PageSetup.PrintArea = ZoneImpression Dim NbCopy As Integer On Error GoTo fin NbCopy = InputBox("Nombre de fiches imprimer (Maxi 5)", "Nombre", 1, 1000, 1000) If NbCopy > 5 Then NbCopy = 5 Application.ScreenUpdating = False ActiveWindow.SelectedSheets.PrintOut Copies:=NbCopy, Collate:=True fin: End Sub Sub UnProtectFeuil() Dim sht As Worksheet For Each sht In ActiveWorkbook.Worksheets sht.Unprotect Next sht End Sub SAYFA KORUMA MENS AIR Sub BlattSchutzEin() Application.Dialogs(xlDialogProtectDocument).Show End Sub SAYFA KORUMASINI KALDIR MENS Sub BlattSchutzAus() ActiveSheet.Unprotect End Sub SAYFA KORUMA MENS AIR Sub BlattSchutzEin() Application.Dialogs(xlDialogProtectDocument).Show End Sub SAYFA KORUMASINI KALDIR MENS Sub BlattSchutzAus() ActiveSheet.Unprotect End Sub
Dim i As Integer, j As Integer, k As Integer Dim l As Integer, m As Integer, n As Integer Dim i1 As Integer, i2 As Integer, i3 As Integer Dim i4 As Integer, i5 As Integer, i6 As Integer On Error Resume Next For i = 65 To 66 For j = 65 To 66 For k = 65 To 66 For l = 65 To 66 For m = 65 To 66 For i1 = 65 To 66 For i2 = 65 To 66 For i3 = 65 To 66 For i4 = 65 To 66 For i5 = 65 To 66 For i6 = 65 To 66 For n = 32 To 126 ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _ Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) _ & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) If ActiveSheet.ProtectContents = False Then MsgBox "One usable password is " & Chr(i) & Chr(j) _ & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) _ & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) Exit Sub End If Next Next Next Next Next Next Next Next Next Next Next Next End Sub Sub FilternAuchBeiBlattschutz() ActiveSheet.Protect userinterfaceonly:=True ActiveSheet.EnableAutoFilter = True End Sub Sub sayfakorumakaldir() Dim Wb As Workbook, Sh As Worksheet For Each Wb In Workbooks For Each Sh In Wb.Worksheets Sh.Unprotect Next Sh Next Wb End Sub
"Norman Harker and JE McGimpsey" Const HEADER As String = "AllInternalPasswords User Message" Const VERSION As String = DBLSPACE & "Version 1.1.1 2003-Apr-04" Const REPBACK As String = DBLSPACE & "Please report failure " & _ "to the microsoft.public.excel.programming newsgroup." Const ALLCLEAR As String = DBLSPACE & "The workbook should " & _ "now be free of all password protection, so make sure you:" & _ DBLSPACE & "SAVE IT NOW!" & DBLSPACE & "and also" & _ DBLSPACE & "BACKUP!, BACKUP!!, BACKUP!!!" & _ DBLSPACE & "Also, remember that the password was " & _ "put there for a reason. Don't stuff up crucial formulas " & _ "or data." & DBLSPACE & "Access and use of some data " & _ "may be an offense. If in doubt, don't." Const MSGNOPWORDS1 As String = "There were no passwords on " & _ "sheets, or workbook structure or windows." & AUTHORS & VERSION Const MSGNOPWORDS2 As String = "There was no protection to " & _ "workbook structure or windows." & DBLSPACE & _ "Proceeding to unprotect sheets." & AUTHORS & VERSION Const MSGTAKETIME As String = "After pressing OK button this " & _ "will take some time." & DBLSPACE & "Amount of time " & _ "depends on how many different passwords, the " & _ "passwords, and your computer's specification." & DBLSPACE & _ "Just be patient! Make me a coffee!" & AUTHORS & VERSION Const MSGPWORDFOUND1 As String = "You had a Worksheet " & _ "Structure or Windows Password set." & DBLSPACE & _ "The password found was: " & DBLSPACE & "$$" & DBLSPACE & _ "Note it down for potential future use in other workbooks by " & _ "the same person who set this password." & DBLSPACE & _ "Now to check and clear other passwords." & AUTHORS & VERSION Const MSGPWORDFOUND2 As String = "You had a Worksheet " & _ "password set." & DBLSPACE & "The password found was: " & _ DBLSPACE & "$$" & DBLSPACE & "Note it down for potential " & _ "future use in other workbooks by same person who " & _ "set this password." & DBLSPACE & "Now to check and clear " & _ "other passwords." & AUTHORS & VERSION Const MSGONLYONE As String = "Only structure / windows " & _ "protected with the password that was just found." & _ ALLCLEAR & AUTHORS & VERSION & REPBACK Dim w1 As Worksheet, w2 As Worksheet Dim i As Integer, j As Integer, k As Integer, l As Integer Dim m As Integer, n As Integer, i1 As Integer, i2 As Integer Dim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer Dim PWord1 As String Dim ShTag As Boolean, WinTag As Boolean Application.ScreenUpdating = False With ActiveWorkbook WinTag = .ProtectStructure Or .ProtectWindows End With ShTag = False For Each w1 In Worksheets ShTag = ShTag Or w1.ProtectContents Next w1 If Not ShTag And Not WinTag Then MsgBox MSGNOPWORDS1, vbInformation, HEADER Exit Sub End If MsgBox MSGTAKETIME, vbInformation, HEADER If Not WinTag Then MsgBox MSGNOPWORDS2, vbInformation, HEADER Else On Error Resume Next Do For i = 65 To 66: For j = 65 To 66: For k = 65 To 66 For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66 For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66 For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126 With ActiveWorkbook .Unprotect Chr(i) & Chr(j) & Chr(k) & _ Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _ Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) If .ProtectStructure = False And _ .ProtectWindows = False Then PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _ Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _ Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) MsgBox Application.Substitute(MSGPWORDFOUND1, _ "$$", PWord1), vbInformation, HEADER Exit Do End If
Worksheets("Kedi2").Protect Password:="a" ' Sayfay "a" ifresi ile korumaya alr Worksheets("Kedi2").Unprotect Password:="a" ' "a" ifreli sayfa korumasn kaldrr Worksheets("Kedi2").Protect Password:="a" ' Sayfay "a" ifresi ile korumaya alr Worksheets("Kedi2").Unprotect Password:="a" ' "a" ifreli sayfa korumasn kaldrr Dim i As Integer, j As Integer, k As Integer Dim l As Integer, m As Integer, n As Integer Dim i1 As Integer, i2 As Integer, i3 As Integer Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next For i = 65 To 66 For j = 65 To 66 For k = 65 To 66 For l = 65 To 66 For m = 65 To 66 For i1 = 65 To 66 For i2 = 65 To 66 For i3 = 65 To 66 For i4 = 65 To 66 For i5 = 65 To 66 For i6 = 65 To 66 For n = 32 To 126 ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _ Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) _ & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) If ActiveSheet.ProtectContents = False Then MsgBox "One usable password is " & Chr(i) & Chr(j) _ & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) _ & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) Exit Sub End If Next Next Next Next Next Next Next Next Next Next Next Next End Sub nce Sayfa korumas olan Excel dosyas alr, sonra makrolar blmnden VBA dzenleyicisinin iine girilir,bir modl oluturulur, oluturulan modln iin ' ****************************** KOD *************************** Sub pcwBreaker() Dim i As Integer, j As Integer, k As Integer Dim l As Integer, m As Integer, n As Integer Dim i1 As Integer, i2 As Integer, i3 As Integer Dim i4 As Integer, i5 As Integer, i6 As Integer On Error Resume Next For i = 65 To 66: For j = 65 To 66: For k = 65 To 66 For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66 For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66 For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126 sifre = Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) ActiveSheet.Unprotect sifre If ActiveSheet.ProtectContents = False Then MsgBox "Bitti." & vbCr & "Sifre:" & vbCr & sifre Exit Sub End If Next: Next: Next: Next: Next: Next Next: Next: Next: Next: Next: Next End Sub Sub DesactiverProtection() ActiveSheet.Unprotect End Sub
On Error Resume Next For i = 65 To 66 For j = 65 To 66 For k = 65 To 66 For l = 65 To 66 For M = 65 To 66 For N = 65 To 66 For o = 65 To 66 For p = 65 To 66 For q = 65 To 66 For r = 65 To 66 For s = 65 To 66 For t = 32 To 126 ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(M) & _ Chr(N) & Chr(o) & Chr(p) & Chr(q) & Chr(r) & Chr(s) & Chr(t) If ActiveSheet.ProtectContents = False Then MsgBox "Ein mgliches Passwort ist " & Chr(i) & Chr(j) & Chr(k) & Chr(l) & _ Chr(M) & Chr(N) & Chr(o) & Chr(p) & Chr(q) & Chr(r) & Chr(s) & Chr(t) Exit Sub End If Next t Next s Next r Next q Next p Next o Next N Next M Next l Next k Next j Next i End Sub Sub pcwBreaker() Dim i As Integer, j As Integer, k As Integer Dim l As Integer, m As Integer, n As Integer Dim i1 As Integer, i2 As Integer, i3 As Integer Dim i4 As Integer, i5 As Integer, i6 As Integer On Error Resume Next For i = 65 To 66: For j = 65 To 66: For k = 65 To 66 For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66 For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66 For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126 sifre = Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) ActiveSheet.Unprotect sifre If ActiveSheet.ProtectContents = False Then MsgBox "Bitti." & vbCr & "Sifre:" & vbCr & sifre Exit Sub End If Next: Next: Next: Next: Next: Next Next: Next: Next: Next: Next: Next End Sub
Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer On Error Resume Next For i = 65 To 66 For j = 65 To 66 For k = 65 To 66 For l = 65 To 66 For m = 65 To 66 For i1 = 65 To 66 For i2 = 65 To 66 For i3 = 65 To 66 For i4 = 65 To 66 For i5 = 65 To 66 For i6 = 65 To 66 For n = 32 To 126 ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) If ActiveSheet.ProtectContents = False Then MsgBox "One useble password is " & Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) Exit Sub End If Next Next Next Next Next Next Next Next Next Next Next Next End Sub Sub upddate_link() ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources End Sub Kopf_und_Fusszeilen() ' &S = Seiten-Nr. ' &A = Seitenanzahl ' &N = Mappen-Name ' &B = Register-Name ' &D = Datum ' &U = Uhrzeit Sub vb_Pfad_in_Fusszeile() Application.ScreenUpdating = False With ActiveSheet.PageSetup .RightFooter = ActiveWorkbook.Path & "\&N [&B]" End With Application.ScreenUpdating = True End Sub Public Sub ProtectGroupedSheets() Const csPASSWD As String = "drowssap" Dim mySheets As Sheets Dim actSheet As Worksheet Dim wkSht As Worksheet Set actSheet = ActiveSheet Set mySheets = ActiveWindow.SelectedSheets actSheet.Select For Each wkSht In mySheets wkSht.Protect Password:=csPASSWD Next wkSht actSheet.Select mySheets.Select False End Sub
Dim Cnt%, N%, M%, i%, ZahlM%, ZahlN% Dim WS As Worksheet Set WS = ActiveSheet Cnt = ActiveWorkbook.Worksheets.Count For M = 1 To Cnt For N = M To Cnt On Error Resume Next For i = 1 To Len(Worksheets(N).Name) If IsNumeric(Right(Worksheets(N).Name, i)) = False Then i=i-1 If i = 0 Then GoTo Text ZahlN = Right(Worksheets(N).Name, i) Exit For End If Next i For i = 1 To Len(Worksheets(M).Name) If IsNumeric(Right(Worksheets(M).Name, i)) = False Then i=i-1 If i = 0 Then GoTo Text ZahlM = Right(Worksheets(M).Name, i) Exit For End If Next i If CInt(ZahlN) < CInt(ZahlM) Then Worksheets(N).Move _ Before:=Worksheets(M) GoTo Nchste Text: If Worksheets(N).Name < Worksheets(M).Name Then _ Worksheets(N).Move Before:=Worksheets(M) Nchste: Next N Next M Sheets("Tab3").Select MsgBox "Anzahl der Tabellen: " & Cnt End Sub
Sheets("Sheet1").Range("A1")=ListBox2.ListCount Private Sub CommandButton1_Click() Dim i As Integer For i = 1 To Worksheets.Count ListBox1.AddItem Worksheets(i).Name Next i End Sub kodlar sayfada herhangi bir yere sa tklamayla kan Hcre popup mensn deitirir. alma kitabndaki sayfalar seen ve seilen sayfaya g Aadaki 'Aadaki kodlar Thisworkbook Modlne kopyala Private Sub Workbook_SheetBeforeRightClick( _ ByVal Sh As Object, ByVal Target As Excel.Range, _ Cancel As Boolean) Dim cntRegister As CommandBar Dim btnAct As CommandBarButton Dim shAct As Worksheet Cancel = True On Error Resume Next Application.CommandBars("Register").Delete On Error GoTo 0 Set cntRegister = Application.CommandBars.Add("Register", msoBarPopup) For Each shAct In ThisWorkbook.Worksheets Set btnAct = cntRegister.Controls.Add With btnAct .Caption = shAct.Name .Style = msoButtonCaption .OnAction = "mnuChoice" End With Next shAct cntRegister.ShowPopup End Sub 'Aadaki kodlar standart modle kopyala Sub mnuChoice() On Error Resume Next Worksheets(Application.Caller(1)).Select CommandBars("Register").Delete End Sub
Worksheets(4).Name = "Kedi2" Bu ilemi aadaki kodlarla; Sayfa2 sekmesini tkladnzda ifre uyar penceresi atrarak ifreyi bilirse sayfa ismini deitirebilir (sayfa2 ye geebilir) ifre Private Sub Worksheet_Activate() 'ActiveWindow.DisplayWorkbookTabs = False 'sayfa tablarn gizler Application.EnableCancelKey = xlErrorHandler 'esc tuu devre d Application.DisplayAlerts = False 'hata mesajlarn gzard et Dim sifre As String sifre = InputBox("Ltfen ifreyi Giriniz," & Chr(13) & Chr(13) & "ifre:123", "pir") If sifre <> "123" Then 'ifre yanlsa MsgBox "Hatal ifre" Worksheets("Sayfa1").Select Exit Sub Else MsgBox ("ifreyi Doru Girdiniz") ActiveWindow.DisplayWorkbookTabs = True Worksheets("Sayfa2").Select Application.DisplayAlerts = True End If End Sub Private Sub Worksheet_Activate() [a1] = ActiveSheet.Name End Sub Sub MasqueOnglet() With ActiveWindow .DisplayWorkbookTabs = Not .DisplayWorkbookTabs End With End Sub Public Sub SortWorksheets() Dim Cnt As Integer Dim N As Integer Dim M As Integer On Error GoTo EndOfMacro Application.ScreenUpdating = False Cnt = ActiveWorkbook.Worksheets.Count For M = 1 To Cnt For N = M To Cnt If UCase(Worksheets(N).Name) < UCase(Worksheets(M).Name) Then Worksheets(N).Move before:=Worksheets(M) End If Next N Next M EndOfMacro: Application.ScreenUpdating = True End Sub Sub sheet_sorting () Dim i As Integer Dim j As Integer For i = 1 To Sheets.Count For j = 1 To Sheets.Count - 1 If UCase$(Sheets(j).Name) > UCase$(Sheets(j + 1).Name) Then Sheets(j).Move after:=Sheets(j + 1) End If Next j Next i End Sub
Public Sub SortWorksheets() Dim Cnt As Integer Dim N As Integer Dim M As Integer On Error GoTo EndOfMacro Application.ScreenUpdating = False Cnt = ActiveWorkbook.Worksheets.Count For M = 1 To Cnt For N = M To Cnt If UCase(Worksheets(N).Name) < UCase(Worksheets(M).Name) Then Worksheets(N).Move before:=Worksheets(M) End If Next N Next M EndOfMacro: Application.ScreenUpdating = True End Sub Sub SayfaSil() Application.DisplayAlerts = False ActiveSheet.Delete End Sub Yanlz uyary tekrar eski haline getirmelisiniz. Sub SayfaSil() Application.DisplayAlerts = False ActiveSheet.Delete Application.DisplayAlerts = True End Sub Sub Sil() Application.DisplayAlerts = False ActiveSheet.Delete End Sub 'kta Eski Haline Getirir. Sub Auto_Close() Application.DisplayAlerts = True End Sub Belli menu ve komutlar (hem ara ubuunda hem de sa klik tuundaki pop-up menleri) seilemez sub menkomutlariptal() Dim Ctrl As Office.CommandBarControl For Each Ctrl In Application.CommandBars.FindControls(ID:=847) Ctrl.Enabled = False'True menleri aktif yapar Next Ctrl For Each Ctrl In Application.CommandBars.FindControls(ID:=889) Ctrl.Enabled = False'True menleri aktif yapar Next Ctrl end sub 'MEN KOMUTLARINI AAR. sub menkomutlara() Dim Ctrl As Office.CommandBarControl For Each Ctrl In Application.CommandBars.FindControls(ID:=847) Ctrl.Enabled = True'True menleri aktif yapar Next Ctrl For Each Ctrl In Application.CommandBars.FindControls(ID:=889) Ctrl.Enabled = True'True menleri aktif yapar Next Ctrl end sub
Belli menu ve komutlar (hem ara ubuunda hem de sa klik tuundaki pop-up menleri) seilemez sub menkomutlariptal() Dim Ctrl As Office.CommandBarControl For Each Ctrl In Application.CommandBars.FindControls(ID:=847) Ctrl.Enabled = False'True menleri aktif yapar Next Ctrl For Each Ctrl In Application.CommandBars.FindControls(ID:=889) Ctrl.Enabled = False'True menleri aktif yapar Next Ctrl end sub 'MEN KOMUTLARINI AAR. sub menkomutlara() Dim Ctrl As Office.CommandBarControl For Each Ctrl In Application.CommandBars.FindControls(ID:=847) Ctrl.Enabled = True'True menleri aktif yapar Next Ctrl For Each Ctrl In Application.CommandBars.FindControls(ID:=889) Ctrl.Enabled = True'True menleri aktif yapar Next Ctrl end sub Private Sub CommandButton3_Click() On Error GoTo 10 Application.DisplayAlerts = False sor = InputBox("Silinecek sayfa adn yaznz.") If sor = "" Then Exit Sub mesaj = MsgBox("silmek istediinizden eminmisiniz", vbYesNo) If mesaj = vbNo Then Exit Sub Sheets("" & sor).Delete Exit Sub 10 MsgBox "sayfa bulunamad" End Sub Option Explicit Private Sub Worksheet_Activate() With Application .CommandBars("Worksheet Menu Bar").Controls("Edit").Controls("Delete Sheet").Enabled = False .CommandBars("Ply").Controls("Delete").Enabled = False End With End Sub Private Sub Worksheet_Deactivate() With Application .CommandBars("Worksheet Menu Bar").Controls("Edit").Controls("Delete Sheet").Enabled = True .CommandBars("Ply").Controls("Delete").Enabled = True End With End Sub Sub sayfasil() Application.DisplayAlerts = False Worksheets("Sayfa1").Delete End Sub Sub ProtectSheet() Dim Password 'This line of code is optional Password = "1234" ActiveSheet.Protect Password, True, True, True End Sub Sub UnProtectSheet() Password = "1234" ActiveSheet.Unprotect Password End Sub Sub sifrele_ac() ActiveSheet.Unprotect "a" MsgBox "Sayfa ifresi zld" ActiveSheet.Protect MsgBox "Sayfa ifrelendi" End Sub
Data2 As Integer Data3 As Integer Data4(0 To 7) As Byte End Type Private Type uPicDesc Size As Long Type As Long hPic As Long hPal As Long End Type
Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As Long Private Declare Function CloseClipboard Lib "user32" () As Long Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As uPicDesc, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IP Declare Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long Declare Function CopyImage Lib "user32" (ByVal handle As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long Const Const Const Const Const CF_BITMAP = 2 CF_PALETTE = 9 CF_ENHMETAFILE = 14 IMAGE_BITMAP = 0 LR_COPYRETURNORG = &H4
Function PastePicture(Optional lXlPicType As Long = xlPicture) As IPicture Dim h As Long, hPicAvail As Long, hPtr As Long, hPal As Long, lPicType As Long, hCopy As Long lPicType = IIf(lXlPicType = xlBitmap, CF_BITMAP, CF_ENHMETAFILE) hPicAvail = IsClipboardFormatAvailable(lPicType) If hPicAvail <> 0 Then h = OpenClipboard(0&) If h > 0 Then hPtr = GetClipboardData(lPicType) If lPicType = CF_BITMAP Then hCopy = CopyImage(hPtr, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG) Else hCopy = CopyEnhMetaFile(hPtr, vbNullString) End If h = CloseClipboard If hPtr <> 0 Then Set PastePicture = CreatePicture(hCopy, 0, lPicType) End If End If End Function Private Function CreatePicture(ByVal hPic As Long, ByVal hPal As Long, ByVal lPicType) As IPicture Dim r As Long, uPicInfo As uPicDesc, IID_IDispatch As GUID, IPic As IPicture Const PICTYPE_BITMAP = 1 Const PICTYPE_ENHMETAFILE = 4 With IID_IDispatch .Data1 = &H7BF80980 .Data2 = &HBF32 .Data3 = &H101A .Data4(0) = &H8B .Data4(1) = &HBB .Data4(2) = &H0 .Data4(3) = &HAA .Data4(4) = &H0 .Data4(5) = &H30 .Data4(6) = &HC .Data4(7) = &HAB End With With uPicInfo .Size = Len(uPicInfo) ' Length of structure. .Type = IIf(lPicType = CF_BITMAP, PICTYPE_BITMAP, PICTYPE_ENHMETAFILE) ' Type of Picture .hPic = hPic ' Handle to image. .hPal = IIf(lPicType = CF_BITMAP, hPal, 0) ' Handle to palette (if bitmap). End With r = OleCreatePictureIndirect(uPicInfo, IID_IDispatch, True, IPic) If r <> 0 Then Debug.Print "Create Picture: " & fnOLEError(r) Set CreatePicture = IPic End Function Private Function fnOLEError(lErrNum As Long) As String Const E_ABORT = &H80004004 Const E_ACCESSDENIED = &H80070005 Const E_FAIL = &H80004005 Const E_HANDLE = &H80070006
Sub Resim_Yapistir() On Error GoTo hata Worksheets("Sayfa1").Range("B1") = Empty Worksheets("Sayfa1").Shapes(Range("A1")).CopyPicture Worksheets("Sayfa1").Image1.Picture = PastePicture Exit Sub hata: Worksheets("Sayfa1").Range("B1") = "htimaldr ki bahis konusu resim bulunamad" End Sub Dim Resim As Object On Error Resume Next Set Resim = Worksheets("Sayfa2").Shapes(Worksheets("Sayfa1").Range("A1")) On Error GoTo 0 If Resim Is Nothing Then MsgBox "Fotagraf bulunamad.", vbCritical, "Arama Sonucu." Else: Resim.CopyPicture Worksheets("Sayfa1").Image1.Picture = PastePicture End If
End Sub ' Sub PopUpMenu() Dim cb As CommandBar Set cb = Application.CommandBars("Cell") ' Set MenuObject = cb.Controls.Add(Type:=msoControlPopup, Temporary:=True) MenuObject.Caption = "Benim Menm" MenuObject.BeginGroup = True ' With MenuObject With .Controls.Add(Type:=msoControlButton) .OnAction = "RaiderMacro1" .FaceId = 7 .Caption = "Alt Menm - 1" End With With .Controls.Add(Type:=msoControlButton) .OnAction = "RaiderMacro2" .FaceId = 17 .Caption = "Alt Menm - 2" End With With .Controls.Add(Type:=msoControlButton) .OnAction = "RaiderMacro3" .FaceId = 27 .Caption = "Alt Menm - 3" End With End With ' Set MenuObject2 = MenuObject.Controls.Add(Type:=msoControlPopup, Temporary:=True) MenuObject2.Caption = "Benim 2nci Seviye Menm - 1" ' With MenuObject2 With .Controls.Add(Type:=msoControlButton) .OnAction = "RaiderMacro4" .FaceId = 37 .Caption = "2nci Seviye(1) Alt Menm - 1" End With With .Controls.Add(Type:=msoControlButton) .OnAction = "RaiderMacro5" .FaceId = 47 .Caption = "2nci Seviye(1) Alt Menm - 2" End With End With ' Set MenuObject3 = MenuObject.Controls.Add(Type:=msoControlPopup, Temporary:=True) MenuObject3.Caption = "Benim 2nci Seviye Menm - 2" ' With MenuObject3 With .Controls.Add(Type:=msoControlButton, ID:=4) .Visible = True End With With .Controls.Add(Type:=msoControlButton, ID:=3) .Visible = True End With With .Controls.Add(Type:=msoControlButton, ID:=1695) .Visible = True End With End With ' Set cb = Nothing Set MenuObject = Nothing Set MenuObject2 = Nothing End Sub ' Sub RaiderMacro1() MsgBox "RaiderMacro1 altrld !" & vbCrLf & vbCrLf & "(AltMen-1)" End Sub ' Sub RaiderMacro2() MsgBox "RaiderMacro2 altrld !" & vbCrLf & vbCrLf & "(AltMen-2)" End Sub ' Sub RaiderMacro3() MsgBox "RaiderMacro3 altrld !" & vbCrLf & vbCrLf & "(AltMen-3)" End Sub ' Sub RaiderMacro4() MsgBox "RaiderMacro4 altrld !" & vbCrLf & vbCrLf & "(2nci Seviye AltMen-1)" End Sub '
Dim ans As Integer ans = MsgBox(prompt:="New workbooks will be base on this workbook with the same page setup, view options... Even the content will be the same." "This procedure can not be undone. Do you want to proceed?" & Chr(13), Buttons:=vbYesNo) If ans = vbNo Then End Application.DisplayAlerts = False If Application.AltStartupPath <> "" And Dir(Application.AltStartupPath, 16) <> "" Then ActiveWorkbook.SaveAs Filename:=Application.AltStartupPath & "\book.xlt", FileFormat:=xlTemplate ActiveWindow.Close End End If On Error GoTo 10 ActiveWorkbook.SaveAs Filename:=Application.StartupPath & "\book.xlt", FileFormat:=xlTemplate ActiveWindow.Close End 10: If Application.DefaultFilePath <> "" And Dir(Application.DefaultFilePath, 16) <> "" Then MkDir Application.DefaultFilePath & "\xlstart" Application.AltStartupPath = Application.DefaultFilePath & "\xlstart" ActiveWorkbook.SaveAs Filename:=Application.AltStartupPath & "\book.xlt", FileFormat:=xlTemplate Else MkDir "c:\xlstart" Application.AltStartupPath = "c:\xlstart" ActiveWorkbook.SaveAs Filename:=Application.AltStartupPath & "\book.xlt", FileFormat:=xlTemplate End If ActiveWindow.Close End Sub Sub SheetDefault() Dim Sh Dim ans As Integer ans = MsgBox(prompt:="New sheets will be base on this sheet with the same page setup, view options... Even the content will be the same." & Chr(1 "This procedure can not be undone. Do you want to proceed?" & Chr(13), Buttons:=vbYesNo) If ans = vbNo Then End Application.DisplayAlerts = False ActiveSheet.Copy For Each Sh In ActiveWorkbook.Sheets If Sh.Name <> ActiveSheet.Name Then Sh.Delete Next Sh ActiveSheet.Name = " " If Application.AltStartupPath <> "" And Dir(Application.AltStartupPath, 16) <> "" Then ActiveSheet.SaveAs Filename:=Application.AltStartupPath & "\sheet.xlt", FileFormat:=xlTemplate ActiveWindow.Close End End If On Error GoTo 10 ActiveSheet.SaveAs Filename:=Application.StartupPath & "\sheet.xlt", FileFormat:=xlTemplate ActiveWindow.Close End 10: If Application.DefaultFilePath <> "" And Dir(Application.DefaultFilePath, 16) <> "" Then MkDir Application.DefaultFilePath & "\xlstart" Application.AltStartupPath = Application.DefaultFilePath & "\xlstart" ActiveSheet.SaveAs Filename:=Application.AltStartupPath & "\sheet.xlt", FileFormat:=xlTemplate Else MkDir "c:\xlstart" Application.AltStartupPath = "c:\xlstart" ActiveSheet.SaveAs Filename:=Application.AltStartupPath & "\sheet.xlt", FileFormat:=xlTemplate End If ActiveWindow.Close End Sub Sayfa2 de mouse sa click, Kod Grntle deyin kan ekrana bu kodlar yaptrn. Private Sub Worksheet_Activate() Set s1 = Sheets("Sayfa1") Set s2 = Sheets("Sayfa2") With s2.[A1:A1000] .Value = s1.[A1:A1000].Value .Sort [A1] End With Set s1 = Nothing Set s2 = Nothing End Sub
Option Explicit Sub sichtbare_kopieren() Range("A1").CurrentRegion _ .SpecialCells(xlCellTypeVisible).Copy _ Worksheets("Tabelle2").Range("A1") End Sub Sub Test2() Dim Sh1 As Worksheet, Sh2 As Worksheet Dim MyRng As Range Dim Nrow As Long Set Sh1 = Sheets("Sheet1") Set Sh2 = Sheets("Sheet2") Sh2.Range("A1:A" & Sh2.Range("A65536").End(xlUp).Row).Clear For Each MyRng In Sh1.Range("A1:A100") If MyRng.Interior.ColorIndex = 6 Then Nrow = Sh2.Range("A65536").End(xlUp).Row + 1 Sh1.Rows(MyRng.Row).Copy Sh2.Range("A" & Nrow).PasteSpecial End If Next Application.CutCopyMode = False Range("A1").Select End Sub
Sub Wykres1() Charts.Add ActiveChart.ChartType = xlColumnClustered ActiveChart.SetSourceData Source:=Sheets("Sayfa1").Range("A1:A7") ActiveChart.Location Where:=xlLocationAsObject, Name:="Sayfa1" End Sub Sub Arabul_listele() Dim i As Integer Dim j As Integer Dim Sayac As Integer Dim SinananVeri As String Veri = InputBox("Aranan Veriyi Belirtiniz", "ARANAN VER", "") SinananVeri = "*" & Veri & "*" Set Say1 = Worksheets("Sayfa1") Set Say2 = Worksheets("Sayfa2") j=1 For i = 1 To 10 If WorksheetFunction.CountIf(Say2.Cells(i, 1), SinananVeri) > 0 Then Say1.Cells(j, 1) = Say2.Cells(i, 1) Sayac = Sayac + 1 j=j+1 End If Next i MsgBox Say2.Name & "'de aram olduunuz " & Veri & " verisini ieren toplam " & Sayac & " adet hcre deeri bulundu ve " & Say1.Name & "'de liste End Sub Application.wait metodu ile visual basic kodu: Sub Auto_Open() Sheets("sayfa1").Select Application.Wait Now + TimeValue("00:00:10") Sheets("sayfa2").Select End Sub
Application.ontime metodu ile visual basic kodu: Sub Auto_Open() Sheets("sayfa1").Select zaman = Now + TimeValue("00:00:10") Application.OnTime zaman, "sayfasec" End Sub Sub sayfasec() Sheets("sayfa2").Select End Sub
Application.wait metodu ile visual basic kodu: Sub Auto_Open() Sheets("sayfa1").Select Application.Wait Now + TimeValue("00:00:10") Sheets("sayfa2").Select End Sub
Application.ontime metodu ile visual basic kodu: Sub Auto_Open() Sheets("sayfa1").Select zaman = Now + TimeValue("00:00:10") Application.OnTime zaman, "sayfasec" End Sub Sub sayfasec() Sheets("sayfa2").Select End Sub Sub Print() Sheets("Sayfa1").PrintOut End Sub Private Sub Workbook_Activate() If ActiveSheet.Name = "Sayfa1" Then Application.DisplayFullScreen = True End Sub Private Sub Workbook_Deactivate() Application.DisplayFullScreen = False End Sub Private Sub Workbook_SheetActivate(ByVal Sh As Object) If ActiveSheet.Name = "Sayfa1" Then Application.DisplayFullScreen = True End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) Application.DisplayFullScreen = False End Sub Sub Add_Sheet() Dim wSht As Worksheet Dim shtName As String shtName = Format(Now, "mmmm_yyyy") For Each wSht In Worksheets If wSht.Name = shtName Then MsgBox "inde bulunduumuz aya ait sayfa daha nce ald " & _ "Bir sonraki ay ayn ilemi yapnz" Exit Sub End If Next wSht Sheets.Add.Name = shtName Sheets(shtName).Move After:=Sheets(Sheets.Count) Sheets("Sayfa1").Range("A1:A5").Copy _ Sheets(shtName).Range("A1") End Sub Sub kod_sil() With ThisWorkbook.VBProject.VBComponents("Sayfa1").CodeModule .DeleteLines 1, .CountOfLines End With End Sub Private Sub Worksheet_Activate() Range("B1").Select MsgBox"Sayfa2 ye Ho Geldiniz" End Sub Sub Hide_WS2() Worksheets(2).Visible = xlVeryHidden End Sub Sub Hide_WS1() Worksheets(2).Visible = Hide End Sub
Sub Toggle_Hidden_Visible() Worksheets(2).Visible = Not Worksheets(2).Visible End Sub Sub UnHide_WS() Worksheets(2).Visible = True End Sub Private Sub Worksheet_Activate() Range("B1").Select MsgBox "Sayfa2'ye Ho Geldiniz" End Sub Thisworkbooka Option Explicit Private Sub Workbook_Deactivate() With Application.AutoCorrect .DeleteReplacement What:="a" .DeleteReplacement What:="b" .DeleteReplacement What:="c" .DeleteReplacement What:="d" End With End Sub Private Sub Workbook_Open() With Application.AutoCorrect .AddReplacement What:="a", Replacement:="Klaus" .AddReplacement What:="b", Replacement:="Marcus" .AddReplacement What:="c", Replacement:="Peter" .AddReplacement What:="d", Replacement:="Berti" End With End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Application.CellDragAndDrop = False If Intersect(Target, Range("B5:G22")) Is Nothing Then Range("A1").Select End If End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim RaBereich As Range, RaZelle As Range Set RaBereich = Range("B3:B20, D1:D7") ' ActiveSheet.Unprotect Application.EnableEvents = False For Each RaZelle In Range(Target.Address) If Not Intersect(RaZelle, RaBereich) Is Nothing Then RaZelle.Offset(0, 1) = Date Next RaZelle ' ActiveSheet.protect Application.EnableEvents = True Set RaBereich = Nothing End Sub Sub bossatir_gizle() Rows("1:250").EntireRow.Hidden = False For x = 5 To 250 gizle = 0 For y = 2 To 5 If Cells(x, y) <> 0 Then gizle = 1 Next y If Cells(x, 6) = "E" Then gizle = 1 If gizle = 0 Then Rows(x & ":" & x).EntireRow.Hidden = True End If Next x Columns("C:J").EntireColumn.AutoFit End Sub Sub satirlari_ac() Rows("1:250").EntireRow.Hidden = False End Sub
Ocak, ubat, Mart...... gibi aylar A2:A13 aralnda, 1975, 1976,............... gibi yllar B1:L1 aralnda, UserForm zerinde TextBox1, TextBox2, Label1 ve CommandButton1 nesneleri varsa; Kod: Private Sub CommandButton1_Click() On Error GoTo ResumeSub: x = Range("A2:A13").Cells.Find(TextBox1).Row y = Range("B1:L1").Cells.Find(TextBox2).Column Label1.Caption = Cells(x, y) Exit Sub ResumeSub: Label1.Caption = "Deger bulunamadi...." End Sub Sub buton_text() MsgBox (ActiveSheet.Buttons(Application.Caller).Text) End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 1 Or Target.Column = 3 Or Target.Column = 4 Then kelime = Replace(Target.Value, "i", "") kelime = Replace(kelime, "", "I") Target.Value = StrConv(kelime, vbUpperCase) End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$" & Target.Row Then kelime = Replace(Target.Value, "i", "") kelime = Replace(kelime, "", "I") Target.Value = StrConv(kelime, vbUpperCase) ElseIf Target.Address = "$C$" & Target.Row Then kelime = Replace(Target.Value, "i", "") kelime = Replace(kelime, "", "I") Target.Value = StrConv(kelime, vbUpperCase) ElseIf Target.Address = "$D$" & Target.Row Then kelime = Replace(Target.Value, "i", "") kelime = Replace(kelime, "", "I") Target.Value = StrConv(kelime, vbUpperCase) End If End Sub Sub auto_open() Worksheets("Sayfa1").OnDoubleClick = "Mein_Makro" End Sub Sub Mein_Makro() ActiveCell.Value = Time End Sub Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, _ ByVal Target As Range, ByVal Cancel As Boolean) Cancel = True End Sub Sayfadaki bir hcrenin deerini deitirdiniz. 'Ancak bir nceki deeri ne imi grmek isterseniz, 'ilgili sayfann kod blmne aadaki kodu yaptrn. 'Bir nceki deer Aklama olarak grnecektir. Dim eski Private Sub Worksheet_Change(ByVal Target As Range) If Target.Comment Is Nothing Then Target.AddComment Target.Comment.Text Text:="Eski deer: " & eski End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) eski = Target.Value End Sub
Bu da sadece bir nceki deil , daha nce yaplan btn deiiklikleri grmek iin Dim eski Private Sub Worksheet_Change(ByVal Target As Range) If Target.Comment Is Nothing Then Target.AddComment Target.Comment.Text Text:=Target.Comment.Text & Chr(10) & "Eski deer: " & eski End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) eski = Target.Value End Sub Sayfann kod blmne Private Sub Worksheet_Activate() Application.MoveAfterReturnDirection = xlUp End Sub Private Sub Worksheet_Deactivate() Application.MoveAfterReturnDirection = xlDown End Sub 'Thisworkbook a Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.MoveAfterReturnDirection = xlDown End Sub Sayfann kod blmne Private Sub Worksheet_Activate() Application.MoveAfterReturnDirection = xlToRight End Sub Private Sub Worksheet_Deactivate() Application.MoveAfterReturnDirection = xlDown End Sub 'Thisworkbook a Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.MoveAfterReturnDirection = xlDown End Sub Sayfann kod blmne Private Sub Worksheet_Activate() Application.MoveAfterReturnDirection = xlToLeft End Sub Private Sub Worksheet_Deactivate() Application.MoveAfterReturnDirection = xlDown End Sub 'Thisworkbook a Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.MoveAfterReturnDirection = xlDown End Sub Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, _ Cancel As Boolean) Cancel = True MsgBox "Sa klik yasaklanmtr! " End Sub Sayfann kod blmne Option Explicit Private Sub Worksheet_Deactivate() Application.OnKey "{del}" End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.HasFormula Then Application.OnKey "{del}", "" Else Application.OnKey "{del}" End If End Sub 'Thisworbook a Option Explicit
sayfann kod blmne Private Sub Worksheet_Deactivate() Application.OnKey "{del}" End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.HasFormula Then Application.OnKey "{del}", "" Else Application.OnKey "{del}" End If End Sub
Application.ScreenUpdating = False Set OutputRange = Selection RetSheet = ActiveSheet.Name NameCnt = ActiveWorkbook.Names.Count For Each Sheet In ActiveWorkbook.Sheets Sheet.Select Set FnRange = Cells.SpecialCells(xlFormulas) For i = 1 To NameCnt With FnRange Set c = .Find(ActiveWorkbook.Names(i).Name, LookIn:=xlFormulas) If Not c Is Nothing Then firstAddress = c.Address Do OutputRange.Offset(n, 0).Value = ActiveWorkbook.Names(i).Name OutputRange.Offset(n, 1).Value = ActiveSheet.Name OutputRange.Offset(n, 2).Value = c.Address(False, False) OutputRange.Offset(n, 3).Value = "'" & c.Formula OutputRange.Offset(n, 4).Value = c.Value n=n+1 Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> firstAddress End If End With Next i Next Sheet Sheets(RetSheet).Select Application.ScreenUpdating = True Exit Sub ErrHndlr: Set FnRange = Cells(1, 1) Resume Next End Sub Sub FindNakamedRangeReferences() Dim NameArray() As String Count = 0 Application.ScreenUpdating = False Application.DisplayAlerts = False On Error Resume Next Sheets("Record").Delete Worksheets(1).Select Worksheets.Add.Name = "Record" With Worksheets("Record") .Range("a1").Value = "Worksheet Name" .Range("b1").Value = "Cell Address" .Range("c1").Value = "Formula" .Range("d1").Value = "Value" End With NamedRangeCount = ActiveWorkbook.Names.Count ReDim NameArray(NamedRangeCount) For i = 1 To NamedRangeCount NameArray(i) = ActiveWorkbook.Names.Item(i).Name Next i For j = 2 To ActiveWorkbook.Sheets.Count On Error Resume Next Worksheets(j).Activate Range("a1").Select Worksheets(j).Range("a1", Range("a1").SpecialCells(xlCellTypeLastCell)). _ SpecialCells(xlCellTypeFormulas).Select For Each myCell In Selection For i = 1 To NamedRangeCount If (InStr(myCell.Formula, NameArray(i)) <> 0) Then Worksheets("Record").Cells(2, 1).Offset(Count, 0).Value Worksheets("Record").Cells(2, 1).Offset(Count, 1).Value Worksheets("Record").Cells(2, 1).Offset(Count, 2).Value Worksheets("Record").Cells(2, 1).Offset(Count, 3).Value Worksheets("Record").Cells(2, 1).Offset(Count, 4).Value Count = Count + 1
Sub maProcedure() ActiveSheet.Shapes.AddShape(msoShapeRectangle, _ 120#, 102#, 300, 10).Select Selection.Name = "fond" With Selection.ShapeRange.Fill .ForeColor.SchemeColor = 10 .Visible = msoTrue .Solid End With ActiveSheet.Shapes.AddShape(msoShapeRectangle, _ 120, 102#, 6#, 10#).Select Selection.Name = "prog" With Selection.ShapeRange.Fill .ForeColor.SchemeColor = 11 .Visible = msoTrue .Solid End With Tot = 100 For i = 1 To Tot For ii = 1 To 100 Range("A1").Select Next ii ActiveCell = i Application.StatusBar = "lerleme Durumu: " _ & i / Tot & "/1 tamamland." ActiveSheet.Shapes("prog").Select Selection.ShapeRange.IncrementLeft 300 / Tot DoEvents Next i MsgBox "Bitti!" Selection.Delete ActiveSheet.Shapes("fond").Select Selection.Delete End Sub Thisworkbooka Private Sub Workbook_Open() Tabelle1.WebBrowser1.Navigate "http://www.excel-lex.de.vu" End Countformula() Sub Sub
Dim R As Integer R=0 Range(Cells(1, 1), Selection.SpecialCells(xlLastCell)).Select For Each Cell In Selection If Left(Cell.Formula, 1) = "=" Then R=R+1 End If Next Cell Selection.SpecialCells(xlFormulas, 23).Select MsgBox "toplam " & R & " adet forml bulundu. Sayfa " & ActiveSheet.Name & " de" End Sub Sub CountFormSub() MsgBox ActiveSheet.UsedRange.SpecialCells(xlFormulas).Count End Sub Function countformulas() As Integer Dim x As Range Dim y As Integer Application.Volatile For Each x In ActiveSheet.UsedRange If x.HasFormula Then y = y + 1 Next x countformulas = y End Function
SAYFADA KAYAN YAZI Sub KayanYazi() [J2] = "" For i = 1 To 10 On Error Resume Next For j = 1 To 1000000 j=j+0 Next j Cells(1, i).Value = "kayan yazi" Cells(1, i - 1).Value = "" Next End Sub Sub Blattschutz_Ja_Nein() If ActiveSheet.ProtectContents = True Then MsgBox "sayfa korumal !", 64, "BLATTSCHUTZ" Exit Sub End If If ActiveSheet.ProtectContents = False Then MsgBox "Sayfada koruma yok !", 64, "BLATTSCHUTZ" Exit Sub End If End Sub Sub EnSonHucreyeGit() ActiveSheet.UsedRange.Select ActiveSheet.UsedRange.SpecialCells( _ xlCellTypeLastCell).Offset(0, 0).Select End Sub Sub SatirSayisi() NbLignes = ActiveSheet.UsedRange.Rows.Count MsgBox NbLignes End Sub Sub SutunSayisi() Sutunlar = ActiveSheet.UsedRange.Columns.Count MsgBox Sutunlar End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) ActiveSheet.Hyperlinks.Delete End Sub Sub Make_Textbox() r=5 c=5 w = Cells(1, 1).Resize(1, c).Width h = Cells(1, 1).Resize(r, 1).Height Worksheets(1).Shapes.AddTextbox(msoTextOrientationHorizontal, w, h, 200, 50).TextFrame.Characters.Text = "Test Box" End Sub Sub Case_Kullan() Select Case ActiveCell.Value Case 0 To 44 ActiveCell.Offset(0, 1).Value = "Kald" Case 45 To 60 ActiveCell.Offset(0, 1).Value = "Orta" Case 61 To 80 ActiveCell.Offset(0, 1).Value = "yi" Case 81 To 100 ActiveCell.Offset(0, 1).Value = "Pekiyi" End Select End Sub Private Sub Worksheet_Change(ByVal Target As Range) If IsNumeric(Target) Then MsgBox "Dikkat?", vbQuestion + vbYesNo Else MsgBox "", vbQuestion + vbYesNo End If End Sub
Sub YakiniBul() Dim i As Integer Dim hucre As Range Range("A1:A1000").ClearFormats k = Abs(Range("c1") - Range("B1")) For i = 1 To WorksheetFunction.CountA(Range("B1:B1000")) deger = Abs(Range("c1") - Cells(i, 2)) If deger > k Then GoTo git Else k = deger End If git: Next i For Each hucre In Range("B1:B1000") If hucre.Value = k + Range("C1") Then hucre.Offset(0, -1).Font.ColorIndex = 3 ElseIf hucre.Value = Abs(k - Range("C1")) Then hucre.Offset(0, -1).Font.ColorIndex = 3 End If Next hucre End Sub Option Compare Text Sub Check_Values_1() On Error Resume Next Dim CurCell As Range Dim Heading As String Dim Prompt As String Dim Criteria As Variant Dim Color As Long Dim lRows As Long Dim lCols As Long Dim lAllCells As Long lRows = ActiveSheet.Rows.Count lCols = ActiveSheet.Columns.Count lAllCells = lRows * lCols If Selection.Cells.Count = lAllCells Then MsgBox "To check the entire sheet, please select only one cell", 64 Exit Sub End If Heading = "Enter Criteria" Prompt = "Enter the value you want to find and highlight." Color = 3 Criteria = InputBox(Prompt, Heading) If Criteria = "" Then Exit Sub ElseIf IsNumeric(Criteria) Then Criteria = CLng(Criteria) ElseIf IsDate(Criteria) Then Criteria = CDate(Criteria) Else Criteria = CStr(Criteria) End If If Selection.Cells.Count > 1 Then For Each CurCell In Selection If CurCell.Value = Criteria Then CurCell.Interior.ColorIndex = Color Next CurCell Else For Each CurCell In ActiveSheet.UsedRange If CurCell.Value = Criteria Then CurCell.Interior.ColorIndex = Color Next CurCell End If End Sub Sub Macro1() ActiveSheet.DrawingObjects.Delete End Sub
Men aa-yukar ve saa-sola scrollunu kullanmanza izin vermez. Basit bir kod, deneyince grrsnz. Option Explicit Private Sub Workbook_Open() Sheets("Anasayfa").Select Sheets("Anasayfa").Range("a1:p40").ClearContents Sheets("Anasayfa").ScrollArea = "c5" Sub formschutz() On Error GoTo fehlerbeh Application.ScreenUpdating = False ActiveSheet.Protect DrawingObjects:=False, Contents:=False, _ Scenarios:=False With Cells .Locked = False .FormulaHidden = False End With With Cells.SpecialCells(xlFormulas, 23) .Locked = True .FormulaHidden = True End With ActiveSheet.Protect DrawingObjects:=True, Contents:=True, _ Scenarios:=True Exit Sub fehlerbeh: If Err.Number <> 0 Then MsgBox Err.Description End If Application.ScreenUpdating = True End Sub Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _ Cancel As Boolean) Dim icbc As Object For Each icbc In Application.CommandBars("cell").Controls If icbc.Tag = "brccm" Then icbc.Delete Next icbc If Not Application.Intersect(Target, Range("b1:b10")) _ Is Nothing Then With Application.CommandBars("cell").Controls _ .Add(Type:=msoControlButton, before:=6, _ temporary:=True) .Caption = "New Context Menu Item" .OnAction = "MyMacro" .Tag = "brccm" End With End If End Auto_Open() Sub Sub With ShortcutMenus(xlWorksheetCell) .MenuItems.AddMenu "Menpunkt1" With ShortcutMenus(xlWorksheetCell) _ .MenuItems("Menpunkt1") .MenuItems.Add "Untermenpunkt1_1", _ OnAction:="Makro1" .MenuItems.Add "Untermenpunkt1_2", _ OnAction:="Makro2" .MenuItems.Add "Untermenpunkt3", OnAction:="Makro3" End With .MenuItems.AddMenu "Menpunkt2" With ShortcutMenus(xlWorksheetCell) _ .MenuItems("Menpunkt2") .MenuItems.Add "Untermenpunkt2_1", _ OnAction:="Makro3" .MenuItems.Add "Untermenpunkt2_2", _ OnAction:="Makro4" End With End With End Sub Sub auto_close() Application.CommandBars("Cell").Reset End Sub
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, _ Cancel As Boolean) Cancel = True MsgBox "Sa klik yasaklanmtr! pir" End satirac() Sub Sub Dim i As Long Dim gec, s, st As String Sheets("CIRO").Select For i = 1 To 3000 s = Cells(i, 1).Value If i > 2 Then gec = Cells(i - 1, 1).Value Else gec = s If s = "" Then GoTo son If i = 82 Then s=s End If If (s <> gec) And (gec <> "") Then st = Str(i) Rows(st).Select Selection.Insert Shift:=xlDown ActiveCell.Value = gec + "TOPLAM" Selection.Interior.ColorIndex = 40 Selection.Font.Bold = True i=i+1 End If Next i son: End Sub Sub DeleteNames() Dim NameX As Name For Each NameX In Names ActiveWorkbook.Names(NameX.Name).Delete Next NameX End Sub Sub DeleteAllNames() Dim Nm As Name For Each Nm In Names Nm.Delete Next End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) Application.EnableEvents = False Target = UCase(Target) Application.EnableEvents = True End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) sayfa = Target.Cells.Value Sheets("Sayfa3").Select End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$C$18" Then Sheets("Sayfa2").Select End Sub Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long 'pir buton1 c4:e7 geniiliinde 'buton2 g12:15 Sub Cursor1() SetCursorPos 540, 350 'hier die Bildschirmposition anpassen End Sub Sub Cursor2() SetCursorPos 220, 200 End Sub Sub sheetbuton_disable () Sheets("Sayfa1").Buttons(1).Enabled = False End Sub Sub SchaltflaecheInaktivieren() Sheets("Sayfa1").Buttons(1).Enabled = False End Sub
Sub LimiteDefilement() ' alma alann snrlar ActiveSheet.ScrollArea = "A1:J20" End Sub Sub RetablitDefilement() ' Snrlamay kaldrr ActiveSheet.ScrollArea = "" End Sub activesheet.usedrange.select veya, C2 den balayarak C stunundaki son dolu hcreye kadar seim: range("c2:c" & cells(65536, 3).end(xlup).row).select baka bir yazm ekli de; range("c2:c" & range("c65536").end(xlup).row).select Sub DeleteEmptyRows() LastRow = ActiveSheet.UsedRange.Row - 1 + _ ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub SATIR BOLUKLARINI DOLDURUR(sayfada) Private Sub CommandButton8_Click() LastRow = ActiveSheet.UsedRange.Row - 1 + _ ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Sub FormulesEnCommentaires() Dim cell, largeur, hauteur On Error Resume Next For Each cell In ActiveSheet.UsedRange If cell.HasFormula Then cell.AddComment cell.Comment.Text Text:=cell.FormulaLocal With cell.Comment.Shape largeur = .Width hauteur = .Height .TextFrame.AutoSize = True If .Width > 350 Then .Width = 350 .Height = 55 End If End With End If Next End Sub Sub SupprimeCommentaires() For i = ActiveSheet.Comments.Count To 1 Step -1 ActiveSheet.Comments(i).Delete Next i End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) ActiveSheet.Unprotect (kubilay) End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) ActiveSheet.Protect password:=kubilay, DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub
Sub Rotate() ' select the shape that called this macro ActiveSheet.Shapes(Application.Caller).Select For i = 1 To 180 Selection.ShapeRange.IncrementRotation 4 Application.Calculate ' Just to slow things down a bit Next i Range("A1").Select End Sub Sub Shape_Index_Name() Dim myVar As Shapes Dim shp As Shape Set myVar = Sheets(1).Shapes For Each shp In myVar MsgBox "Index = " & shp.ZOrderPosition & _ vbCrLf & "Name = " & shp.Name Next End Sub Private Sub TextBox1_Change() On Error Resume Next SONUC2 = TextBox1.Value Set FC2 = Range("B6:B500").Find(What:=SONUC2) 'Set FC2 = Cells.Find(What:=SONUC2) 'bu ekilde tm sayfada arar Application.Goto Reference:=Range(FC2.Address), _ Scroll:=False End Sub Private Sub TextBox1_GOTFocus() TextBox1.Text = "" End Sub
Dim Sh As Worksheet Dim Newsh As Worksheet Dim myCell As Range Dim ColNum As Integer Dim RwNum As Long Dim Basebook As Workbook With Application .Calculation = xlCalculationManual .ScreenUpdating = False End With Set Basebook = ThisWorkbook Set Newsh = Basebook.Worksheets.Add On Error Resume Next Newsh.Name = "Summary-Sheet" If Err.Number > 0 Then MsgBox "The Summary sheet already exist in this workbook." With Application .DisplayAlerts = False Newsh.Delete .DisplayAlerts = True .Calculation = xlCalculationAutomatic .ScreenUpdating = True End With Exit Sub End If RwNum = 1 'The links to the first sheet will start in row 2 For Each Sh In Basebook.Worksheets If Sh.Name <> Newsh.Name And Sh.Visible Then ColNum = 1 RwNum = RwNum + 1 Newsh.Cells(RwNum, 1).Value = Sh.Name 'Copy the sheet name in the A column For Each myCell In Sh.Range("A1,D5:E5,Z10") ' <----Change the range ColNum = ColNum + 1 Newsh.Cells(RwNum, ColNum).Formula = _ "='" & Sh.Name & "'!" & myCell.Address(False, False) Next myCell End If Next Sh Newsh.UsedRange.Columns.AutoFit With Application .Calculation = xlCalculationAutomatic .ScreenUpdating = True End With End Sub Private Sub Workbook_SheetActivate(ByVal Sh As Object) MsgBox Sh.Name End Sub CTRL+PAGE UP, CTRL PAGE DOWN OLAYI PTAL Sheets("sayfa1").Select End Sub
Private Sub Wo
textbox'larla uramamak iin inputbox kullandm, onu deitirirsiniz. Kodunuzdaki hata elseif iin art dng iinde kullandnz iin her halikarda salanm oluyor. yani (ElseIf Worksheets(sayfa).Name <> sayfaadi Then ) visual basic kodu: -------------------------------------------------------------------------------Sub sayfalar() sayfaadi = InputBox("sayfaadi") For sayfa = 1 To Worksheets.Count If Worksheets(sayfa).Name = sayfaadi Then Worksheets(sayfaadi).Select Range("a4").Value = 11 Exit Sub End If Next sayfa Worksheets.Add ActiveSheet.Name = sayfaadi ActiveSheet.Select Range("a4").Value = 111 End Sub activesheet.usedrange.select veya, C2 den balayarak C stunundaki son dolu hcreye kadar seim: range("c2:c" & cells(65536, 3).end(xlup).row).select baka bir yazm ekli de; range("c2:c" & range("c65536").end(xlup).row).select activesheet.usedrange.select veya, C2 den balayarak C stunundaki son dolu hcreye kadar seim: range("c2:c" & cells(65536, 3).end(xlup).row).select baka bir yazm ekli de; range("c2:c" & range("c65536").end(xlup).row).select
Dim sayfamenu As CommandBar, pir As CommandBarButton, sh As Worksheet On Error Resume Next Application.CommandBars("menuler").Delete On Error GoTo 0 Set sayfamenu = CommandBars.Add(Name:="SayfaMen", temporary:=True) With sayfamenu .Position = msoBarFloating .Visible = True End With For Each sh In ActiveWorkbook.Sheets Set pir = sayfamenu.Controls.Add(Type:=msoControlButton) With pir .Style = msoButtonCaption .Caption = Left(sh.Name & " ", 16) .Tag = sh.Name .OnAction = "Start" .BeginGroup = True End With Next sh Set pir = sayfamenu.Controls.Add(Type:=msoControlButton) With pir .Style = msoButtonCaption .Caption = "sayfa geii" .OnAction = "sheets_menu" .BeginGroup = True End With sayfamenu.Width = 1 End Sub Sub Start() Sheets(Application.CommandBars.ActionControl.Tag).Activate End Sub thisworkbook a Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.CommandBars("menuler").Delete On Error GoTo 0 End Sub Private Sub Workbook_Open() Call sheets_menu End Sub Levetn beyin yapt kodu devam ediyorum. Aadaki ekle getirirseniz liste sayfasnda hangi satrda iseniz o satr veri giri sayfasna tar. Kod: Sub kaydet2() a = ActiveCell.Row Sheets("liste").Range("A" & a & ":G" & a).Copy Sheets("veri").Range("B2").PasteSpecial , , , True Application.CutCopyMode = False End Sub
Sub InsertHeaderFooter() ' inserts the same header/footer in all worksheets Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In ActiveWorkbook.Worksheets Application.StatusBar = "Changing header/footer in " & ws.Name With ws.PageSetup .LeftHeader = "Company name" .CenterHeader = "Page &P of &N" .RightHeader = "Printed &D &T" .LeftFooter = "Path : " & ActiveWorkbook.Path .CenterFooter = "Workbook name &F" .RightFooter = "Sheet name &A" End With Next ws Set ws = Nothing Application.StatusBar = False End Sub Range("A65536").Select If InputBox("ifre Gir?", "ifre") = "123" Then Range("A1").Select Else MsgBox ("ifre Yanl") Sheets("Sayfa1").Select End If End Sub sonra al makrusuna u kodu ekleyin Kod: Sub Auto_Open() [b]Sheets("Gizli Sayfa").Visible = True[/b] End Sub Burada mantk u Makrolar etkinletirlmesse sayfa grnmez. Etkinletirldiinde ise o sayfaya tklandnda sayfann kod blmne u kodu ekleyin Kod:
'
Private Sub Worksheet_Activate() Dim sifre Dim durum git: sifre = Application.InputBox("Ltfen Kullanc Kodunu Giriniz", _ "Sayn ; " & Application.UserName, "ifre") If sifre = Empty Then Sheets("DierSayfa").Select If sifre <> "ifre" Then durum = MsgBox("Girdiiniz ifre Yanltr " _ & vbNewLine & "Ltfen doru ifre giriniz." _ & vbNewLine & "Tekrar ifre Girmek stiyormusunuz", vbYesNo, Application.UserName) If durum = vbYes Then GoTo git Else MsgBox "ifre Dorudur.....!", vbInformation, Application.UserName Exit Sub End If Sheets("DierSayfa").Select End Sub Sub sirala() For a = 1 To Sheets.Count For b = a + 1 To Sheets.Count If LCase(Sheets(b).Name) > LCase(Sheets(a).Name) Then GoTo 100 Sheets(b).Move before:=Sheets(a) 100 Next Next End Sub
Dim SheetNames() As String Dim SheetHidden() As Boolean Dim i As Integer Dim SheetCount As Integer Dim VisibleWins As Integer Dim Item As Object Dim OldActive As Object If ActiveWorkbook Is Nothing Then Exit Sub SheetCount = ActiveWorkbook.Sheets.Count If ActiveWorkbook.ProtectStructure Then MsgBox ActiveWorkbook.Name & " is protected.", _ vbCritical, "Cannot Sort Sheets." Exit Sub End If Application.EnableCancelKey = xlDisabled SheetCount = ActiveWorkbook.Sheets.Count ReDim SheetNames(1 To SheetCount) ReDim SheetHidden(1 To SheetCount) Set OldActive = ActiveSheet For i = 1 To SheetCount SheetNames(i) = ActiveWorkbook.Sheets(i).Name Next i For i = 1 To SheetCount SheetHidden(i) = Not ActiveWorkbook.Sheets(i).Visible If SheetHidden(i) Then ActiveWorkbook.Sheets(i).Visible = True Next i Call BubbleSort(SheetNames) Application.ScreenUpdating = False For i = 1 To SheetCount ActiveWorkbook.Sheets(SheetNames(i)).Move _ before:=ActiveWorkbook.Sheets(i) Next i For i = 1 To SheetCount If SheetHidden(i) Then ActiveWorkbook.Sheets(i).Visible = False Next i OldActive.Activate End Sub Sub BubbleSort(List() As String) Dim First As Integer Dim Last As Integer Dim i As Integer Dim j As Integer Dim Temp As String First = LBound(List) Last = UBound(List) For i = First To Last - 1 For j = i + 1 To Last If UCase(List(i)) > UCase(List(j)) Then Temp = List(j) List(j) = List(i) List(i) = Temp End If Next j Next i End Sub
Sub sirala() For a = 1 To Sheets.Count For b = a + 1 To Sheets.Count If LCase(Sheets(b).Name) > LCase(Sheets(a).Name) Then GoTo 10 Sheets(b).Move before:=Sheets(a) 10 Next Next End SortSheetUp() Sub Sub Dim iMax As Integer Dim tb1 As Integer Dim tb2 As Integer Application.ScreenUpdating = False iMax = ThisWorkbook.Sheets.Count For tb1 = 1 To iMax For tb2 = tb1 To iMax If UCase(Sheets(tb2).Name) _ < UCase(Sheets(tb1).Name) Then Sheets(tb2).Move before:=Sheets(tb1) End If Next tb2 Next tb1 Application.ScreenUpdating = True End Sub Sub SortSheetDown() Dim iMax As Integer Dim tb1 As Integer Dim tb2 As Integer Application.ScreenUpdating = False iMax = ThisWorkbook.Sheets.Count For tb1 = 1 To iMax For tb2 = tb1 To iMax If UCase(Sheets(tb2).Name) _ > UCase(Sheets(tb1).Name) Then Sheets(tb2).Move before:=Sheets(tb1) End If Next tb2 Next tb1 Application.ScreenUpdating = True End Sub Son sayfa hari tm sayfalar gizler Sub xlVeryHidden_All_Sheets() On Error Resume Next Dim sh As Worksheet For Each sh In Worksheets sh.Visible = xlVeryHidden Next End Sub
Dim dlg As DialogSheet ' global variable Sub SheetNavigation() Dim ws As Worksheet Application.ScreenUpdating = False Set dlg = ActiveWorkbook.DialogSheets.Add With dlg.DialogFrame .Left = 0 .Top = 0 .Height = 300 ' dialog height .Width = 300 ' dialog width End With dlg.Buttons(1).Left = 245 ' position of button1 dlg.Buttons(2).Left = 245 ' position of button2 With dlg.ListBoxes.Add(10, 15, 230, 275) ' size of listbox For Each ws In ActiveWorkbook.Worksheets If ws.Visible Then .AddItem ws.Name Next ws .ListIndex = 0 .OnAction = "DisplaySheet" End With dlg.DialogFrame.Text = "Select the worksheet you want to activate" dlg.Visible = False Application.ScreenUpdating = True If dlg.Show Then Worksheets(dlg.ListBoxes(1).List(dlg.ListBoxes(1).ListIndex)).Activate End If Application.DisplayAlerts = False dlg.Delete Application.DisplayAlerts = True Set ws = Nothing Set dlg = Nothing End Sub Private Sub DisplaySheet() Sheets(dlg.ListBoxes(1).List(dlg.ListBoxes(1).ListIndex)).Activate End Sub Public Sub ProtectGroupedSheets() Const csPASSWD As String = "drowssap" Dim mySheets As Sheets Dim actSheet As Worksheet Dim wkSht As Worksheet Set actSheet = ActiveSheet Set mySheets = ActiveWindow.SelectedSheets actSheet.Select For Each wkSht In mySheets wkSht.Protect Password:=csPASSWD Next wkSht actSheet.Select mySheets.Select False End Sub Sub BlattName() For Blatt = 2 To ActiveWorkbook.Sheets.Count Sheets(1).Cells(Blatt, 1).Select Sheets(Blatt).Name = Sheets(1).Cells(Blatt, 1) ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _ Sheets(Blatt).Name & "!A1", TextToDisplay:=ActiveCell.Formula Next Blatt Sheets(1).Select End Sub
Sub Auto_Open() MyMenu Range("A1").Select End Sub Sub MyMenu() On Error Resume Next If Not MyControl Is Nothing Then GoTo ResumeSub: Set MyControl = CommandBars.FindControl(Type:=msoControlComboBox, Tag:="MyMenu", Visible:=True) MyControl.Delete On Error GoTo 0 Set MyBar = Application.CommandBars("standard") Set NewCombo = MyBar.Controls.Add(Type:=msoControlComboBox) ResumeSub: With NewCombo .Clear .Text = "Sayfa secin" .Tag = "MyMenu" .Width = 150 .Text = ActiveSheet.Name For i = 1 To Worksheets.Count .AddItem Sheets(i).Name, i Next .DropDownLines = 5 .DropDownWidth = 90 .OnAction = "MyCombo" End With Set NewCombo = Nothing Set MyBar = Nothing Set MyControl = Nothing End Sub ' Sub MyCombo() Set MyControl = CommandBars.FindControl(Type:=msoControlComboBox, Tag:="MyMenu", Visible:=True) Sheets(MyControl.Text).Select Set MyControl = Nothing End Sub ' Sub DelMyMenu() Set MyControl = CommandBars.FindControl(Type:=msoControlComboBox, Tag:="MyMenu", Visible:=True) MyControl.Delete Set MyControl = Nothing End Sub ' Sub Auto_Close() DelMyMenu End Sub Sub Alle_auswhlen() ReDim Matrixvariable(1 To Sheets.Count) For Each Blattname In Sheets Blattzhler = Blattzhler + 1 Matrixvariable(Blattzhler) = Blattname.Name Next For y = 1 To Blattzhler Next Sheets(Matrixvariable()).Select With Selection.Font .Name = "Arial" .Size = 14 End With End Sub Sub sayfa_sirala() Dim intI As Integer, intJ As Integer For intI = 1 To Sheets.Count For intJ = 1 To Sheets.Count - 1 If UCase(Sheets(intJ).Name) > UCase(Sheets(intJ + 1).Name) Then Sheets(intJ).Move after:=Sheets(intJ + 1) End If Next Next End Sub
Sub MappeDrucken() Dim Sh As Worksheet For Each Sh In Worksheets If Sh.Visible = True Then Sh.PrintPreview End If Next Sh End Sub Sub SortSheets() Dim i As Integer, j As Integer For i = 1 To Sheets.Count For j = 1 To Sheets.Count - 1 If UCase$(Sheets(j).Name) < UCase$(Sheets(j + 1).Name) Then Sheets(j).Move after:=Sheets(j + 1) End If Next j Next i End Sub Sub AllsheetsInOpenBooks() 'Example in http://www.mvps.org/dmcritchie/excel/collections.htm Dim wkBook As Workbook, wkSheet As Worksheet ' 2001-11-24 Dim iRow As Long, iSheet As Long: iRow = 1 'Create a new sheet in the current workbook ' added Private Sub CommandButton1_Click() Bastar = TextBox1 SonTar = TextBox2 Set S1 = Sheets("RAPOR") Range("A2:F4500").Select Selection.ClearContents Range("A2").Select SAYAC = 1 For sayfa = 1 To Worksheets.Count Worksheets(sayfa).Select If ActiveSheet.Name <> "RAPOR" Then 'If [B1] <> "RAPOR" Then Range("b3").Select Do While ActiveCell.Value <> "" If Format(ActiveCell.Value, "dd/mm/yyyy") >= Bastar And Format(ActiveCell.Value, "dd/mm/yyyy") <= SonTar Then S1.Cells(1 + SAYAC, 1).Value = SAYAC S1.Cells(1 + SAYAC, 2).Value = ActiveCell.Value S1.Cells(1 + SAYAC, 3).Value = ActiveCell.Offset(0, 1).Value S1.Cells(1 + SAYAC, 4).Value = ActiveCell.Offset(0, 2).Value S1.Cells(1 + SAYAC, 5).Value = ActiveCell.Offset(0, 3).Value S1.Cells(1 + SAYAC, 6).Value = ActiveCell.Offset(0, 4).Value SAYAC = SAYAC + 1 End If ActiveCell.Offset(1, 0).Select Loop End If Next End Sub
Dim I As Integer For I = 1 To ThisWorkbook.Worksheets.Count MsgBox ThisWorkbook.Worksheets(I).Name & _ " has Index = " & ThisWorkbook.Worksheets(I).Index Next I End Sub Public Sub InsertChartsBeforeWorksheets()'grafik Dim Worksheet1 As Worksheet For Each Worksheet1 In Worksheets Charts.Add Before:=Sheets(Worksheet1.Index) Next Worksheet1 End Sub Public Sub InsertChartsBeforeWorksheets2() Dim Worksheet1 As Worksheet For Each Worksheet1 In Worksheets Charts.Add Before:=Worksheet Next Worksheet1 End Sub Public Sub InsertChartsAfterWorksheets() Dim Worksheet1 As Worksheet Dim Chart1 As Chart For Each Worksheet1 In Worksheets Set Chart1 = Charts.Add Chart1.Move After:=Worksheet1 Next Worksheet1 End Sub Sub Menu() Application.CommandBars("Workbook tabs").ShowPopup 930, 30 End Subblmne; Module Global WCnt Global Sh(1 To 100) As Worksheet Global ShNames(1 To 100) As String 'workbook'un code una; Public Sub Workbook_Open() Dim i As Integer WCnt = Worksheets.Count For i = 1 To WCnt ShNames(i) = Sheets(i).Name Set Sh(i) = Sheets(ShNames(i)) Next i End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim z As Integer For z = 1 To WCnt Sh(z).Name = ShNames(z) Next z End Sub SAYFA KISA YOLLARINI EKRANA GETRR Sub Menu() Application.CommandBars("Workbook tabs").ShowPopup 500, 150 End Sub
ThisWorkbook modulne yerletirilecek kodlar: visual basic kodu: -------------------------------------------------------------------------------Private Sub Workbook_BeforeClose(Cancel As Boolean) If ActiveSheet.Name = "Liste2" Then Cancel = True End If End Sub Sub tester() Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets With ws.PageSetup .LeftHeader = "&A" .LeftFooter = "Page &P of &N" End With Next ws End Sub Sub top() Application.GoTo Reference:=ActiveSheet.Range("A1"), Scroll:=True End Sub Sub copysheets() Dim iMax As Integer Dim tb1 As Integer Dim tb2 As Integer Dim ws As String ws = InputBox("Bitte geben Sie einen neuen TabBlattNamen ein") Sheets("Blanko_zum_Kopieren").Copy After:=Sheets(1) 'TabBlattName anpassen Sheets("Blanko_zum_Kopieren (2)").Name = ws Application.ScreenUpdating = False iMax = ActiveWorkbook.Sheets.Count For tb1 = 1 To iMax For tb2 = tb1 To iMax If UCase(Sheets(tb2).Name) _ < UCase(Sheets(tb1).Name) Then Sheets(tb2).Move before:=Sheets(tb1) End If Next tb2 Next tb1 Application.ScreenUpdating = True End Sub Sub PfadInFusszeile() ActiveSheet.PageSetup.LeftFooter = ActiveSheet.Parent.FullName End Sub Sub PfadInFusszeile() ActiveSheet.PageSetup.LeftFooter = ActiveSheet.Parent.FullName End Sub Private Sub Worksheet_Change(ByVal Target As Excel.Range) If IsEmpty(Target) Then Exit Sub If Target = "1" Then Target = "le Milli Eitim Mdrl" If Target = "2" Then Target = "Ahmet Akn KKKAYA" If Target = "3" Then Target = "Ordu li Kabata lesi" If Target = "4" Then Target = "Kabata" End Sub Sub LimiteDefilement() ActiveSheet.ScrollArea = "A1:A10" End Sub Sub RetablitDefilement() ActiveSheet.ScrollArea = "" End Sub
alma sayfalarnz yaptktan sonra makro altrlr v e bulunduunuz sayfann aktif hcresinden aaya doru sayfalarnza kpr atlr Sub Tabellennamen_auflisten() Dim i As Integer Dim myRange As Range Set myRange = ActiveCell myRange.Resize(Worksheets.Count).Select If (MsgBox("UYARI: Sayfalara kpr oluturulacak... !" & vbCrLf & _ Chr(13) & " Emin misin ?", vbYesNo)) _ <> vbYes Then Exit Sub For i = 1 To Worksheets.Count With myRange.Cells(i) .Value = Worksheets(i).Name .Hyperlinks.Add _ Anchor:=myRange.Cells(i), _ Address:="", _ SubAddress:=.Value & "!" & .Address, _ ScreenTip:="Blatt (" & .Value & ")", _ TextToDisplay:=.Value End With Next i myRange.Select MsgBox (" Toplam ") & ThisWorkbook.Worksheets.Count & _ (" alma sayfasna kpr oluturuldu"), vbOKOnly, ThisWorkbook.Name End Sub
'Cetvelin llerini tanmla Const Ruler_Width As Double = 16 ' Genilik 16 cm Const Ruler_Height As Double = 14 ' Ykseklik 14 cm ' Ekran boyutu ve yazcdaki gerek boyut Const Screen_Width As Double = 16 Const Screen_Height As Double = 14 Const Printer_Width As Double = 16 Const Printer_Height As Double = 14 Dim i As Long Dim l As Long Dim x As Long Dim y As Long Dim ws As Worksheet Dim x2 As Double Dim y2 As Double x = Ruler_Width * 10 y = Ruler_Height * 10 Application.ScreenUpdating = False Set ws = ActiveSheet Worksheets.Add ActiveSheet.Move ActiveSheet.Lines.Add 0, 0, 3 * x, 0 For i = 1 To x If i Mod 10 = 0 Then l = 5 Else: If i Mod 5 = 0 Then l = 4 Else l = 3 ActiveSheet.Lines.Add 3 * i, 0, 3 * i, 3 * l Next ActiveSheet.Lines.Add 0, 0, 0, 3 * y For i = 1 To y If i Mod 10 = 0 Then l = 5 Else: If i Mod 5 = 0 Then l = 4 Else l = 3 ActiveSheet.Lines.Add 0, 3 * i, 3 * l, 3 * i Next ActiveSheet.Lines.Border.ColorIndex = 55 For i = 10 To x - 1 Step 10 With ActiveSheet.TextBoxes.Add(3 * i - 9, 3 * 5, 18, 12) .Text = Format(i \ 10, "!@@") End With Next For i = 10 To y - 1 Step 10 With ActiveSheet.TextBoxes.Add(3 * 5, 3 * i - 9, 12, 1) .Orientation = xlDownward .Text = Format(i \ 10, "!@@") End With Next With ActiveSheet.TextBoxes .Font.Size = 9 .Font.ColorIndex = 55 .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .Border.ColorIndex = xlNone .Interior.ColorIndex = xlNone End With With ActiveSheet.DrawingObjects.Group .Placement = xlFreeFloating .Width = Application.CentimetersToPoints(x / 10) .Height = Application.CentimetersToPoints(y / 10) .CopyPicture xlScreen, xlPicture ActiveSheet.Paste x2 = (Selection.Width - .Width) / 3 y2 = (Selection.Height - .Height) / 3 Selection.Delete .CopyPicture xlPrinter, xlPicture ActiveSheet.Paste .Width = .Width * .Width/(Selection.Width - _ x2 * 2)*Screen_Width/Printer_Width .Height = .Height * .Height/(Selection.Height - _ y2 * 2)*Screen_Height/Printer_Height Selection.Delete If Val(Application.Version) >= 9 Then .Copy ActiveSheet.PasteSpecial 'Format:="Picture (PNG)" With Selection.ShapeRange.PictureFormat .CropLeft = x2 .CropTop = y2 .CropRight = x2 .CropBottom = y2 End With Selection.Copy ws.Activate
Sayfa, CommandButton ve makro isimlerini kendi almana gre dzenle Private Sub CommandButton1_Click() Select Case ActiveSheet.Name Case "Sheet1" Makro1 Case "Sheet2" Makro2 Case "Sheet3" Makro3 Case Else Makro4 End Select Unload Me End Sub Sheets("Sayfa1").Name = "Sayfa1" Bu resim ekleme makrosu. Sub ekle() Range("A3").Select resimadi = Range("A1").Text & ".jpg" ActiveSheet.Pictures.Insert("C:\DEN\Resim\" & resimadi).Select Selection.ShapeRange.LockAspectRatio = msoFalse Selection.ShapeRange.Height = 198.75 Selection.ShapeRange.Width = 226.5 Selection.ShapeRange.Rotation = 0# End Sub Silme makrosu da alyor fakat butonlar da siliyor. O imdilik muallakta kalsn yada bir karde el atsn Sub sil() ActiveSheet.Shapes.SelectAll Selection.Delete Range("I7").Select End Sub Sub Protection() ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub Sub KorumaKaldir() Dim ws As Worksheet For Each ws In Worksheets ws.Unprotect ("a") Next End Sub Sub KorumaKoy() Dim ws As Worksheet For Each ws In Worksheets ws.Protect ("a") Next End Sub Sub BlattSchutzAus() Dim wks As Worksheet For Each wks In ThisWorkbook.Worksheets wks.Unprotect Password:="a" Next wks End Sub Sub BlattSchutzEin() Dim wks As Worksheet For Each wks In ThisWorkbook.Worksheets wks.Protect Password:="a" Next wks End Sub Sub deneme() Sheets("Sayfa1").Unprotect Password:="sifre" 'Buraya sizin kodlarnz yazn...... Sheets("Sayfa1").Protect Password:="sifre" End Sub
Private Sub Worksheet_Activate() Range("A65536").Select If InputBox("ifre Gir?", "ifre") = "123" Then Range("A1").Select Else MsgBox ("ifre Yanl") Sheets("Sayfa2").Select End If End Sub Worksheets("Sayfaismi").Activate Sub SetValue() Worksheets("Sheet1").Activate ActiveCell.Value = 35 End Sub Worksheets("Sayfaismi") ' sayfa ad ile Worksheets(2) ' sayfa indeksi ile Dim ws As Worksheet Set ws =ThisWorkbook.Worksheets("Sayfa1") Sub HeaderName() ActiveSheet.PageSetup.LeftHeader = ThisWorkbook.FullName ActiveSheet.PrintPreview End Sub Sayfa Gizle Sub auto_open() Worksheets("Sayfa1").Visible = False End Sub Worksheets("Kedi2").Visible = False ' Sayfay gizler Worksheets("Kedi2").Visible = True ' Sayfay grnr yapar Sheet1.Visible = xlSheetVeryHidden Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) MsgBox "Impossible d'enregistrer" Cancel = False End Sub Sub Add_Sheet() Dim wSht As Worksheet Dim shtName As String shtName = Format(Now - 1, "dd.mm") For Each wSht In Worksheets If wSht.Name = shtName Then MsgBox "Sheet already exists...Make necessary " & _ "corrections and try again." Exit Sub End If Next wSht Sheets.Add.Name = shtName Sheets(shtName).Move After:=Sheets(Sheets.Count) Sheets("Ana_Sayfa").Range("A2:F50").Copy _ Sheets(shtName).Range("A1") End Sub Sub Spalten_trotz_Blattschutz_ausblenden() ActiveSheet.Protect userinterfaceonly:=True Columns("C:C").Select Selection.EntireColumn.Hidden = True End Sub Worksheets("Kedi2").Delete Sub Go2sheet() myShts = ActiveWorkbook.Sheets.Count For i = 1 To myShts myList = myList & i & " - " & ActiveWorkbook.Sheets(i).Name & " " & vbCr Next i Dim mySht As Single mySht = InputBox("Select sheet to go to." & vbCr & vbCr & myList) Sheets(mySht).Select End Sub
Sub onizleme() ActiveWindow.SelectedSheets.PrintPreview ActiveSheet.DisplayAutomaticPageBreaks = False 'sayfa sonlarn gstermez End Sub Sub onizleme() ActiveWindow.SelectedSheets.PrintPreview ActiveSheet.DisplayAutomaticPageBreaks = False 'sayfa sonlarn gstermez End Sub Sub ProtectFeuil() Dim sht As Worksheet Dim MotPass MotPass = InputBox("Taper un mot de passe", 2) For Each sht In ActiveWorkbook.Worksheets sht.Protect Password:=(MotPass), Contents:=True, _ DrawingObjects:=True, Scenarios:=True Next sht End Sub Tam ekran iin: Sub tam() Application.DisplayFullScreen = True End Sub ' Normal grnm iin: Sub normal() Application.DisplayFullScreen = False End Sub Sub AktifSayfayiSil() Application.DisplayAlerts = False ActiveSheet.Delete Application.DisplayAlerts = True End Sub Sub PrintRpt1() Sheets(1).PageSetup.Orientation = xlLandscape Range("a1").PrintOut Copies:=1 End Sub Sub HeaderName() ActiveSheet.PageSetup.LeftHeader = _ ThisWorkbook.FullName ActiveSheet.PrintPreview End Sub Sayfa Gizle Sub auto_open() Worksheets("Sayfa1").Visible = False End Sub Sub aktifsayfayazdir() Dim Kopyasays As Long Dim Kopyanumaras As Long Kopyasays = Application.InputBox("Ka kopya alacaksnz", Type:=1) For Kopyanumaras = 1 To Kopyasays ActiveSheet.PrintOut Next Kopyanumaras End Sub Sub NumeroDeLigne() NumeroLigne = Cells.Find("100").Row MsgBox NumeroLigne End Sub TextBox1.text = format(xxxx,"0.00") Sub SayiOlanHucreSay() 'Returns a count of non-blank cells in a selection Dim myCount As Integer 'using the Count ws function (only counts numbers, no text) myCount = Application.Count(Selection) MsgBox "Seili alandaki bo olmayan ve rakam ieren hcre says: " _ & myCount, vbInformation, "Rakaml Hcre Say" End Sub
Function Uret(Basamak) ReDim Sayi(0 To Basamak) For i = 1 To Basamak YeniSayiTut: Randomize If i = 1 Then Sayi(i) = Int(Rnd * 9) + 1 Else Sayi(i) = Int(Rnd * 10) End If For j = 1 To i - 1 If Sayi(i) = Sayi(j) Then GoTo YeniSayiTut Next j retStr = retStr & Sayi(i) Next i Uret = Val(retStr) End Function Sub MoveMinus() On Error Resume Next Dim cel As Range Dim myVar As Range Set myVar = Selection For Each cel In myVar If Right((Trim(cel)), 1) = "-" Then cel.Value = cel.Value * 1 End If Next With myVar .NumberFormat = "#,##0.00_);[Red](#,##0.00)" .Columns.AutoFit End With End Sub
[code]Sub bicim() [A2].Value = Abs(1) End Sub[/code] Kod: Sub bicim2() [A2].Value = Atn(1) * 1 End Sub Kod: Sub bicim3() '/- saylar yuvarla '/- 101 saysn dndrr [A2].Value = Int(100.9 + 0.5) End Sub Kod: Sub bicim4() '/- saylar yuvarla '/- 100 saysn dndrr [A2].Value = Int(100.4 + 0.5) End Sub Kod: Sub bicim5() '/- saylar yuvarla '/- eksi 101 saysn dndrr [A2].Value = Int(-100.9 + 0.5) End Sub Kod: Sub bicim6() '/- saylar yuvarla '/- eksi 100 saysn dndrr [A2].Value = Int(-100.4 + 0.5) End Sub Kod: Sub bicim7() '/- belirtilen sayda ondalk basamaa yuvarlanm olan nmerik bir terim dndrr '/- eksi 3 saysn dndrr [A2].Value = Round(3, 49) End Sub Kod: Sub bicim8() '/- belirtilen sayda ondalk basamaa yuvarlanm olan nmerik bir terim dndrr '/- eksi 4 saysn dndrr [A2].Value = Round(3, 51) End Sub [code]Sub bicim() [A2].Value = Abs(1) End Sub[/code] Sub bicim2() [A2].Value = Atn(1) * 1 End Sub Sub bicim3() '/- belirtilen sayda ondalk basamaa yuvarlanm olan nmerik bir terim dndrr '/- eksi 3 saysn dndrr [A2].Value = Round(3, 49) End Sub Sub bicim4() '/- belirtilen sayda ondalk basamaa yuvarlanm olan nmerik bir terim dndrr '/- eksi 4 saysn dndrr [A2].Value = Round(3, 51) End Sub
'Kullanm; Excel tablosu iindeki hcreye =Yaziyla(A1) eklindedir. A1 iinde say bulunan hcreyi temsil eder. Fonksiyon; Microsoft Excel, Access, Visual B Function Yaziyla(Sayi#) ReDim birler$(10), onlar$(10), basamak$(5) birler$(0) = "": birler$(1) = "Bir" birler$(2) = "ki": birler$(3) = "" birler$(4) = "Drt": birler$(5) = "Be" birler$(6) = "Alt": birler$(7) = "Yedi" birler$(8) = "Sekiz": birler$(9) = "Dokuz" onlar$(0) = "": onlar$(1) = "On" onlar$(2) = "Yirmi": onlar$(3) = "Otuz" onlar$(4) = "Krk": onlar$(5) = "Elli" onlar$(6) = "Altm": onlar$(7) = "Yetmi" onlar$(8) = "Seksen": onlar$(9) = "Doksan" basamak$(1) = "": basamak$(2) = "Bin" basamak$(3) = "Milyon": basamak$(4) = "Milyar" basamak$(5) = "Trilyon" virgul2$ = "": cevap$ = "": onda$ = "" Say$ = Str$(Sayi#) virgul% = InStr(1, Say$, ".") If virgul% Then Say$ = Right$(Say$, Len(Say$) - virgul%) Select Case Len(Say$) Case 6: onda$ = "milyonda" Case 5: onda$ = "yzbinde" Case 4: onda$ = "onbinde" Case 3: onda$ = "binde" Case 2: onda$ = "yzde" Case 1: onda$ = "onda" End Select GoSub cevir virgul2$ = " virgl " + onda$ + " " + cevap$ cevap$ = "" Say$ = Str$(Sayi#) Say$ = Left(Say$, virgul% - 1) End If GoSub cevir Yaziyla = cevap$ + virgul2$ Exit Function cevir: x% = Len(Say$) Say$ = String$(3 - (x% - Int(x% / 3) * 3), 48) + Say$ x% = Len(Say$) / 3 For i% = 1 To x% uclu$ = Mid$(Say$, Len(Say$) - i% * 3 + 1, 3) Y% = Val(Mid$(uclu$, 1, 1)) O% = Val(Mid$(uclu$, 2, 1)) b% = Val(Mid$(uclu$, 3, 1)) yazi$ = "" If Y% <> 0 Then If Y% > 1 Then yazi$ = birler$(Y%) yazi$ = yazi$ + "Yz" End If yazi$ = yazi$ + onlar$(O%) + birler$(b%) If yazi$ <> "" Then If LCase(yazi$) = "bir" And i% = 2 Then yazi$ = "" cevap$ = yazi$ + basamak$(i%) + cevap$ End If Next i% Return End Function Hcreye 12345 yazn ve aadaki kodu altrn. Sub Round() ActiveCell = Application.round(ActiveCell, -3) End Sub 1000 ile 13000 arasnda yukar yuvarlar ActiveCell = Application.Ceiling(ActiveCell, 1000) 1000 ile 12000 arasnda aa yuvarlar. ActiveCell = Application.Floor(ActiveCell, 1000)
rnek textbox1=150 'textbox2=2 dakika 30saniye Private Sub CommandButton1_Click() Dim Isec As Integer Isec = Val(TextBox1.Text) BreakSec = Str$(Int(Isec / 60)) & " dakika " & Str$(Isec Mod 60) & " saniye " TextBox2.Text = BreakSec End Sub
Dim sDollars As String Dim sCents As String Dim iLen As Integer Dim sTemp As String Dim iPos As Integer Dim iHundreds As Integer Dim iTens As Integer Dim iOnes As Integer Dim sUnits(2 To 5) As String Dim bHit As Boolean Dim vOnes As Variant Dim vTeens As Variant Dim vTens As Variant If Not IsNumeric(vNumber) Then Exit Function End If sDollars = Format(vNumber, "###0.00") iLen = Len(sDollars) - 3 If iLen > 15 Then DollarText = CVErr(xlErrNum) Exit Function End If sCents = Right$(sDollars, 2) & "/100 Dollar" 'Hier die Whrung ndern If vNumber < 1 Then DollarText = sCents Exit Function End If sDollars = Left$(sDollars, iLen) vOnes = Array("", "one", "two", "three", "four", "five", _ "six", "seven", "eight", "nine") vTeens = Array("ten", "eleven", "twelve", "thirteen", "fourteen", _ "fifteen", "sixteen", "seventeen", "eighteen", "nineteen") vTens = Array("", "", "twenty", "thirty", "forty", "fifty", _ "sixty", "seventy", "eighty", "ninety") sUnits(2) = "thousand" sUnits(3) = "million" sUnits(4) = "billion" sUnits(5) = "trillion" sTemp = "" For iPos = 15 To 3 Step -3 If iLen >= iPos - 2 Then bHit = False If iLen >= iPos Then iHundreds = Asc(Mid$(sDollars, iLen - iPos + 1, 1)) - 48 If iHundreds > 0 Then sTemp = sTemp & " " & vOnes(iHundreds) & " hundred" bHit = True End If End If iTens = 0 iOnes = 0 If iLen >= iPos - 1 Then iTens = Asc(Mid$(sDollars, iLen - iPos + 2, 1)) - 48 End If If iLen >= iPos - 2 Then iOnes = Asc(Mid$(sDollars, iLen - iPos + 3, 1)) - 48 End If If iTens = 1 Then sTemp = sTemp & " " & vTeens(iOnes) bHit = True Else If iTens >= 2 Then sTemp = sTemp & " " & vTens(iTens) bHit = True End If If iOnes > 0 Then If iTens >= 2 Then sTemp = sTemp & "-" Else sTemp = sTemp & " " End If sTemp = sTemp & vOnes(iOnes) bHit = True End If End If If bHit And iPos > 3 Then sTemp = sTemp & " " & sUnits(iPos \ 3) End If End If Next iPos
Sub DashMasher() On Error Resume Next Application.Calculation = xlCalculationManual Application.ScreenUpdating = False Set TextCells = Cells.SpecialCells(xlCellTypeConstants, xlTextValues) n = TextCells.Count For Each Cell In TextCells x = Cell.Value If Right(x, 1) = "-" Then x = -Left(x, Len(x) - 1) Cell.Value = x End If c=c+1 Application.StatusBar = "Percent Complete: " & Int(c / n * 100) & "%" Next Cell Application.StatusBar = False Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic End Sub
If Not IsNumeric(sayi) Then GoTo hata If (para - Int(para)) = 0 Then paracevir= cevir(para) Else tamsayi = cevir(Int(para)) ondalik = cevir((para - Int(para)) * 100) ondalik = LCase(Mid(ondalik, 1, 1)) + Mid(ondalik, 2, Len(ondalik) - 1) paracevir = tamsayi + "virgl" + ondalik End If GoTo tamam hata: paracevir = "Hata" tamam: End Function Private Function cevir(sayi As Double) Dim b(9) As String Dim y(9) As String Dim m(4) As String Dim v(15) Dim c(3) b(0) b(1) b(2) b(3) b(4) b(5) b(6) b(7) b(8) b(9) y(0) y(1) y(2) y(3) y(4) y(5) y(6) y(7) y(8) y(9) = "" = "bir" = "iki" = "" = "drt" = "be" = "alt" = "yedi" = "sekiz" = "dokuz" = "" = "on" = "yirmi" = "otuz" = "krk" = "elli" = "altm" = "yetmi" = "seksen" = "doksan" = "trilyon" = "milyar" = "milyon" = "bin" = ""
a = Str(Round(sayi, 0)) If Left(a, 1) = " " Then pozitif = 1 Else pozitif = 0 a = Right(a, Len(a) - 1) If Len(a) > 15 Then GoTo hata a = String(15 - Len(a), "0") + a For x = 1 To 15 v(x) = Val(Mid(a, x, 1)) Next x s = "" For x = 0 To 4 c(1) = v(x * 3 + 1) c(2) = v(x * 3 + 2) c(3) = v(x * 3 + 3) If c(1) = 0 Then e = "" ElseIf c(1) = 1 Then e = "yz" Else e = b(c(1)) + "yz" End If e = e + y(c(2)) + b(c(3)) If e <> "" Then e = e + m(x) If (x = 3) And (e = "birbin") Then e = "bin" s=s+e Next x
lgili sayy sqr() ile karekk olarak dntrebilirsiniz. rnek A1 de saymz olsun; Kod: Sub karekok() sonuc = Sqr(Range("A1").Value) MsgBox (sonuc) End Sub Sub Einfgen() Dim Letzte As Long Dim Zeile As Integer Dim I As Long Letzte = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row Zeile = Application.InputBox("Nach wieviel Zeilen Leerzeile einfgen", "Zeilenanzahl", 0, Type:=1) If Zeile = 0 Then Exit Sub For I = Letzte To 2 Step Zeile * -1 Rows(I).Insert Shift:=xlDown Next I End Sub Sub CenterAcrossColumns() With Selection .HorizontalAlignment = xlCenterAcrossSelection .MergeCells = False End With End Sub Selection.PrintOut Copies:=2 Sheets("Sayfa1").PageSetup.PrintArea = "$A$1:$k$58" ActiveWindow.SelectedSheets.PrintPreview 'Tm seili sayfalardan vede seili alanlardan tek bir sayfann print yaplmas ? Sub MultiSheetPrint() Dim oActive As Object Dim oSheet As Object Dim oSheets As Object Dim wsPrint As Worksheet Dim oLastPic As Object Dim iPics As Integer ' remember where we are Set oSheets = ActiveWindow.SelectedSheets If oSheets.Count = 1 Then Selection.PrintOut preview:=True Exit Sub End If Set oActive = ActiveSheet Application.ScreenUpdating = False oActive.Select ' otherwise we get lots of new sheets Set wsPrint = Worksheets.Add For Each oSheet In oSheets If TypeName(oSheet) = "Worksheet" Then iPics = iPics + 1 oSheet.Activate Selection.CopyPicture wsPrint.Cells(iPics * 3 - 2, 1).Value = oSheet.Name wsPrint.Paste wsPrint.Cells(iPics * 3 - 1, 1) wsPrint.Rows(iPics * 3 - 1).RowHeight = _ wsPrint.Pictures(iPics).Height End If Next wsPrint.PrintOut preview:=True Application.DisplayAlerts = False wsPrint.Delete Application.DisplayAlerts = True oSheets.Select oActive.Activate Application.ScreenUpdating = True End Sub
'Tm seili sayfalardan vede seili alanlardan tek bir sayfann print yaplmas ? Sub MultiSheetPrint() Dim oActive As Object Dim oSheet As Object Dim oSheets As Object Dim wsPrint As Worksheet Dim oLastPic As Object Dim iPics As Integer ' remember where we are Set oSheets = ActiveWindow.SelectedSheets If oSheets.Count = 1 Then Selection.PrintOut preview:=True Exit Sub End If Set oActive = ActiveSheet Application.ScreenUpdating = False oActive.Select ' otherwise we get lots of new sheets Set wsPrint = Worksheets.Add For Each oSheet In oSheets If TypeName(oSheet) = "Worksheet" Then iPics = iPics + 1 oSheet.Activate Selection.CopyPicture wsPrint.Cells(iPics * 3 - 2, 1).Value = oSheet.Name wsPrint.Paste wsPrint.Cells(iPics * 3 - 1, 1) wsPrint.Rows(iPics * 3 - 1).RowHeight = _ wsPrint.Pictures(iPics).Height End If Next wsPrint.PrintOut preview:=True Application.DisplayAlerts = False wsPrint.Delete Application.DisplayAlerts = True oSheets.Select oActive.Activate Application.ScreenUpdating = True End Sub Sub DateinameFiltern() Dim strDName strDName = Application.GetOpenFilename strDName = Dir(strDName) MsgBox strDName End Sub Sub ResetValues2() For i = 1 To Worksheets.Count On Error GoTo ErrorHandler For Each n In Worksheets(i).UsedRange If IsNumeric(n) Then If n.Value <> 0 Then n.Value = 0 ProtectedCell: End If End If Next n ErrorHandler: If Err = 1005 Then Resume ProtectedCell End If Next i End Sub
Workbook code blmne Option Explicit Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 Set OldCell = Target End Sub 'Sayfann code blmne Option Explicit 'son aktif olan hcrenin rengi sabit olarak kalyor. Buna bir zm varm? Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveCell.Interior.ColorIndex = xlColorIndexNone End Sub Sub formullerideeryap() For Each fCell In Selection fCell.Value = fCell.Value Next fCell End Sub Sub metnecevr() Col = 1 DerLig = Cells(65536, Col).End(xlUp).Row For i = 1 To DerLig Cells(i, Col).Formula = "'" & Cells(i, Col) Cells(i, Col).Formula = "" & Cells(i, Col) Next i End Sub Sub Cevir() For Each hucre In Selection n=n+1 Next hucre ReDim aralik(n) For Each hucre In Selection aralik(i) = hucre.Value i=i+1 Next hucre For Each hucre In Selection i=i-1 hucre.Value = aralik(i) Next hucre End Sub Sub TopLeft() ActiveCell.Select With ActiveWindow .ScrollColumn = ActiveCell.Column .ScrollRow = ActiveCell.Row End With End Sub Sub ResetValues() On Error GoTo ErrorHandler For Each n In ActiveSheet.UsedRange If n.Value <> 0 Then n.Value = 0 End If TypeMismatch: Next n ErrorHandler: If Err = 13 Then 'Type Mismatch Resume TypeMismatch End If End Sub
Sub WordSheetRangeCopy() Dim WordObj As Object Selection.Copy Set WordObj = CreateObject("Word.Basic") With WordObj .AppShow .FileNew .EditPaste End With Set WordObj = Nothing End Sub
' prints selected cells, use from a toolbar button or a menu Dim aCount As Integer, cCount As Integer, rCount As Integer Dim i As Integer, j As Long, aRange As String Dim rHeight() As Single, cWidth() As Single Dim AWB As Workbook, NWB As Workbook If UCase(TypeName(ActiveSheet)) <> "WORKSHEET" Then Exit Sub ' useful only in worksheets aCount = Selection.Areas.Count If aCount = 0 Then Exit Sub ' no cells selected cCount = Selection.Areas(1).Cells.Count If aCount > 1 Then ' multiple areas selected Application.ScreenUpdating = False Application.StatusBar = "Printing " & aCount & " selected areas..." Set AWB = ActiveWorkbook rCount = ActiveSheet.Cells.SpecialCells(xlLastCell).Row cCount = ActiveSheet.Cells.SpecialCells(xlLastCell).Column ReDim rHeight(rCount) ReDim cWidth(cCount) For i = 1 To rCount ' find the row height of every row in the selection rHeight(i) = Rows(i).RowHeight Next i For i = 1 To cCount ' find the column width of every column in the selection cWidth(i) = Columns(i).ColumnWidth Next i Set NWB = Workbooks.Add ' create a new workbook For i = 1 To rCount ' set row heights Rows(i).RowHeight = rHeight(i) Next i For i = 1 To cCount ' set column widths Columns(i).ColumnWidth = cWidth(i) Next i For i = 1 To aCount AWB.Activate aRange = Selection.Areas(i).Address ' the range address Range(aRange).Copy ' copying the range NWB.Activate With Range(aRange) ' pastes values and formats .PasteSpecial Paste:=xlValues, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False .PasteSpecial Paste:=xlFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False End With Application.CutCopyMode = False Next i NWB.PrintOut NWB.Close False ' close the temporary workbook without saving Application.StatusBar = False AWB.Activate Set AWB = Nothing Set NWB = Nothing Else If cCount < 10 Then ' less than 10 cells selected If MsgBox("Are you sure you want to print " & _ cCount & " selected cells ?", _ vbQuestion + vbYesNo, "Print celected cells") = vbNo Then Exit Sub End If Selection.PrintOut End If End Sub Sub SelCurRegCopy() Selection.CurrentRegion.Select Selection.Copy Range("A17").Select ' Kopyalamaya balanacak hcreyi belirt ActiveSheet.Paste Application.CutCopyMode = False End Sub
Hcreye sa tklamayla kan popup menye eklenen Three Times maddesi ile seili hcredeki deerin 3 ile arpmn statusBarda gsterir. 'Thisworkbook modlne kopyala Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.CommandBars("Cell").Controls("Three Times").Delete Application.StatusBar = False End Sub Private Sub Workbook_Open() Dim cdbCtr As CommandBarButton Application.DisplayStatusBar = True Set cdbCtr = Application.CommandBars("Cell").Controls.Add With cdbCtr .Caption = "Three Times" .BeginGroup = True .OnAction = "Multiplying" .Visible = True End With End Sub 'Worksheet modlne kopyala Private Sub Worksheet_SelectionChange(ByVal Target As Range) Application.StatusBar = False End Sub 'Standard modle kopyala Sub Multiplying() Application.StatusBar = "Choice * 3 = " & _ WorksheetFunction.Sum(Selection) * 3 End Sub
Public bColored As Integer Sub ColoredToBW() Dim cht As Chart Dim chtSC As SeriesCollection Dim x As Integer Dim iSeriesCount As Integer Dim iColors(1 To 5, 0 To 1) As Integer Dim iColor As Integer 'Set colors for BW series iColors(1, 0) = 1 'Black iColors(2, 0) = 56 'Gray-80% iColors(3, 0) = 16 'Gray-50% iColors(4, 0) = 48 'Gray-40% iColors(5, 0) = 15 'Gray-25% 'Set colors for Color series iColors(1, 1) = 55 'Indigo iColors(2, 1) = 7 'pink iColors(3, 1) = 6 'yellow iColors(4, 1) = 8 'Turquoise iColors(5, 1) = 13 'Violet 'Toggle Color/BW change 0 to 1 or 1 to 0 bColored = 1 - bColored Set cht = ActiveChart 'check that a chart is selected If cht Is Nothing Then MsgBox ("Select a chart") Exit Sub End If Set chtSC = cht.SeriesCollection 'Check for MIN of number of series or 'colors and only do the minimum iSeriesCount = Application.WorksheetFunction.Min _ (UBound(iColors), chtSC.Count) For x = 1 To iSeriesCount 'Define the color iColor = iColors(x, bColored) 'Set the LINE color chtSC(x).Border.ColorIndex = iColor 'Marker color With chtSC(x) .MarkerBackgroundColorIndex = xlNone .MarkerForegroundColorIndex = iColor End With Next x End Sub Sub AdVer2() ActiveSheet.Names.Add Name:="Alan2", _ RefersTo:="=" & Selection.Address() End Sub Sub AdVer3() Selection.Name = "Alan3" End Sub Selection.ClearFormats
Sub ValMaxi() Dim Cel As Range Dim Val As Integer Dim Adr As String For Each Cel In Selection If Val < Cel Then Val = Cel 'Valeur de la cellule Adr = Cel.Address 'Adresse de la cellule End If Next Range(Adr).Font.Bold = True 'La plus grande valeur est contenu dans la variable Val End Sub Sub FormulAcikla() Dim cell As Range Selection.ClearComments For Each cell In Selection If cell.HasFormula Then cell.AddComment cell.Formula cell.Comment.Visible = False cell.Comment.Shape.TextFrame.AutoSize = True End If Next cell End Sub On Error GoTo ErrorAufgabe Dim MyError As Integer Dim Faellig As Date Dim Link As String Dim myolApp As Object, myitem As Object 'Eigene Fehleroutine/Nummer erffnen MyError = 1 'Flligkeit ist bermorgen Faellig = Date + 1 MyError = 2 Set myolApp = CreateObject("Outlook.Application") Set myitem = myolApp.CreateItem(3) myitem.Subject = "Datei ERFASSEN !" ' Text der Aufgabe myitem.DueDate = Faellig myitem.ReminderTime = Faellig 'Ein Link kann nur erstellt werden, wenn die Pfadangabe eine 'Angabe mit einem ShareName ist myitem.Body = "\\Computername\Freigabename\dateiname.xls" myitem.Save Set myitem = Nothing ErrorExit: Exit Sub ErrorAufgabe: Select Case MyError Case 1 MsgBox "Die Datei wurde noch nicht gespeichert" Case 2 MsgBox "Outlook kann nicht gestartet werden" & Chr$(13) &_ "Aufgabe wurde nicht erstellt !" End Select Resume ErrorExit End Sub Range("A1:A5").Select Selection.Insert Shift:=xlDown 'Seili hcreler aa kaydrlr 'Seili hcrelere ait tm satr telemek Range("A1:A5").Select Selection.EntireRow.Insert 'Seili hcrelere ait tm stunu telemek Range("D6:E7).Select Selection.EntireColumn.Insert
Sub SeciliHucreSay() 'Returns a count of all cells in a selection Dim myCount As Integer 'using the Selection and Count properties myCount = Selection.Count MsgBox "Toplam seili hcre says : " _ & myCount, vbInformation, "Hcre Says" End Sub Sub LowerCase() Dim cell As Range For Each cell In Selection.Cells If cell.HasFormula = False Then cell = LCase(cell) End If Next End Sub Sub imgComment() Dim nom$ On Error Resume Next For Each C In Selection nom = C.Value With C .AddComment .Comment.Shape.Fill.UserPicture ActiveWorkbook.Path & "\" & nom & ".jpg" End With Next End Sub Sub InserImage() Dim nom$ Dim fichimg$ [C10].Select With ActiveWindow y = .Selection.Width End With On Error Resume Next nom = Selection.Offset(0, -1).Value fichimg = ActiveWorkbook.Path & "\" & nom & ".jpg" ActiveSheet.Pictures.Insert(fichimg).Select Selection.ShapeRange.Width = y End Sub Sub RngName() Selection.Name = "myRange" End Sub Sub Message() msg = "Voulez-vous continuer ?" ' Dfinit le message. Style = vbYesNo + vbDefaultButton1 'Dfinit les boutons. Title = "Bonjour !" ' Dfinit les titres. Rponse = MsgBox(msg, Style, Title) If Rponse = vbYes Then ' Vous avez choisi le bouton " Oui ". Set MaSlection = Application.ActiveCell MaSlection.Value = 100 Else Range("A1:b2").Select ' Accomplit une autre chose. End If End Sub Sub Nach_Word_Kopieren() Dim WordObj As Object Selection.Copy Set WordObj = CreateObject("Word.Basic") With WordObj .AppShow 'Word 6/7: .AnwAnzeigen .FileNew 'Word 6/7: .DateiNeu .EditPaste 'Word 6/7: .BearbeitenEinfgen End With Set WordObj = Nothing End Sub
Sub AddBullets() Dim Bullet As String Dim Dash As String Dim Cel As Range Dim Str As String Dim i As Long Bullet = " " Dash = " - " 'select which cells to perform an action on For Each Cel In Selection Str = Cel.Value 'If there is already a bullet there then put a dash in its place If Left(Str, Len(Bullet)) = Bullet Then Str = Right(Str, Len(Str) - 2) Cel.Value = Dash & Str Else 'If there is already a dash there then trim back to normal text If Left(Str, Len(Dash)) = Dash Then Str = Trim(Cel.Value) i = Len(Str) - 1 If i >= 0 Then Cel.Value = Trim(Right(Str, i)) End If Else 'Otherwise add the bullet Cel.Value = Bullet & Str End If End If 'Go to the next cell in the selection and do the same thing Next Cel End Sub Sub Cevir() For Each hucre In Selection n=n+1 Next hucre ReDim aralik(n) For Each hucre In Selection aralik(i) = hucre.Value i=i+1 Next hucre For Each hucre In Selection i=i-1 hucre.Value = aralik(i) Next hucre End Sub Dim s as integer Dim r as integer s=8 ActiveCell.ClearContents r = ActiveCell.Row Range("A" & r + 1 & ":A" & s).Select Selection.Cut Destination:=Range("A" & r & ":A" & s - 1) Range("a" & r).Select Sub CountRows() Dim myCount As Integer myCount = Selection.Rows.Count MsgBox "This selection contains " & myCount & _ " row(s)", vbInformation, "Count Rows" End Sub Sub CountRows() Dim myCount As Integer myCount = Selection.Rows.Count MsgBox "This selection contains " & myCount _ & " row(s)", vbInformation, "Count Rows" End Sub ActiveSheet.Name = "merhaba"
Sub ift_kaytlari_arala() toplamsatr = ActiveSheet.UsedRange.Rows.Count For Row = toplamsatr To 2 Step -1 If Cells(Row, 1).Value <> Cells(Row - 1, 1).Value Then Rows(Row).Insert Next Row End Sub Sub SatirSay() Dim myCount As Integer myCount = Selection.Rows.Count MsgBox "Seili alanda " & myCount & " satr var.", _ vbInformation, "Count Rows" End Sub Sub SutunSay() Dim myCount As Integer myCount = Selection.Columns.Count MsgBox "Seili alanda " & myCount & " stun var.", _ vbInformation, "Count Columns" End Sub Range("A1:F15").Select 'set range zoom ActiveWindow.zoom = True Sub analyse1() Dim we% z=2 Do While Cells(z, 1) <> "" we = Cells(z, 1) Select Case we Case Is < 10 Cells(z, 2) = " Wert ist kleiner als 10" Case Is < 20 Cells(z, 2) = " Wert ist kleiner als 20" Case Is < 30 Cells(z, 2) = " Wert ist kleiner als 30" Case Is < 30 Cells(z, 2) = " Wert ist kleiner als 40" Case Is < 50 Cells(z, 2) = " Wert ist kleiner als 50" End Select z=z+1 Loop Dim hucre As Integer Dim eski_hucre, eski_hucre_column As String Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error Resume Next If eski_hucre_column = "1" Then veri = ActiveCell Range(eski_hucre) = Format(DateValue(Left(Range(eski_hucre).Value, 2) & "." & _ Mid(Range(eski_hucre).Value, 3, 2) _ & "." & Right(Range(eski_hucre), 4)), "dd.mm.yyyy") End If eski_hucre = ActiveCell.Address eski_hucre_column = ActiveCell.Column End Sub
sesx$ = ThisWorkbook.Path & "\" & "numaral cihazn kayd yaplmtr.wav" '--Eklenen kod---dz1 = Array(" ", "bir", "iki", "", "drt", "be", "alt", "yedi", "sekiz", "dokuz") dz2 = Array(" ", "on", "yirmi", "otuz", "krk", "elli", "altm", "yetmi", "seksen", "doksan") dz3 = Array(" ", "", "bin", "milyon", "milyar", "trilyon", "katrilyon") tur = Len(sy) \ 3 kalan = Len(sy) Mod 3 k=2 say = "" For i = 1 To tur sya = Mid(sy, (Len(sy) - k), 3) sy1 = dz1(Mid(sya, 3, 1)): sy2 = dz2(Mid(sya, 2, 1)): sy3 = dz1(Mid(sya, 1, 1)) Select Case Mid(sya, 1, 1) Case 1 sy3 = "yz" Case Is > 1 sy3 = sy3 & " " & "yz" End Select If i = 2 Then Select Case Val(sya) Case 0 sy1 = "" Case 1 sy1 = "bin" Case Is > 1 sy1 = sy1 & " " & "bin" End Select Else birim = dz3(i) End If If Val(sya) > 0 Then say = sy3 & " " & Trim(sy2) & " " & sy1 & " " & birim & " " & Trim(say) k=k+3 Else k=k+3 End If Next i If kalan = 0 Then f = say p = InStr(1, LTrim(f), " ") Do While p > 0 s = Trim(Mid(f, 1, p)) f = LTrim(Mid(f, p, Len(f))) p = InStr(1, f, " ") ses$ = ThisWorkbook.Path & "\" & s & ".wav" Call PlaySound(ses$, 1, 0) Loop If f <> "" Then s=f ses$ = ThisWorkbook.Path & "\" & s & ".wav" Call PlaySound(ses$, 1, 0) End If Call PlaySound(sesx$, 1, 0) '-------Eklenen kod-----Exit Function Else End If syb = Mid(sy, 1, kalan) sy11 = dz1(Mid(syb, kalan, 1)): sy22 = dz2(Mid(sy, kalan - 1, 1)) If tur = 1 Then Select Case Val(Mid(syb, 1, 2)) Case 0 sy11 = "" Case 1 sy11 = "bin" Case Is > 1 sy11 = sy11 & " " & "bin" End Select Else birim1 = dz3(tur + 1) End If say = sy22 & " " & sy11 & " " & birim1 & " " & say f = LTrim(say) p = InStr(1, f, " ") Do While p > 0 s = Trim(Mid(f, 1, p)) f = LTrim(Mid(f, p, Len(f))) p = InStr(1, f, " ") ses$ = ThisWorkbook.Path & "\" & s & ".wav" Call PlaySound(ses$, 1, 0) Loop If f <> "" Then
Sub Beeper() Beep start2 = Now() + TimeSerial(0, 0, 0.9) Application.Wait start2 For i = 2 To 3 start2 = Now() + TimeSerial(0, 0, 0.8) Application.Wait start2 Beep Next i End Sub Bu kodu bir module ekleyip altrrsanz kendne yen br sayfa olusturup ne kadar sayfa varsa yen sayfa da brlestryor. Kod: Sub SayfaBirletir() Dim YeniSayfa As Worksheet Dim SayfaSay SayfaSay = Worksheets.Count Set YeniSayfa = Worksheets.Add(After:=Worksheets(SayfaSay)) With YeniSayfa For i = 1 To SayfaSay Worksheets(i).UsedRange.Copy .Range("A" & IIf(i = 1, 1, .UsedRange.Rows.Count + 1)) Next End With End Sub Val As Variant Addr As String End Type ' Stores info about current selection Public OldWorkbook As Workbook Public OldSheet As Worksheet Public OldSelection() As SaveRange Sub ZeroRange() ' Inserts zero into all selected cells ' Abort if a range isn't selected If TypeName(Selection) <> "Range" Then Exit Sub ' The next block of statements ' Save the current values for undoing ReDim OldSelection(Selection.Count) Set OldWorkbook = ActiveWorkbook Set OldSheet = ActiveSheet i=0 For Each cell In Selection i=i+1 OldSelection(i).Addr = cell.Address OldSelection(i).Val = cell.Formula Next cell ' Insert 0 into current selection Application.ScreenUpdating = False Selection.Value = 0 ' Specify the Undo Sub Application.OnUndo "Undo the ZeroRange macro", "UndoZero" End Sub Sub UndoZero() ' Undoes the effect of the ZeroRange sub ' Tell user if a problem occurs On Error GoTo Problem Application.ScreenUpdating = False ' Make sure the correct workbook and sheet are active OldWorkbook.Activate OldSheet.Activate ' Restore the saved information For i = 1 To UBound(OldSelection) Range(OldSelection(i).Addr).Formula = OldSelection(i).Val Next i Exit Sub ' Error handler Problem: MsgBox "Can't undo" End Sub Other examples of Undo
Sub Button32_Click () On Error GoTo HataKontrol A=5 B=0 Sunuc = A / B Exit Sub 'burada programa son verilir. HataKontrol: Select Case Err.Number Case 11: Mesaj = "Sfra blnme hatas olutu!!!" End Select MsgBox Mesaj Resume Next End Sub rnek pir1, pir2, pir3 Public addShtCount As Long Public Sub AddSheets() addShtCount = addShtCount + 1 Dim straddShtCount As String straddShtCount = addShtCount newShtName = "pir" + straddShtCount Worksheets.Add ActiveSheet.Name = newShtName End Sub Sub ekle() Dim i For i = 1 To 5 Cells(i, 1) = InputBox("Hcreye yazlacak deeri girin:") Next End Sub Private Sub CommandButton1_Click() For x = 1 To 5 i = InputBox("ne yazacaksn", "Soru " & x) Cells(1, x).Value = i Next End Sub Sub sayfaekle() For a = 1 To [a3] Sheets.Add.Move After:=Sheets(Sheets.Count) Sheets(Sheets.Count).Name = a Next End Sub Sub textbox_olustur() Dim a, b, c, d, e, f, g, h, i, j, Button Set a = [A2]: Set b = [B2]: Set c = [C2]: Set d = [D2]: Set e = [E2] Set f = [A4]: Set g = [B4]: Set h = [C4]: Set i = [D4]: Set j = [E4] '******************************************************************************************* Set Button = ActiveSheet.Buttons.Add(a.Left, a.Top, a.Width, a.Height) Set Button = ActiveSheet.Buttons.Add(b.Left, b.Top, b.Width, b.Height) Set Button = ActiveSheet.Buttons.Add(c.Left, c.Top, c.Width, c.Height) Set Button = ActiveSheet.Buttons.Add(d.Left, d.Top, d.Width, d.Height) Set Button = ActiveSheet.Buttons.Add(e.Left, e.Top, e.Width, e.Height) '******************************************************************************************* Set Button = ActiveSheet.Buttons.Add(f.Left + 3, f.Top + 3, f.Width - 4, f.Height - 4) Set Button = ActiveSheet.Buttons.Add(g.Left + 3, g.Top + 3, g.Width - 4, g.Height - 4) Set Button = ActiveSheet.Buttons.Add(h.Left + 3, h.Top + 3, h.Width - 4, h.Height - 4) Set Button = ActiveSheet.Buttons.Add(i.Left + 3, i.Top + 3, i.Width - 4, i.Height - 4) Set Button = ActiveSheet.Buttons.Add(j.Left + 3, j.Top + 3, j.Width - 4, j.Height - 4) End Sub Sub sirala() [b3:f65536].Sort Key1:=[B3], Key2:=[C3], Key3:=[D3] End Sub Sub Dialog_26() Application.Dialogs(xlDialogFileDelete).Show End Sub
Option Ex
Sub CommandBarControlID_List() Dim a, b, c Application.ScreenUpdating = False For Each ComBar In Application.CommandBars If ComBar.Name = "test" Then ComBar.Delete Next Set ComBar = Application.CommandBars.Add(Name:="test", Position:=msoBarTop) b=0 c=1 For a = 1 To 50000 On Error Resume Next Set cbb = ComBar.Controls.Add(ID:=a) If Err.Number <> 0 Then GoTo weiter cbb.CopyFace With Workbooks("FaceIDs").Sheets(1) .Cells((c Mod 100) + 1, (c \ 100) + b + 1).Formula = a .Cells((c Mod 100) + 1, (c \ 100) + b + 2).Activate ActiveSheet.Paste .Cells((c Mod 100) + 1, (c \ 100) + b + 3).Formula = cbb.Caption End With If (c + 1) Mod 100 = 0 Then b = b + 3 c=c+1 weiter: Application.CommandBars("test").FindControl(ID:=a).Delete Err.Clear Next End Sub Sub CommandBarFaceID_List() Dim a, b Application.ScreenUpdating = False For Each ComBar In Application.CommandBars If ComBar.Name = "test" Then ComBar.Delete Next On Error Resume Next Set ComBar = Application.CommandBars.Add(Name:="test", Position:=msoBarTop) Set cbb = ComBar.Controls.Add(ID:=1) b=0 For a = 1 To 3518 With cbb .FaceId = a .CopyFace End With With ThisWorkbook.Sheets(1) .Cells((a Mod 100) + 1, (a \ 100) + b + 1).Formula = a .Cells((a Mod 100) + 1, (a \ 100) + b + 2).Activate ActiveSheet.Paste End With If (a + 1) Mod 100 = 0 Then b = b + 2 Next End Sub Sub CommandBar_List() Application.ScreenUpdating = False Dim a, b, c, cbc, d b=1 d=0 For Each a In Application.CommandBars Cells(b + d, 1) = a.Name Cells(b + d, 2) = "Item-no: " & b For Each cbc In a.Controls d=d+1 Cells(b + d, 3) = cbc.Caption Cells(b + d, 4) = Cells(cbc.Type, 10) Cells(b + d, 5) = "Type: " & cbc.Type Cells(b + d, 6) = "ID: " & cbc.ID Next b=b+1 Next End Sub
bl = combobox1.ListIndex+1 cells(bl,2).select TextBox1.Value = ActiveCell.Offset(0, 0).Value TextBox2.Value = ActiveCell.Offset(0, 1).Value TextBox3.Value = ActiveCell.Offset(0, 2).Value TextBox4.Value = ActiveCell.Offset(0, 3).Value TextBox5.Value = ActiveCell.Offset(0, 4).Value TextBox6.Value = ActiveCell.Offset(0, 5).Value TextBox7.Value = ActiveCell.Offset(0, 6).Value TextBox8.Value = ActiveCell.Offset(0, 7).Value TextBox9.Value = ActiveCell.Offset(0, 8).Value TextBox10.Value = ActiveCell.Offset(0, 9).Value TextBox11.Value = ActiveCell.Offset(0, 10).Value TextBox12.Value = ActiveCell.Offset(0, 11).Value TextBox13.Value = ActiveCell.Offset(0, 12).Value TextBox14.Value = ActiveCell.Offset(0, 13).Value Dim s As String, oSystem As Object, item As Object Set oSystem = GetObject("winmgmts:").instancesOf("Win32_ComputerSystem") For Each item In oSystem s = "Computer Info" & vbCrLf s = s & "-------------------------------" & vbCrLf s = s & "Name: " & item.Name & vbCrLf s = s & "Status: " & item.Status & vbCrLf s = s & "Type: " & item.SystemType & vbCrLf s = s & "Mfg: " & item.Manufacturer & vbCrLf s = s & "Model: " & item.Model & vbCrLf s = s & "RAM: " & item.TotalPhysicalMemory \ 1024000 & "mb" & vbCrLf s = s & "Domain: " & item.Domain & vbCrLf s = s & "Role: " & TranslateDomainRole(item.DomainRole) & vbCrLf s = s & "Current User: " & item.UserName & vbCrLf MsgBox s Next Set oSystem = Nothing End Sub Function TranslateDomainRole(ByVal roleID) As String Dim RetString As String Select Case roleID Case 0 RetString = "Standalone Workstation" Case 1 RetString = "Member Workstation" Case 2 RetString = "Standalone Server" Case 3 RetString = "Member Server" Case 4 RetString = "Backup Domain Controller" Case 5 RetString = "Primary Domain Controller" Case Else RetString = "Unknown" End Select TranslateDomainRole = RetString End Function Private Sub cmdSetClock_Click() Shell "rundll32.exe shell32.dll,Control_RunDLL timedate.cpl", vbNormalFocus End Sub Sub yazlist() Shell ("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder") End Sub
If Not Application.CanPlaySounds Then MsgBox "Sorry, sound is not supported on your system." Exit Sub End If Standart Modle Public RunWhen As Double Sub StartBlink() If Range("A1").Font.ColorIndex = 2 Then Range("A1").Font.ColorIndex = xlColorIndexAutomatic Else Range("A1").Font.ColorIndex = 2 End If RunWhen = Now + TimeSerial(0, 0, 1) Application.OnTime RunWhen, "StartBlink", , True End Sub 'ThisWorkbook'un kod sayfasna Sub StopBlink() Range("A1").Font.ColorIndex = xlColorIndexAutomatic Application.OnTime RunWhen, "StartBlink", , False End Sub Private Sub Workbook_Open() StartBlink End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) StopBlink End Sub Sub mt() Columns("b:b").Select Selection.Font.ColorIndex = 2 End Sub Application.Caption = "Benim Basligim" Sub test() Application.Caption = "Balk" ActiveWindow.Caption = "Deneme" ' Yanl MsgBox Application.Caption & " " & ActiveWindow.Caption ' Doru MsgBox Application.Caption End Sub Sub myEdit() MsgBox Left("abcd", 2) 'soldan 2 karakter say MsgBox Right("abcd", 2) 'sadan 2 karakter say MsgBox Len("abcd") 'saysal olarak karakter say End Sub Sub sondolu_satir() i = ActiveSheet.UsedRange.Rows.Count MsgBox i End Sub Sub sondolu_sutun() i = ActiveSheet.UsedRange.Columns.Count MsgBox i End Sub Sub Yazdirma_Alani_Belirle() Dim sh As Worksheet Dim sonsatir As Long Set sh = Sheets("faturarapor") sonsatir = sh.Cells(65536, 1).End(xlUp).Row sh.PageSetup.PrintArea = "$A$3:$F$" & sonsatir Set sh = Nothing End Sub Private Sub CommandButton3_Click() Application.DisplayAlerts = False Sheets(Sheets.Count).Delete Unload Me End Sub
Sub SayfaSecSonraki() On Error Resume Next If ActiveSheet.Index = Worksheets.Count Then Worksheets(1).Select Else On Error Resume Next Worksheets(ActiveSheet.Index + 1).Select End If End Sub
MenuSil Set cbMenu = Application.CommandBars(1).Controls.Add(msoControlPopup, , , , True) With cbMenu .Caption = "&Szlk" .OnAction = "formac" .Tag = "MyTag" .BeginGroup = True End With If cbMenu Is Nothing Then Exit Sub Set cbSubMenu = Nothing Set cbMenu = Nothing End Sub Sub MenuSil() kaldir "MyTag" End Sub Private Sub kaldir(CustomControlTag As String) On Error Resume Next Do Application.CommandBars.FindControl(, , CustomControlTag, False).Delete Loop Until Application.CommandBars.FindControl(, , CustomControlTag, False) Is Nothing On Error GoTo 0 End Sub Sub auto_close() MenuSil End Sub Sub formac() UserForm1.Show End Sub SZLK OLUTURMA KODLARI Private Sub UserForm_Initialize() With ListBox1 .RowSource = "[Szlk.xla]TrEng!A1:A16174" .Font.Name = "Verdana" .Font.Size = 10 End With With ComboBox1 .RowSource = "[Szlk.xla]TrEng!A1:A16174" .ShowDropButtonWhen = fmShowDropButtonWhenNever .Font.Name = "Verdana" .Font.Size = 10 End With With ComboBox2 .RowSource = "[Szlk.xla]TrEng!B1:B16174" .ShowDropButtonWhen = fmShowDropButtonWhenNever .Locked = True .Font.Name = "Verdana" .Font.Size = 10 End With With ListBox2 .RowSource = "[Szlk.xla]EngTr!A1:A11435" .Font.Name = "Verdana" .Font.Size = 10 End With With ComboBox3 .RowSource = "[Szlk.xla]EngTr!A1:A11435" .ShowDropButtonWhen = fmShowDropButtonWhenNever .Font.Name = "Verdana" .Font.Size = 10 End With With ComboBox4 .RowSource = "[Szlk.xla]EngTr!B1:B11435" .ShowDropButtonWhen = fmShowDropButtonWhenNever .Locked = True .Font.Name = "Verdana" .Font.Size = 10 End With End Sub 'BU KOD COMBOBOX1'E YAZILACAK Private Sub ComboBox1_Change() ListBox1.ListIndex = ComboBox1.ListIndex ComboBox2.ListIndex = ComboBox1.ListIndex
visual basic kodu: -------------------------------------------------------------------------------Private Sub SpinButton1_SpinDown() ListBox1.ListIndex = ListBox1.ListCount - 1 End Sub --------------------------------------------------------------------------------
visual basic kodu: -------------------------------------------------------------------------------Private Sub SpinButton1_SpinUp() ListBox1.ListIndex = 0 End Sub ThisWorkbook objesine yaz Private Sub Workbook_Open() UserForm1.Show End Sub ' UserFormun kod ksmna yaz Private Sub UserForm_Activate() Application.OnTime Now + TimeValue("00:00:05"), "KillTheForm" End Sub ' Standart modle yaz Private Sub KillTheForm() Unload UserForm1 End Sub 'Veya ksaca u ekilde de yaplabilir: Private Sub UserForm_Activate() Application.Wait Now + TimeSerial(0, 0, 3) Unload Me End Sub Private Sub UserForm_Initialize() Spreadsheet1.Range("A1:C100").Value = _ Worksheets("Sayfa2").Range("A1:C100").Value End Sub
Dim rCol As Range Dim rCell1 As Range, rCell2 As Range Dim i As Integer, iPBcount As Integer Dim Sht As Worksheet Application.StatusBar = "Converting, please wait....!" Application.ScreenUpdating = False 'Set range variable to Selection Set Sht = ActiveSheet Set rCol = Sht.UsedRange.Columns(1) 'Insert page breaks Sht.PageSetup.PrintArea = "" Sht.PageSetup.Zoom = 100 ActiveWindow.View = xlPageBreakPreview 'Count only horizontal page breaks and pass to an Integer iPBcount = Sht.HPageBreaks.Count On Error Resume Next 'Loop as many times as there horizontal page breaks. For i = 1 To iPBcount 'Set variable 1 to page break X Set rCell1 = Sht.HPageBreaks(i).Location 'Set variable 2 to X page break Set rCell2 = Sht.HPageBreaks(i + 1).Location.Offset(-1, 0) If rCell2 Is Nothing Then 'Last page break Range(rCell1, rCol.Cells(65536, 1).End(xlUp)).Cut Destination:=Sht.Cells(1, i + 1) Else Range(rCell1, rCell2).Cut Destination:=Sht.Cells(1, i + 1) End If Set rCell1 = Nothing Set rCell2 = Nothing Next i On Error GoTo 0 ActiveWindow.View = xlNormalView Application.ScreenUpdating = True Sht.DisplayPageBreaks = False Application.Goto rCol.Cells(1, 1), True Set rCol = Nothing Application.StatusBar = "" End Sub
(ByVal dwMilliseconds As Long) Private Declare Function WaitForSingleObject Lib "kernel32" _ (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib "kernel32" _ (ByVal hObject As Long) As Long Private Declare Function OpenProcess Lib "kernel32" _ (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Private Const INFINITE = -1& Private Const SYNCHRONIZE = &H100000 Dim LaufbandExit As Integer Sub LaufbandStart() Dim OrStatus As String Dim LaufText As String Dim B As Range Dim BZelle As Range LaufbandExit = 0 OrStatus = Application.DisplayStatusBar Application.DisplayStatusBar = True Set B = Sheets("Lauftext").Range("A1:D10") LaufText = String(130, " ") For Each BZelle In Sheets("Lauftext").Range("A1:D10") LaufText = LaufText & " " & BZelle.Text Next BZelle Application.StatusBar = LaufText Do Sleep 100 'Verzgerung in Millisekunden LaufText = Right(LaufText, Len(LaufText) - 1) & Left(LaufText, 1) Application.StatusBar = LaufText DoEvents If LaufbandExit = 1 Then Application.StatusBar = False Application.DisplayStatusBar = OrStatus LaufbandExit = 0 Exit Sub End If Loop End Sub Sub LaufbandEnde() LaufbandExit = 1 End Sub Option Explicit Sub Countdown() Dim intCounter As Integer Dim bln As Boolean bln = Application.DisplayStatusBar For intCounter = 10 To 1 Step -1 Application.StatusBar = "Noch " & _ intCounter & " Sekunden ..." Application.Wait Now + TimeSerial(0, 0, 1) Next intCounter Application.StatusBar = False Application.DisplayStatusBar = bln MsgBox "Fertig ", vbOKOnly, " K.-M. Buss" End Sub
Sub Fortschritt() Dim i%, y% For i = 1 To 10 StatusLED "lem Yaplyor: ", i / 10 Application.Wait Now + TimeSerial(0, 0, 1) Next i End Sub Function StatusLED(Msg As String, Pct As Single) Dim PctDone As Integer Dim NumReps As Integer With Application PctDone = .Round(Pct, 2) * 100 NumReps = Int(PctDone / 5) .StatusBar = Msg & .Rept(Chr(14), NumReps) & _ .Rept("**", 20 - NumReps) & " " & PctDone & "%" End With End Function Sub StatusBarExample() Application.ScreenUpdating = False Application.DisplayStatusBar = True Application.StatusBar = "Please wait while performing task 1..." ' add some code for task 1 that replaces the next sentence Application.Wait Now + TimeValue("00:00:02") Application.StatusBar = "Please wait while performing task 2..." ' add some code for task 2 that replaces the next sentence Application.Wait Now + TimeValue("00:00:02") Application.StatusBar = False End Sub Private Sub UserForm_Activate() Do DoEvents StatusBar1.Panels(1).Text = Time Loop End Sub ' Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) End End Sub Sub GeriSayim() Dim intCounter As Integer Dim bln As Boolean bln = Application.DisplayStatusBar Application.DisplayStatusBar = True For intCounter = 10 To 1 Step -1 Application.StatusBar = intCounter & " Saniye..." Application.Wait Now + TimeSerial(0, 0, 1) Next intCounter Application.StatusBar = False Application.DisplayStatusBar = bln End Sub Private Sub Workbook_Open() Application.DisplayStatusBar = True Application.StatusBar = "Merhaba! Bugn: " & Date End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.StatusBar = False End Sub Sub Dialog_05() Application.Dialogs(xlDialogApplyStyle).Show End Sub Sub Dialog_21() Application.Dialogs(xlDialogDefineStyle).Show End Sub sub dosyabul() dim a as string a = application.findfile msgbox a end sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Set rng = Columns("C:C") If Not (Intersect(Target, rng) Is Nothing) Then rng.ColumnWidth = 30 Else rng.ColumnWidth = 10.71 End If End Sub Sutun seimini makrodaki ("C:C") deeriyle oynayarak deitirebilirsiniz rnek:("E:E") veya ("A:A") Kod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Set rng = Columns("C:C") If Not (Intersect(Target, rng) Is Nothing) Then rng.ColumnWidth = 30 Else rng.ColumnWidth = 10.71 End If End Sub Sub bul() Dim cell As Range i=0 For Each cell In Sheets("Sayfa1").Range("B1:B" & Range("B65536").End(xlUp).Row) i=i+1 If cell = "kubilay" Then cell.Offset(0, 1) = "bulundu" End If Debug.Print i Next cell End Sub
Dim d, x, y d = GetSetting("DANISMAN", "Ayarlar", "Ilk Giris", "") If d = "" Then SaveSetting "DANISMAN", "Ayarlar", "Ilk Giris", Date Else If (Date - CDate(d)) > 365 Then MsgBox ("Programin Demo Sresi dolmustur.") DoCmd.Close Application.Quit Else x = GetSetting("DANISMAN", "Ayarlar", "Son ikis Tarihi", "") If x = "" Then 'End Else If CVDate(x) > Date Then MsgBox ("Programin Deneme Sresi Doldu Ltfen Israr Etmeyin") DoCmd.Close Else y = GetSetting("DANISMAN", "Ayarlar", "Son ikis Saati", "") If (CVDate(x) = Date) And (CVDate(y) > Time) Then MsgBox ("Programin Deneme Sresi Doldu Ltfen Israr Etmeyin") DoCmd.Close End If End If x = GetSetting("DANISMAN", "Ayarlar", "Sayi", "1") MsgBox ("Programi" & x & ". defa alistiriyorsunuz.") SaveSetting "DANISMAN", "Ayarlar", "Sayi", x + 1 End If End If End If siparisfrm.Show Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) SaveSetting "DANISMAN", "Ayarlar", "Son ikis Tarihi", Date SaveSetting "DANISMAN", "Ayarlar", "Son ikis Saati", Time Application.Visible = True Application.Quit End Sub Dim NextTime As Date Sub Flash() NextTime = Now + TimeValue("00:00:01") With ActiveWorkbook.Styles("Flash").Font If .ColorIndex = 2 Then .ColorIndex = 3 Else .ColorIndex = 2 End With Application.OnTime NextTime, "Flash" End Sub Sub StopIt() Application.OnTime NextTime, "Flash", schedule:=False ActiveWorkbook.Styles("Flash").Font.ColorIndex = xlAutomatic End Sub Private Sub UserForm_Activate() Dim Pausenlnge, Start, Ende, Gesamtdauer Pausenlnge = 10 ' Dauer festlegen. Start = Timer ' Anfangszeit setzen. UserForm1.Caption = "http://www.excel-lex.de.vu 2003 K.-M. Buss" Do While Timer < Start + Pausenlnge DoEvents ' Steuerung an andere Prozesse ' abgeben. Loop Ende = Timer ' Ende festlegen. Gesamtdauer = Ende - Start ' Gesamtdauer berechnen. UserForm1.Hide End Sub
Private Sub UserForm_Activate() ' Rcupration de l'heure d'affichage de la BdD TimeDebut = Timer ' Donne la main excel pour facilit l'affichage de la BdD DoEvents ' Boucle tant que 2 secondes ne se sont pas coul While Timer < TimeDebut + 10 Wend ' Fermeture de la BdD Unload Me End Sub Private Sub UserForm_Activate() Application.Wait Now + TimeSerial(0, 0, 3) Unload Me End Sub Sub Src_Harfi_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") s = d.DriveLetter MsgBox s End Sub Sub Src_Tipi_Gster() On Error GoTo hata: Dim ds, d, s, t Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("F:\") Select Case d.DriveType Case 0: t = "Bilinmiyor" Case 1: t = "karlabilir" Case 2: t = "HardDisk" Case 3: t = "A" Case 4: t = "CD-ROM" Case 5: t = "RAM Disk" End Select s = "Src " & d.DriveLetter & ": " & t MsgBox s End hata: MsgBox "Byle Bir Src Yok" End Src_Hazr_M_Gster() Sub Sub On Error GoTo hata: Dim ds, d, s, t Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("F:\") Select Case d.DriveType Case 0: t = "Bilinmiyor" Case 1: t = "karlabilir" Case 2: t = "HardDisk" Case 3: t = "A" Case 4: t = "CD-ROM" Case 5: t = "RAM Disk" End Select s = "Src " & d.DriveLetter & ": " & t If d.IsReady Then s = s & vbCrLf & "Src Hazr." Else s = s & vbCrLf & "Src Hazr Deil." End If MsgBox s End hata: MsgBox "Byle Bir Src Yok" End Sub
Sub Src_Seri_Numaras_Gster() On Error GoTo hata: Dim ds, d, s, t Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") Select Case d.DriveType Case 0: t = "Bilinmiyor" Case 1: t = "karlabilir" Case 2: t = "HardDisk" Case 3: t = "A" Case 4: t = "CD-ROM" Case 5: t = "RAM Disk" End Select s = "Src " & d.DriveLetter & ": " & t If d.IsReady Then s = s & vbCrLf & d.SerialNumber MsgBox s Else s = s & vbCrLf & "Src Hazr Deil." MsgBox s End If End hata: MsgBox "Byle Bir Src Yok" End Src_Seri_Numaras_Gster() Sub Sub On Error GoTo hata: Dim ds, d, s, t Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") Select Case d.DriveType Case 0: t = "Bilinmiyor" Case 1: t = "karlabilir" Case 2: t = "HardDisk" Case 3: t = "A" Case 4: t = "CD-ROM" Case 5: t = "RAM Disk" End Select s = "Src " & d.DriveLetter & ": " & t If d.IsReady Then s = s & vbCrLf & d.SerialNumber MsgBox s Else s = s & vbCrLf & "Src Hazr Deil." MsgBox s End If End hata: MsgBox "Byle Bir Src Yok" End Sub Sub Src_ara() Set ds = CreateObject("Scripting.FileSystemObject") a = ds.DriveExists(":\") If a = True Then MsgBox "Bu isimde bir src var" Else MsgBox "Bu isimde bir src yok" End If End Sub Sub Src_Says() Dim ds, dc, s Set ds = CreateObject("Scripting.FileSystemObject") Set dc = ds.Drives s = dc.Count MsgBox s End Sub
Sub Src_simleri() Dim ds, dc, s Set ds = CreateObject("Scripting.FileSystemObject") Set dc = ds.Drives For Each src In dc s = s & vbCrLf & src Next MsgBox s End Sub Sub Src_Harfi_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("C:\") s = d.DriveLetter MsgBox s End Sub Sub Bo_Alan_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive(ds.GetDriveName("C:\")) s = UCase(d) & " Srcsnde Bo Alan:" & Chr(13) _ + vbCrLf & FormatNumber(d.AvailableSpace) s = s & " Bytes" MsgBox s End Src_Hazr_M_Gster() Sub Sub On Error GoTo hata: Dim ds, d, s, t Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("F:\") Select Case d.DriveType Case 0: t = "Bilinmiyor" Case 1: t = "karlabilir" Case 2: t = "HardDisk" Case 3: t = "A" Case 4: t = "CD-ROM" Case 5: t = "RAM Disk" End Select s = "Src " & d.DriveLetter & ": " & t If d.IsReady Then s = s & vbCrLf & "Src Hazr." Else s = s & vbCrLf & "Src Hazr Deil." End If MsgBox s End hata: MsgBox "Byle Bir Src Yok" End Sub Sub Give_Filesystem() Dim myFSO As Object, myDrv As Object, strFS As String Set myFSO = CreateObject("Scripting.FileSystemObject") Set myDrv = myFSO.GetDrive("c:") strFS = myDrv.FileSystem MsgBox strFS End Sub Sub Src_ara() Set ds = CreateObject("Scripting.FileSystemObject") a = ds.DriveExists("G:\") If a = True Then MsgBox "Bu isimde bir src var" Else MsgBox "Bu isimde bir src yok" End If End Sub
Sub Src_Tipi_Gster() On Error GoTo hata: Dim ds, d, s, t Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive("F:\") Select Case d.DriveType Case 0: t = "Bilinmiyor" Case 1: t = "karlabilir" Case 2: t = "HardDisk" Case 3: t = "A" Case 4: t = "CD-ROM" Case 5: t = "RAM Disk" End Select s = "Src " & d.DriveLetter & ": " & t MsgBox s End hata: MsgBox "Byle Bir Src Yok" End Sub Sub AKTAR1() Range("l1:l100").ClearContents For x = 1 To 100 If Cells(x, 3) <> "" Then Cells(x, 12) = Cells(x, 3) Next End Sub Sub AKTAR2() c=0 Range("l1:l100").ClearContents For x = 1 To 100 If Cells(x, 3) <> "" Then c=c+1 Cells(c, 12) = Cells(x, 3) End If Next End Sub Sub sutunsec() Set Maplage = ActiveCell.CurrentRegion Nlignes = InputBox("birinci stun iin numara gir", , 1) Ncolonnes = InputBox("son stun iin numara gir", , 1) Maplage.Resize(Nlignes, Ncolonnes).Select MsgBox Selection.Address End Sub Sub Spaltenziffern() With Application .ReferenceStyle = xlR1C1 End With End Sub Sub Spaltenbuchstaben() With Application .ReferenceStyle = xlA1 End With End Sub Sub LargeurColonne() For Each col In Selection.Columns If col.Column Mod 2 = 0 Then col.ColumnWidth = 5 End If Next col End Sub Sub Dialog_13() Application.Dialogs(xlDialogColumnWidth).Show End Sub A1:AL1 hcreleri arasnda "Mahmut" yazan stunlar gizleme For Each ALAN In Range("A1:AL1") If ALAN.Value <> "Mahmut" Then ALAN.EntireColumn.Hidden = True End If Next End Sub
Se hcre=columns(D).Find (what:=ist.) - --> D stununda ist. Szc aranyor.Bulunan ilk hcrenin adresi hcre deikenine atanyor.What , find metodun bir argmandr. Sub sil() Range("c1").Select Application.ScreenUpdating = False Dim hucre As Range For Each hucre In Range("c1:c" & WorksheetFunction.CountA(Range("c1:c5000"))) Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ActiveCell.EntireRow.Select Selection.Delete Shift:=xlUp Next Application.ScreenUpdating = True End Sub Sub sil() Range("c1").Select Application.ScreenUpdating = False Dim hucre As Range For Each hucre In Range("c1:c" & WorksheetFunction.CountA(Range("c1:c5000"))) Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ActiveCell.EntireRow.Select Selection.Delete Shift:=xlUp Next Application.ScreenUpdating = True End Sub Sub Dme1_Tklat() ActiveSheet.UsedRange.Select Range("c1:c" & Cells(65536, 3).End(xlUp).Row).Select End Sub Sub DeleteRow() Application.ScreenUpdating = False Dim N As Long For N = Selection(1, 1).Row + Selection.Rows.Count - 1 _ To Selection(1, 1).Row Step -1 With Cells(N, 1) If .Value = 0 And Not .HasFormula Then .EntireRow.Delete End If End With Next N End sub Sub Dme1_Tklat() Selection.Copy 'seili alan kopyala Range("A:A").End(xlDown).Offset(1, 0).Select 'en son satra git ActiveSheet.Paste 'yaptr Application.CutCopyMode = False 'kopyalanlar iptal et End Sub Sub ZeileEinfuegen() Dim Zeile As Integer Zeile = 2 Application.ScreenUpdating = False Do Until Range("a" & Zeile).Value = "" Rows(Zeile & ":" & Zeile).Select Selection.Insert Shift:=xlDown Zeile = Zeile + 2 Loop Range("A1").Select Application.ScreenUpdating = True End Sub
Sub CountCellvide() numBlanks = 0 For Each c In Selection If c.Value = "" Then numBlanks = numBlanks + 1 End If Next c MsgBox "Il y a " & numBlanks & " cellules vides dans cette plage." End Sub Sub leere_zelle() [A1].Select ActiveCell.End(xlDown).Select ActiveCell.Offset(1, 0).Range("A1").Select End Sub Sub zahl_suchen() leere_Zeile = Range("A" & Rows.Count).End(xlUp).Row + 1 For i = 1 To leere_Zeile Range("A" & i).Select If ActiveCell = 5 Then Exit Sub Next i End Sub Private Sub metinayikla() Dim nums As String For i = 1 To Cells(65536, 1).End(xlUp).Row For b = 1 To Len(Cells(i, 1)) If IsNumeric(Mid(Cells(i, 1), b, 1)) = True Then nums = nums & Mid(Cells(i, 1), b, 1) End If Next b Cells(i, 1) = nums nums = "" Next i End Sub Sub BosHucreyeGit() ActiveCell.End(xlDown).Offset(1, 0).Select ' stundaki ilk bo hcreye gider End Sub Sub NombreDeLigne() With Selection MsgBox Selection.Rows.Count End With End Sub Aadaki kodu uygulaynz. (Sayfa yazdrma ayarlarnz yaptnz varsaydm.) Kod: Sub GZLE_YAZDIR() Range("C:C,F:F,H:H").Select 'Buradaki stunlar artrabilirsiniz. Selection.EntireColumn.Hidden = True Range("A1").Select ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True End Sub Gizlenen stunlarda tekrar grnr hale getirmek iin aadaki kodu uygulayn. Kod: Sub STUNLARI_GSTER() Range("C:C,F:F,H:H").Select Selection.EntireColumn.Hidden = False Range("A1").Select End Sub Sub ajuste_colonne() Selection.Columns.AutoFit End Sub Sub CompteLesNonVides() NonVide = 0 For Each Cellule In Selection.Cells If Not IsEmpty(Cellule) Then NonVide = NonVide + 1 Next MsgBox "Il y a " & NonVide & " cellules non vides dans la slection" End Sub
Sub Somme_Rouge() Dim Cel As Range Dim SomRoug As Integer For Each Cel In Selection If Cel.Font.ColorIndex = 3 Then SomRoug = SomRoug + Cel End If Next Range("A1") = SomRoug End Sub Sub Select_from_ActiveCell_to_Last_Cell_in_Column() Dim topCel As Range Dim bottomCel As Range On Error GoTo errorHandler Set topCel = ActiveCell Set bottomCel = Cells((65536), topCel.Column).End(xlUp) If bottomCel.Row >= topCel.Row Then Range(topCel, bottomCel).Select End If Exit Sub errorHandler: MsgBox "Error no. " & Err & " - " & Error End Sub Sub Auto_Open() [M1] = WorksheetFunction.Sum(Range("L1:L65536")) - WorksheetFunction.Sum(Range("J1:J65536")) End Sub Sub setPrintArea() Dim rng As Range Set rng = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) stcell = "A1": lcell = rng.Address ActiveSheet.PageSetup.PrintArea = stcell & ":" & lcell End Sub 1. Veri adnda bir sayfay index'i 1 olacak ekilde ayarlayn. Yani en sol baa yerletirin. 2. Veri sayfasna A1'den balayarak isimleri srasyla yaznz. 3. Veri sayfasn takip eden ilk Sayfa'da bahsettiiniz deerler olsun. Yani bu sayfannda index'i 2 olmal. Soldan ikinci sayfa yani. 4. Yeteri kadar sayfa an. Yani isimleriniz kadar sayfa ekleyin. Bunu otomatik de yapabilirdik ama bu satrlar yazarken aklma geldi. Aadaki kodu ekleyin. Sub Aktarma_Yap() Dim i As Integer Set veri = Worksheets("Veri") For i = 1 To 2 Range("A1").AutoFilter Range("A1").AutoFilter Field:=1, Criteria1:=veri.Cells(i, 1) Range("A1").CurrentRegion.Copy Sheets(i + 2).Range("A1") Next i End Sub Deerlerinizin olduu sayfadan bu kodu altrn Private Sub CommandButton1_Click() k=1 For i = 1 To Range("B65536").End(xlUp).Row If Range("A" & i).Font.Color = vbRed Then Cells(k, 3) = Cells(i, 2) k=k+1 End If Next i End Sub Selection.AutoFilter Field:=5, Criteria1:=ComboBox1.Value Private Sub Worksheet_SelectionChange(ByVal Target As Range) If [B18].Value = 20 Then Call Makro1 End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address <> "$B$1" Then Exit Sub If [b1] < [a1] Then MsgBox "girdiiniz deer yanl" End Sub
Private Sub ListBox1_Click() If ListBox1.ListIndex = -1 Then CommandButton1.Enabled = False Else CommandButton1.Enabled = True End If End Sub ilk bata komut dmesinin enable zelliini false yapmay unutmayn. Sub Auto_Open() Worksheets("Sayfa1").OnCalculate = "PlayIt" End Sub Sub PlayIt() If Range("A1").Value > 5 Then ExecuteExcel4Macro ("SOUND.PLAY(,""C:\Windows\Media\Tada.wav"")") End If End Sub
ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, _ ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function CreateRoundRectRgn Lib "gdi32" ( _ ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, _ ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, _ ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, _ ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, _ ByVal nCombineMode As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, _ ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Private Declare Function DeleteObject Lib "gdi32" (_ ByVal hObject As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private frmRegion As Long, hWnd As Long, msg1 As String, msg2 As String Private Sub CommandButton1_Click() Unload Me End Sub Private Sub UserForm_Initialize() seffaf End Sub Private Sub seffaf() Dim W As Single, H As Single, cl As Long Dim ct As Long, cw As Long, ch As Long Dim i As Integer, R As Long, Outer As Long, Inner As Long ' 1 pixel = 0.75 point / 1 point = 1.33 pixel hWnd = FindWindow(vbNullString, Me.Caption) W = Me.Width * 1.33: H = Me.Height * 1.33 frmRegion = CreateRectRgn(0, 0, 0, 0) ' X = (W - ScaleWidth) / 2 -> Genelde 3 ' Y = H - X - ScaleHeight -> Genelde 22 Const X As Single = 3: Const Y As Single = 22 Const RGN_OR = 2 Const RGN_DIFF = 4 Outer = CreateRectRgn(0, 0, W, H) Inner = CreateRectRgn(X, Y, W - X, H - X) CombineRgn frmRegion, Outer, Inner, RGN_DIFF For i = 0 To Me.Controls.Count - 1 If Me.Controls(i).Visible Then ct = Y + (1.33 * Me.Controls(i).Top) ch = ct + (1.33 * Me.Controls(i).Height) cl = X + (1.33 * Me.Controls(i).Left) cw = cl + (1.33 * Me.Controls(i).Width) R = CreateRectRgn(cl, ct, cw, ch) CombineRgn frmRegion, R, frmRegion, RGN_OR End If Next SetWindowRgn hWnd, frmRegion, True End Sub Private Sub UserForm_QueryClose(Cancel As Integer, _ CloseMode As Integer) SetWindowRgn hWnd, 0, False DeleteObject frmRegion End Sub
If Option1.Value = True a = Val(Text1.Text) b = 3.14 * a ^ 2 Text3.Text = b End If If Option2.Value = True a = Val(Text1.Text) b=a^2 Text3.Text = b End If If Option3.Value = True a = Val(Text1.Text) b = Val(Text2.Text) c=a*b Text3.Text = c End If If Option4.Value = True a = Val(Text1.Text) b = Val(Text2.Text) c = (a * b) / 2 Text3.Text = c End If End Sub
Then
Then
Then
Then
Private Sub option1_click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Label2.Visible = False Text2.Visible = False Label1.Caption = "yarap(r)" Label3.Caption = "Alan" End Sub Private Sub option2_click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Label2.Visible = False Text2.Visible = False Label1.Caption = "Kenar(a)" Label3.Caption = "Alan" End Sub Private Sub option3_click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Label2.Visible = True Text2.Visible = True Label1.Caption = "Kenar(a)" Label2.Caption = "Kenar(b)" Label3.Caption = "Alan" End Sub Private Sub option4_click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Label2.Visible = True Text2.Visible = True Label1.Caption = "Taban(a)" Label2.Caption = "Ykseklik(h)" Label3.Caption = "Alan" End Sub
Bu komut Visual Basic ve VBA da dahili bir komut olduu iin herhangi bir n hazrla gerek duymaz. Grevi : Windows kayt defteri(registry)ne kayt yapar. Kullanm : SaveSetting Program(uygulama) ad, Blm, Anahtar, Deer Private Sub CommandButton1_Click() 'Bu prosedrde registry'e en son girilen kaydedilir. SaveSetting "partner", "Settings", "UserForm1", TextBox1.Text End Sub Yukardaki prosedirde registere gerekli kayt yaplyor. Aadaki prosedrde ise registry'e kaydedilen bilgi TextBoxa geri arlyor. Kaytlar okumak iin GetSetting komutu kullanlr. SaveSetting'in tersidir. Kullanm: Deiken = GetSetting (Program ad, Blm, Anahtar, [Kayt Yoksa Deer]) Kayt Yoksa Deer parametresi zorunlu deildir. Registerde belirtilen kayt yoksa varsaylan olarak atanacak deeri buraya yazabilirsiniz. Private Sub UserForm_Initialize() 'UserFormdaki TextBox1 e yazdnz en son bilgi UserForm aktif olduunda tekrar arlr TextBox1.Text = GetSetting("partner", "Settings", "UserForm1") End Sub Peki bu kayt register'in neresinde diye soranlara? Balat / altr 'a regedit yazp enter'e basn. Aadaki grlen resimdeki adrese ulan. Kayd orada greceksiniz. ThisWorkbook'a Private Sub Workbook_Open() Test1 End Sub Sub Test1() Dim NumberofColumns As Integer Dim BMax As Integer Dim InputErrorCheck As Boolean InputErrorCheck = False Do While InputErrorCheck = False NumberofColumns = Application.InputBox(prompt:="ifre kodunuzu giriniz ", Type:=1) If IsNumeric(NumberofColumns) Then If NumberofColumns <= 254 And NumberofColumns > 0 Then ' ifre kodunun 0-254 aras bir say olduu varsaylmtr. InputErrorCheck = True End If End If If NumberofColumns = False Then MsgBox ("lem iptal edildi") Exit Sub End If Loop MsgBox (NumberofColumns) ' Burada input alndktan sonra esas yaplmamk istenen ilem prosedrleri arlacak End Sub
2 adet TextBox 1.si ifre 2.ifre Tekrar yazma '1 adet Command Buton giri Private Sub CommandButton1_Click() If TextBox1.Value = "kubilay" Or TextBox1.Value = "B" Then GoTo Kontrol2 Else Unload UserForm1 MsgBox "TEKRAR DENE STERSEN OLMADI!", vbCritical, "HATA" ActiveWorkbook.Close 0 Exit Sub End If Kontrol2: If TextBox2.Value = "kubilay" Or TextBox2.Value = "2" Then MsgBox "Programa giriiniz onaylanmtr.", vbInformation Unload Me Application.Visible = True Else Unload UserForm1 MsgBox "zgnm girdiiniz parola hatal.", vbCritical, "HATA" ActiveWorkbook.Close 0 Exit Sub End If End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode <> 1 Then Cancel = True End Sub Public Sub DemoEncryptData() gszData = CStr(Application.InputBox("Enter a string to be encrypted.", "Encyrption Demo")) If (gszData <> CStr(False)) And (Len(gszData) > 0) Then EncryptDecrypt gszData MsgBox "The encrypted string is:" & vbLf & vbLf & gszData, vbInformation, "Encryption Demo" Else gszData = vbNullString End If End Sub Public Sub DemoDecryptData() If Len(gszData) > 0 Then EncryptDecrypt gszData MsgBox "The decrypted string is:" & vbLf & vbLf & gszData, vbInformation, "Encryption Demo" Else MsgBox "There is no stored data to decrypt.", vbExclamation, "Encryption Demo" End If End Sub Private Sub EncryptDecrypt(ByRef szData As String) Const lKEY_VALUE As Long = 215 Dim bytData() As Byte Dim lCount As Long bytData = szData For lCount = LBound(bytData) To UBound(bytData) bytData(lCount) = bytData(lCount) Xor lKEY_VALUE Next lCount szData = bytData End Sub If Date >= CDate("23.02.2005") Then sifre = InputBox("Devam edebilmek iin ifre girmelisiniz!", "Progranm Kullanm Sresi Dolmutur") If sifre <> "1234" Then Exit Sub End If MsgBox "alan kodlar"
Sub Registrierung() ActiveWindow.DisplayWorkbookTabs = False Worksheets("Codeabfrage").Select On Error GoTo Abbruch Application.EnableCancelKey = xlErrorHandler Application.DisplayAlerts = False Heute = Now Verfalldatum = #5/14/2003# 'Hier Verfalldatum im Format MM/TT/JJJJ eintragen If Verfalldatum < Heute Then Dim passwort As String passwort = InputBox("Die Testphase ist abgelaufen," & Chr(13) & Chr(13) & " bitte geben Sie Ihre Registrierungs-Nr.:", "Testphase abgelauf If passwort <> "36" Then Registrierung End If MsgBox ("Registrierung erfolgreich") ActiveWindow.DisplayWorkbookTabs = True Worksheets("Datenbereich").Select Application.DisplayAlerts = True End If Exit Sub Aufraeumen: Application.EnableCancelKey = xlInterrupt ThisWorkbook.Close Exit Sub Abbruch: ThisWorkbook.Close End Sub Sub sifreac() Dim a As Integer For a = 1 To 10000 Application.DisplayAlerts = False Workbooks.Open Filename:="C:\Documents and Settings\usak0018\Belgelerim\YTL.xls", Password:=a Next a End Sub Visual Basic ve VBA da dahili bir komut olduu iin herhangi bir n hazrla gerek duymaz. Bu komut Grevi : Windows kayt defteri(registry)ne kayt yapar. Kullanm : SaveSetting Program(uygulama) ad, Blm, Anahtar, Deer Private Sub CommandButton1_Click() 'Bu prosedrde registry'e en son girilen kaydedilir. SaveSetting "partner", "Settings", "UserForm1", TextBox1.Text End Sub Yukardaki prosedirde registere gerekli kayt yaplyor. Aadaki prosedrde ise registry'e kaydedilen bilgi TextBoxa geri arlyor. Kaytlar okumak iin GetSetting komutu kullanlr. SaveSetting'in tersidir. Kullanm: Deiken = GetSetting (Program ad, Blm, Anahtar, [Kayt Yoksa Deer]) Kayt Yoksa Deer parametresi zorunlu deildir. Registerde belirtilen kayt yoksa varsaylan olarak atanacak deeri buraya yazabilirsiniz. Private Sub UserForm_Initialize() 'UserFormdaki TextBox1 e yazdnz en son bilgi UserForm aktif olduunda tekrar arlr TextBox1.Text = GetSetting("partner", "Settings", "UserForm1") End Sub
Peki bu kayt register'in neresinde diye soranlara? Balat / altr 'a regedit yazp enter'e basn. Aadaki grlen resimdeki adrese ulan. Kayd orada greceksiniz. Aadaki kodu gncelletirme yaplan dosyann thisworkbook sayfasna kopyalayn. Dosyay her atnzda link olan tm dosyalar otomatik olarak gncel Private Sub workbook_open() Link = ActiveWorkbook.LinkSources(xlExcelLinks) If IsEmpty(Link) = False Then For a = 1 To UBound(Link) Workbooks.Open Link(a), Password:="9876", WriteResPassword:="9876" ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources ActiveWorkbook.Close False Next End If End Sub
Microsoft nternet Transfer Control, version 6.0 ekleyiniz. C:\Windows\System32 de MSINET.OCX i Bu kodlar genellikle *.html ve *.htm uzantl sayfalarda ilem grmektedir. partner = Inet1.OpenURL("http://www.tcmb.gov.tr/kurlar/today.html") TextBox1.Text = Mid(partner, InStr(partner, "USD") + 42, 6) & " YTL" ' USD adl kelimeyi bulur ve 42. karakterden itibaren 6 karakter sandakine kadar TextBox2.Text = Mid(partner, InStr(partner, "USD") + 55, 6) & " YTL" TextBox3.Text = Mid(partner, InStr(partner, "EUR") + 42, 6) & " YTL" TextBox4.Text = Mid(partner, InStr(partner, "EUR") + 55, 6) & " YTL" Private Sub TextBox2_Enter() Me.TextBox2.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection End Sub Private Sub TextBox2_Enter() Me.TextBox2.EnterFieldBehavior = fmEnterFieldBehaviorSelectAll End Sub YEN VER GRMEK N TABLOYU BOALTIR Private Sub CommandButton5_Click() Unload Gnlk Gnlk.Show End Sub 'TABLOYU TEMZLE Private Sub CommandButton10_Click() ComboBox1.Value = "" TextBox2.Value = "" TextBox3.Value = "" ComboBox1.SetFocus End Sub YEN VER GRMEK N TABLOYU BOALTIR Private Sub CommandButton5_Click() Unload Gnlk Gnlk.Show End Sub 'TABLOYU TEMZLE Private Sub CommandButton10_Click() ComboBox1.Value = "" TextBox2.Value = "" TextBox3.Value = "" ComboBox1.SetFocus End Sub Private Sub Workbook_Open() Tabelle1.WebBrowser1.Navigate "http://www.mynet.com" End Sub Private Sub Workbook_Open() Tabelle1.WebBrowser1.Navigate "http://www.excel.web.tr" End Sub Makro blmne yaptrn ve tua atayn Tam ekran iin Kod: Sub tam() Application.DisplayFullScreen = True End Sub Normal grnm iin Kod: Sub normal() Application.DisplayFullScreen = False End Sub
Dim varYear As Variant Dim bytMonth As Byte Dim bytDay As Byte Dim bytWeekday As Byte Dim strWeekday As String Dim ws As Worksheet varYear = 2005 For Each ws In Worksheets If ws.Name = "Jahr " & varYear Then ws.Delete End If Next ws Set ws = Worksheets.Add ws.Name = "Jahr " & varYear For bytMonth = 1 To 12 With Cells(1, bytMonth) .Value = Format(DateSerial(varYear, bytMonth, 1), "mmmm") .Interior.ColorIndex = 36 .Font.Bold = True End With For bytDay = 1 To Day(DateSerial(varYear, bytMonth + 1, 0)) With Cells(bytDay + 1, bytMonth) bytWeekday = Weekday(DateSerial(varYear, bytMonth, bytDay)) strWeekday = WhichWeekday(bytWeekday) .Value = strWeekday & ", " & bytDay If bytWeekday = 7 Or bytWeekday = 1 Then .Interior.ColorIndex = 22 End If End With Next bytDay Next bytMonth End Sub Function WhichWeekday(ByVal bytWeekday As Byte) As String Select Case bytWeekday Case 1 WhichWeekday = "pazar" Case 2 WhichWeekday = "p.tesi" Case 3 WhichWeekday = "sal" Case 4 WhichWeekday = "carsamba" Case 5 WhichWeekday = "persembe" Case 6 WhichWeekday = "cuma" Case 7 WhichWeekday = "c.tesi" End Select End Function Sub Tam_Dizin_smi() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.GetAbsolutePathName("") MsgBox a End Sub Sub Tam_Dizin_smi() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") a = ds.GetAbsolutePathName("") MsgBox a End Sub
Sub tam() Application.DisplayFullScreen = True End Sub BYLTR EKRANI Sub Auto_Open() Sheets("kitap1").Select Application.DisplayFullScreen = True Application.DisplayFormulaBar = False Application.DisplayFormulaBar = False With ActiveWindow .DisplayHorizontalScrollBar = False .DisplayVerticalScrollBar = False .DisplayWorkbookTabs = False End With Range("A1").Select End Sub EKARNI KLTR Sub Auto_Close() Sheets("kitap1").Select Application.DisplayFullScreen = False Application.DisplayFormulaBar = True With ActiveWindow .DisplayHorizontalScrollBar = True .DisplayVerticalScrollBar = True .DisplayWorkbookTabs = True End With End Sub EKRANI BYLTR Sub Auto_Open() Sheets("kitap1").Select Application.DisplayFullScreen = True Application.DisplayFormulaBar = False Application.DisplayFormulaBar = False With ActiveWindow .DisplayHorizontalScrollBar = False .DisplayVerticalScrollBar = False .DisplayWorkbookTabs = False End With Range("A1").Select End Sub EKARNI KLTR Sub Auto_Close() Sheets("kitap1").Select Application.DisplayFullScreen = False Application.DisplayFormulaBar = True With ActiveWindow .DisplayHorizontalScrollBar = True .DisplayVerticalScrollBar = True .DisplayWorkbookTabs = True End With End Sub Private Sub UserForm_Activate() Me.Top = Application.Top Me.Left = Application.Left Me.Height = Application.Height Me.Width = Application.Width End Sub Application.DisplayFullScreen = True Application.CommandBars("Full Screen").Enabled = False Sub name_delete() Dim definedName As Object For Each definedName In ActiveWorkbook.Names definedName.Delete Next End Sub
(a2 ve b2 hcre adresi yaz rn: b12:c60) Sub SL() Sheets("Sayfa1").Select Set ALAN1 = [A2] Set ALAN2 = [B2] If ALAN1 <> "" Then Sheets("Sayfa1").Range(ALAN1).ClearContents If ALAN2 <> "" Then Sheets("Sayfa2").Range(ALAN2).ClearContents Sheets("Sayfa1").Select MsgBox "LEM TAMAMLANMITIR.", vbInformation End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value <> "" And IsDate(TextBox1.Value) = False Then MsgBox ("hatal veri girii" & vbCrLf & TextBox1) TextBox1.Value = "" Else TextBox1 = Format(TextBox1, "dd.mm.yyyy") End If End Sub ayekle(EklenecekSure As Integer, ilkTarih As Date) Function ayekle = DateAdd("m", EklenecekSure, ilkTarih) End Function Function yilekle(EklenecekSure As Integer, ilkTarih As Date) yilekle = DateAdd("yyyy", EklenecekSure, ilkTarih) End Function Function gunekle(EklenecekSure As Integer, ilkTarih As Date) gunekle = DateAdd("d", EklenecekSure, ilkTarih) End Function Function ayfarki(ilkTarih As Date, sonTarih As Date) ayfarki = DateDiff("m", ilkTarih, sonTarih) End Function Function yilfarki(ilkTarih As Date, sonTarih As Date) yilfarki = DateDiff("yyyy", ilkTarih, sonTarih) End Function Function gunfarki(ilkTarih As Date, sonTarih As Date) gunfarki = DateDiff("d", ilkTarih, sonTarih) End Function Function ayinsonu(tarih As Date) Dim ay As Integer Dim yil As Integer ay = Month(tarih) yil = Year(tarih) ayinsonu = IIf(ay = 2, IIf((yil Mod 4) > 0, 28, 29), IIf(ay = 4, 30, IIf(ay = 6, 30, IIf(ay = 9, 30, IIf(ay = 11, 30, 31))))) End Function Function yildakigun(tarih As Date) Dim yil As Integer yil = Year(tarih) yildakigun = IIf((yil Mod 4) > 0, 365, 366) End Function Function TarihEkle(Tarih As Date, Optional Gun As Integer, Optional Hafta As Integer, Optional Ay As Integer, Optional Yil As Integer) TarihEkle TarihEkle TarihEkle TarihEkle = = = = DateAdd("d", Gun, Tarih) DateAdd("ww", Hafta, TarihEkle) DateAdd("m", Ay, TarihEkle) DateAdd("yyyy", Yil, TarihEkle)
End Function
Private Sub Kaydet_Click() Sheets("Sayfa1").Select On Error Resume Next Dim i, r, y As Integer Dim s As String Dim q As Date s = txtyer For i = 5 To WorksheetFunction.CountA(Range("a2:a40")) + 1 If Cells(i, 1).Value = s Then q = txttarih For r = 5 To WorksheetFunction.CountA(Range("a3:AJ40")) + 1 If Cells(3, r).Value = q Then d = txtsonu Cells(i, r).Value = d MsgBox "KAYIT TAMAMLANDI", , "KAYIT" Exit Sub End If Next r End If Next i MsgBox "ARANAN YER BULUNAMADI !" End Sub Dim tarih As Date, hafta As Integer tarih = Date hafta = DatePart("ww", tarih, vbMonday, vbFirstJan1) MsgBox "Bugn: " & Date & " --> Yln " & hafta & ". Haftas" Sub Auto_Open() Dim exdate As Date exdate = "11/30/2004" If Date > exdate Then MsgBox ("You have reached end of your trail period") ActiveWorkbook.Close End If MsgBox ("You have " & exdate - Date & "Days left") End Sub sub deneme() [d2].select selection.numberformat = "yyyy/mm/dd hh:mm:ss" end sub Sub ConvertToDateSerial() 'Convert from recognizable US date to date serial 'For dates on/after March 1, 1900 back to dateserial Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Dim cell As Range On Error Resume Next '-- in case no cells selected For Each cell In Intersect(Selection, _ Selection.SpecialCells(xlCellTypeConstants)) cell.Value = Int(DateValue(cell.Value)) cell.NumberFormat = "general" Next cell Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub
Sub YearWorkbook() Dim iWeek As Integer Dim sht As Variant Dim sTemp As String Dim dSDate As Date sTemp = InputBox("Date for the first worksheet:", "End of Week?") dSDate = CDate(sTemp) Application.ScreenUpdating = False Worksheets.Add After:=Worksheets(Worksheets.Count), _ Count:=(52 - Worksheets.Count) For Each sht In Worksheets sht.Name = Format(dSDate, "dd-mmm-yyyy") dSDate = dSDate + 7 Next sht Application.ScreenUpdating = True End Sub Sub tarih() If [a1] = Date Then [b1] = 1 End If If [a1] = Date + 1 Then [b1] = 2 End If If [a1] = Date + 2 Then [b1] = 3 End If End Sub Public Sub Dateikopie() Dim InI As Integer Workbooks.Add With ThisWorkbook ' Datei mit Code ActiveWorkbook.SaveAs .Path & "\Kopie_von" & ThisWorkbook.Name ' neue Datei Workbooks.Add For InI = .Worksheets.Count To 1 Step -1 ' Anzahl Register in ThisWorkbook Sheets.Add .Worksheets(InI).Cells.Copy With ActiveWorkbook.ActiveSheet.Cells .PasteSpecial Paste:=xlPasteValues ' Werte .PasteSpecial Paste:=xlFormats ' Formate End With ActiveWorkbook.ActiveSheet.Name = .Worksheets(InI).Name Next InI Application.CutCopyMode = False 'Zwischenspeicher lschen Application.DisplayAlerts = False Worksheets(ActiveWorkbook.Worksheets.Count).Delete Application.DisplayAlerts = True MsgBox "Reine Datentabelle gespeichert als: " & .Path & "\Kopie_von" & ThisWorkbook.Name ActiveWorkbook.Close True End With End Sub Sub DateiUnter TagesdatumAbspeichern() Tagesdatum = Application.Text(Now(), "mm-dd-yy hh-mm") Sicherung = "Backup" & Tagesdatum & ".XLS" ActiveWorkbook.SaveCopyAs Sicherung End Sub Sub tarihli_yedek_al() Dim dname As String, strTest As String dname = "C:\DATA\kubilay.xls" & Format(Now(), "yyyy_mmdd") strTest = Dir(dname, vbDirectory) If (strTest = "") Then MkDir (dname) ActiveWorkbook.SaveCopyAs dname & "\BK_" & Range("A1") & Range("a2") ActiveWorkbook.Save End Sub Sub tarihli_yedek_al() Dim dname As String, strTest As String dname = "C:\DATA\" & Range("A1") & " " & Range("a2") & Format(Now(), "yyyy_mmdd") strTest = Dir(dname, vbDirectory) If (strTest = "") Then MkDir (dname) ActiveWorkbook.SaveCopyAs dname & "\BK_" & Range("A1") & Range("a2") ActiveWorkbook.Save End Sub
Private sub Commandbutton1_click() TextBox9 = Format(DateAdd("d", -TextBox4, ComboBox6), "dd.mm.yyyy") end sub Sub tarih_parca_al() Dim cevap As Date cevap = InputBox("Enter date", "ENTER", "DD.MM.YYYY") If IsDate(cevap) Then FTarih = Left(cevap, 2) & Mid(cevap, 3, 2) & Right(cevap, 4) gun = Left(cevap, 2) gunay = Left(cevap, 2) & Mid(cevap, 4, 2) yl = Right(cevap, 4) ay = Mid(cevap, 4, 2) Else If Response = vbRetry Then cevap = InputBox("Tarih giriniz", "GR", "DD.MM.YYYY") FTarih = Left(cevap, 2) & Mid(cevap, 3, 2) & Right(cevap, 4) gun = Left(cevap, 2) gunay = Left(cevap, 2) & Mid(cevap, 3, 2) yl = Right(cevap, 4) ay = Mid(cevap, 4, 2) End If End If MsgBox "Girmi olduunuz tarihin ayrntl dkm " & Chr(13) _ & "Gn :" & gun & Chr(13) _ & "Ay :" & ay & Chr(13) _ & "Yl :" & yl & Chr(13) _ & "Gn ve ay :" & gunay & Chr(13) End Sub Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Sub UserForm_Activate() Dim hWnd As Long, exLong As Long hWnd = FindWindowA(vbNullString, Me.Caption) exLong = GetWindowLongA(hWnd, -16) If exLong And &H880000 Then SetWindowLongA hWnd, -16, exLong And &HFF77FFFF Me.Hide: Me.Show End If End Sub Sub kayt() UserForm1.OptionButton1.Visible = False UserForm1.OptionButton2.Visible = False UserForm1.Show End Sub Sub temizle() For t = 1 To Sheets.Count Sheets(t).Select For Each hucre In [a1:e20] If hucre.Interior.Color = vbYellow Then hucre.ClearContents Next Next End Sub
Bu forml ile A1 hcresindeki ismin "Ad" ksmn B1 hcresine alm bulunmaktayz. Formln bu kadar uzun olmasna neden olan ise baz adlarn 2 isimd Soyadlarn ayrmak iin de C1 hcresine aadaki forml girin: =PARAAL(A1;UZUNLUK(B1)+2;UZUNLUK(A1)-UZUNLUK(B1))
B1 ve C1 hcresindeki formlleri listeniz uzunluunca kopyaladnda listenizdeki btn kaytlar "Ad" ve "Soyad" halinde 2 farkl stuna kopyalanm olac Sub yaz() For a=1 To 22 [j7]=a ActiveSheet.PrintOut Next End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$C$18" Then Sheets("Sayfa2").Select End Sub Sub Dialog_11() Application.Dialogs(xlDialogClear).Show End Sub Sub ReverseText() Dim strText As String, strReverseText As String Dim intPos As Integer, intLen As Integer strText = Selection.Text intLen = Len(strText) For intPos = 1 To Len(strText) strReverseText = strReverseText & Mid(strText, intLen - intPos + 1, 1) Next intPos ActiveCell.FormulaR1C1 = strReverseText End Sub Private Sub UserForm_Initialize() TextBox1 = Format(Date, "mm.dd.yyyy") End Sub
saat iinde;
Private Sub UserForm_Initialize() TextBox1 = Format(Time, "hh:mm") End Sub A stununda isimler var Formuma eklediim textbox kutusunun ad "isim" ve o ismi listeden bulmak istiyorum.. --------------------Dim bak As Range For Each bak In Range("A1:A" & WorksheetFunction.CountA(Worksheets("sayfa1").Range("A1:A10000"))) If StrConv(bak.Value, vbUpperCase) = StrConv(isim.Value, vbUpperCase) Then bak.Select msgbox("Aradnz " & ActiveCell.Offset(0, 0).Value & "isim bulundu. Hcre adresi" & ActiveCell.Offset(0, 0).address) ----------------mesaj kutusunda aradnz ismi ve adresini grntler. TextBox1.ForeColor = vbRed Private Sub TextBox1_Change() If Len(TextBox1.Text) >= 15 Then TextBox1 = Left(TextBox1, 15) If Len(TextBox1.Text) < 10 Then TextBox1 = Replace(TextBox1, " ", "") Else TextBox1.Text = Format(TextBox1, "(###) ### ## ##") End If End Sub Sub Text_Dosyas_A() Const ForReading = 1, ForWriting = 2, ForAppending = 3 'For Reading Sadece Okur,For Appending ise hem Okur hem Yazar Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.OpenTextFile("c:\testfile.txt", ForAppending, TristateFalse) 'TristateUseDefault'da System Default,TristateTrue 'da Unicode,TristateFalse'da ASCII kullanlr. End Sub
Sub Text_Dosyas_Olutur_Yaz() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") Set a = ds.CreateTextFile("C:\Deneme.txt", True, False) 'lk true Overwrite,kinci False ASCII true olursa Unicode a.WriteLine ("lk Satr") a.Close End Sub Sub Text_Dosyas_Test() Const ForReading = 1, ForWriting = 2, ForAppending = 3 Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.OpenTextFile("c:\deneme.txt", 2) f.write "Merhaba f.Close End Sub Dosya isminden sonra False yazarsak eski bilgilerin stne yazlmaz ve File Already Exists yani Dosya Zaten Var uyars gelir. True yazarsak,eski bilgiler silinir,yenileri yazlr. Bu rnekte bilgi yazma ksmna yer vermedik. Bilgi yazma ksm makalemizin ikinci ksmnda,Alt FSO blmnde bulunmaktadr. kinci ksm False olursa dosya ASCII,True olursa UNICODE olur. Sub Text_Dosyas_Olutur() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") Set a = ds.CreateTextFile("C:\SXS\Deneme.txt", True, False) 'lk true Overwrite,kinci False ASCII true olursa Unicode End Sub Dosya silmeye yarar.Dosya isminden sonra gelen yere ,dosya Salt okunursa True yazmalsnz.Yoksa "Access Denied" yani "Giri Reddedildi" der. Sub Dosya_Sil() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.DeleteFile "C:\SXS\Deneme.txt", True End Sub Sub Text_Dosyas_A() Const ForReading = 1, ForWriting = 2, ForAppending = 3 'For Reading Sadece Okur,For Appending ise hem Okur hem Yazar Dim ds, f Set ds = CreateObject("Scripting.FileSystemObject") Set f = ds.OpenTextFile("c:\testfile.txt", ForAppending, TristateFalse) 'TristateUseDefault'da System Default,TristateTrue 'da Unicode,TristateFalse'da ASCII kullanlr. End Sub Sub Text_Dosyas_Olutur_Yaz() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") Set a = ds.CreateTextFile("C:\Deneme.txt", True, False) 'lk true Overwrite,kinci False ASCII true olursa Unicode a.WriteLine ("lk Satr") a.Close End Sub
Sub Import() Open "d:\data.txt" For Input As #1 R=1 While Not EOF(1) 'Scan file line by line C=1 Entry = "" Line Input #1, Buffer Length = Len(Buffer) i=1 While i <= Length 'split comma-delimited string into cells If (Mid(Buffer, i, 1)) = "," Then With Application.Cells(R, C) .NumberFormat = "@" 'Text formatting .Value = Entry End With C=C+1 Entry = "" Else Entry = Entry + Mid(Buffer, i, 1) End If i=i+1 Wend If Len(Entry) > 0 Then With Application.Cells(R, C) .NumberFormat = "@" 'Text formatting .Value = Entry End With End If R=R+1 Wend Close #1 End Sub Sub OuvreTXT() Workbooks.OpenText Filename:="C:\ajeter\TEST.TXT", _ Origin:=xlWindows, StartRow:=1, _ DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, _ ConsecutiveDelimiter:=False, Tab:=False, _ Semicolon:=True, Comma:=False, Space:=False, _ Other:=False, FieldInfo:=Array(Array(1, 1), _ Array(2, 1), Array(3, 1)) End Sub Sub Dateiimport() Quelle = Application.GetOpenFilename("TXT-Dateien , *.TXT") Workbooks.OpenText Filename:=Quelle, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon _ :=False, Comma:=False, Space:=False, Other:=False, FieldInfo _ :=Array(1, 1) End Sub Sub satr_sonu() Dim ds, a, son Set ds = CreateObject("Scripting.FileSystemObject") Set a = ds.OpenTextFile("c:\deneme.txt") Do While a.AtEndOfline <> True son = a.Read(2) '2 rakam satr sonundaki 2 harfi verir. Loop MsgBox son a.Close End Sub TEK BOK 1' KESER (BAKA YERE YAPITIRMAK N) Private Sub CommandButton2_Click() TextBox1.Cut End Sub 'TEK BOKA VER YAPITIRIR Private Sub CommandButton7_Click() TextBox11.Paste End Sub
BU KODU TextBox1 E YAZARSANIZ TEXTBOXA GRDNZ VERLER A1 HCRESNE YAZAR Private Sub TextBox1_Change() [a1] = TextBox1.Text End Sub Textbox kna veya commandbutona balayabilirsiniz If Val(TextBox1.Text) <= 10 Then MsgBox "Say 10'den byk olmal", vbInformation TextBox1.SetFocus Exit Sub End If End Sub Private Sub TextBox1_Change() On Error Resume Next [aa1] = "=bykharf(""" & TextBox1 & """)" [aa1] = "=upper(""" & TextBox1 & """)" TextBox1 = [aa1] End Sub Veya; Private Sub TextBox1_Change() On Error Resume Next TextBox1 = Evaluate("=bykharf(""" & TextBox1 & """)") TextBox1 = Evaluate("=upper(""" & TextBox1 & """)") End Sub Private Sub CommandButton1_Click() For a = 1 To 40 b = Sheets("sayfa1").Cells(a, 1).Value If b = "" Then Sheets("sayfa1").Cells(a, 1) = TextBox1.Value Sheets("sayfa1").Cells(a, 2) = ComboBox1.Text GoTo 10 End If Next a Sheets("sayfa1").Cells(1, 3) = "TM SATIRLAR DOLU" 'UYARI MESAJI 10 End Sub Aadaki ekilde yazn sorununuz zlecektir. TextBox17=Format(TextBox17,"#,##0.00") Private Sub TextBox1_GotFocus() TextBox1.Text = "" End Sub Private Sub TextBox1_GotFocus() TextBox1.Text = "" End Sub Private Sub
TextBox1,TextBox2 ve TextBox3 olduunu varsayalm. TextBox1 A1 Hcresine iliik TextBox2 A2 Hcresine iliik TextBox3 A3 Hcresine iliik TextBox3'de Toplam Sonucu Grmek isterseniz. Textbox1 ve 2'deki deerleri TextBox3'de grmek iin. Kod: Private Sub TextBox1_Change() TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value) End Sub Private Sub TextBox2_Change() TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value) End Sub Hcredeki deeri Sn Leventm 'nin yazd ekilde zaten alyorsunuz. Ayrca Girdiiniz deerlerin TextBoxlarla birlikte Hcrelerde Annda grnmesini isterseniz. Kod: Private Sub TextBox1_Change() Range("A1").Select [a1] = TextBox1.Value TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value) End Sub Private Sub TextBox2_Change() Range("A2").Select [a2] = TextBox2.Value TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value) End Sub Private Sub TextBox3_Change() Range("A3").Select [a3] = TextBox3.Value End Sub If TextBox1 <> Empty Then TextBox1.SelStart = 0 TextBox1.SelLength = TextBox1.TextLength TextBox1.Copy MyData.GetFromClipboard MsgBox "TextBox1 icerigi hafizaya kopyaland...." End If Private Sub TextBox3_Change() TextBox3 = Format(TextBox3, "mm""/""dd""/""yyyy") End Sub
Private Sub TextBox2_Enter() TextBox1.BackColor = &HFFFF00 End Sub Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1.BackColor = vbWhite End Sub Private Sub TextBox4_Enter() TextBox3.BackColor = &HFFFF00 End Sub Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox3.BackColor = vbWhite End Sub Private Sub TextBox6_Enter() TextBox5.BackColor = &HFFFF00 End Sub Private Sub TextBox6_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox5.BackColor = vbWhite End Sub Private Sub TextBox8_Enter() TextBox7.BackColor = &HFFFF00 End Sub Private Sub TextBox8_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox7.BackColor = vbWhite End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If Len(TextBox1) < 11 Then MsgBox "EKSK KARAKTER GR !" & vbCrLf & "EN AZ 11 KARAKTER GREBLRSNZ.", vbCritical Cancel = True ElseIf Len(TextBox1) > 11 Then MsgBox "FAZLA KARAKTER GR !" & vbCrLf & "EN FAZLA 11 KARAKTER GREBLRSNZ.", vbCritical Cancel = True Else Cancel = False End If End Sub Private Sub CommandButton1_Click() 'Eer text kutusu grnmez ise grnr yap If TextBox1.Visible = False Then TextBox1.Visible = True: GoTo 10 'Eer text kutusu grnrse grnmez yap. If TextBox1.Visible = True Then TextBox1.Visible = False: GoTo 10 10: End Sub Private Sub CommandButton1_Click() Range("a1").Select ActiveCell.Formula = TextBox1 End Sub Private Sub TextBox1_Enter() TextBox1.BackColor = vbYellow End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1.BackColor = vbWhite End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Select Case Len(TextBox1.Value) Case Is >= 2 TextBox2.SetFocus Case Else TextBox2.Value = "" End Select End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If Len(TextBox1.Value) >= 2 Then TextBox2.Value = "Artk ben aktifim" Else TextBox2.Value = "" End If End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Select Case Len(TextBox1.Value) Case Is >= 2 TextBox2.Value = "Artk ben aktifim" Case Else TextBox2.Value = "" End Select End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "##,##.00") End Sub Private Sub Text1_KeyPress Dim strDizi As String strDizi = "1234567890," 'sayi ve virgl girebilir. Private Sub TextBox1_Change() uz = Len(TextBox1) par = Right(TextBox1, 1) If uz < 3 And IsNumeric(par) = False Or uz > 5 Then SendKeys "{bs}" If uz = 3 And par <> "." Then SendKeys "{bs}" If uz > 3 And IsNumeric(par) = False Then SendKeys "{bs}" End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii = 32 Then KeyAscii = 0 End If End Sub Private Sub TextBox1_Change() With TextBox1 .SelLength = 1 If .SelText = "." Then .SelStart = .SelStart + 1 .SelLength = 1 End If End With End Sub Private Sub UserForm_Initialize() With TextBox1 .MaxLength = 10 .EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection .Text = "##.##.####" .SelStart = 0 .SelLength = 1 End With End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If Right(TextBox1.Value, 4) >= 2000 Then TextBox1.Value = Format(TextBox1.Value, "dd""/""mm""/""yyyy") Else MsgBox "hatal" End If End Sub Private Sub TextBox1_Enter() TextBox1.BackColor = &HFF& End Sub Private Sub CommandButton1_Click() Application.ScreenUpdating = False satir = WorksheetFunction.CountA(Sheets("TABLO").Range("A1:A65536")) + 1 'VER sayfasnda, a kolonundaki son dolu hcreden sonraki satir Sheets("TABLO").Cells(satir, 1) = ComboBox1.Value Sheets("TABLO").Cells(satir, 2) = TextBox1.Value Sheets("TABLO").Cells(satir, 3) = TextBox2.Value Sheets("TABLO").Cells(satir, 4) = TextBox3.Value Sheets("TABLO").Cells(satir, 5) = TextBox4.Value ComboBox1.Value = "" TextBox1.Value = "" TextBox2.Value = "" TextBox3.Value = "" TextBox4.Value = "" End Sub
Public Function AutoType(c As Control, KeyAscii As Integer) As Integer AutoType = KeyAscii If KeyAscii > 95 And KeyAscii < 123 Then If c.SelStart = 0 Then AutoType = AutoType - 32 ElseIf Mid$(c.Text, c.SelStart, 1) < "!" Then AutoType = AutoType - 32 End If End If End Function Private Sub Text1_KeyPress(KeyAscii As Integer) KeyAscii = AutoType(Screen.ActiveControl, KeyAscii) End Sub Private Sub CommandButton5_Click() Dim Nesne As Control For Each Nesne In Controls Select Case TypeName(Nesne) Case "TextBox", "ComboBox" Nesne = "" End Select Next End Sub Private Sub UserForm_Initialize() With TextBox1 .EnterKeyBehavior = True .TabKeyBehavior = True .MultiLine = True End With End Sub Private Sub TextBox1_Change() If Len(TextBox1.Text) > 14 Then MsgBox ("Karakter says uzun") TextBox1.Enabled = False Else TextBox1.Enabled = True End If Label1.Caption = "Karakter say" & " " & Len(TextBox1.Text) & " " End Sub Private Sub UserForm_Click() End Sub Private Sub TextBox1_Change() On Error Resume Next Satrno = Sheets("Sayfa1").[B2:B65536].Find(TextBox1.Value).Row TextBox2 = Sheets("Sayfa1").Cells(Satrno, 3).Value End Sub
For i = 1 To Worksheets.Count If Sheets(i).Name = TextBox1 Then MyQ = MsgBox("Bu isimde bir irket var, deiik bir isim girmelisiniz !") TextBox1 = Empty TextBox1.SetFocus Exit Sub End If Next Set NewSh = Worksheets.Add With NewSh .Name = TextBox1 .Range("A1") = Label2 .Range("A2") = Label3 .Range("A3") = Label4 .Range("A4") = Label5 .Range("B1") = TextBox2 .Range("B2") = TextBox3 .Range("B3") = TextBox4 .Range("B4") = TextBox5 .Range("B5") = TextBox6 .Columns("A:A").ColumnWidth = 12 .Columns("B:B").ColumnWidth = 34 .Columns("C:C").ColumnWidth = 19 .Columns("D:D").ColumnWidth = 19 End With End If With Range("A9:D9") With .Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin End With With .Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin End With With .Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin End With With .Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin End With With .Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin End With End With With Range("A1:D8") .Borders(xlDiagonalDown).LineStyle = xlNone .Borders(xlDiagonalUp).LineStyle = xlNone With .Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin End With With .Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin End With With .Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin End With With .Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin End With .Borders(xlInsideVertical).LineStyle = xlNone .Borders(xlInsideHorizontal).LineStyle = xlNone End With Set NewSh = Nothing End Sub
Ocak, ubat, Mart...... gibi aylar A2:A13 aralnda, 1975, 1976,............... gibi yllar B1:L1 aralnda, UserForm zerinde TextBox1, TextBox2, Label1 ve CommandButton1 nesneleri varsa; Private Sub CommandButton1_Click() On Error GoTo ResumeSub: x = Range("A2:A13").Cells.Find(TextBox1).Row y = Range("B1:L1").Cells.Find(TextBox2).Column Label1.Caption = Cells(x, y) Exit Sub ResumeSub: Label1.Caption = "Deger bulunamadi...." End Sub Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1 <> 0 Then If TextBox1.Value < TextBox2 Then MsgBox "hata" TextBox2 = "" End if End If End Sub Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1 <> 0 And Val(TextBox1.Text) < Val(TextBox2.Text) Then MsgBox "hata":TextBox2 = "" End Sub Userforma aadaki kodu yazn. visual basic kodu: -------------------------------------------------------------------------------Private Sub UserForm_Initialize() TextBox7.TextAlign = fmTextAlignRight End Sub Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If (Asc(UCase(Chr(KeyAscii))) < 65 Or Asc(UCase(Chr(KeyAscii))) > 91) And KeyAscii <> 8 And KeyAscii <> 32 Then KeyAscii = 0 End If End Sub Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) UserForm2.Show End Sub Bir UserForm zerine 3 adet TextBox nesnesi ve 1 adet CommandButton nesnesi yerletirin. Aadaki kodlar UserForm'unuza kopyalayn. Private Sub CommandButton1_Click() Dim t1 As Double Dim t2 As Double t1 = TextBox1.Value t2 = TextBox2.Value TextBox3 = t1 + t2 End Sub Private Sub TextBox1_Change() TextBox1 = Format(TextBox1, "###,0") End Sub Private Sub TextBox2_Change() TextBox2 = Format(TextBox2, "###,0") End Sub Sub TextBox1_change() Dim N$ N = "0123456789." If KeyAscii <> 8 Then If InStr(N, Chr(KeyAscii)) = 0 Then Beep KeyAscii = 0 Exit Sub End If End If End Sub
Private Sub TextBox1_Change() If Len(TextBox1.Text) = 0 Then Exit Sub If Not IsNumeric(TextBox1.Text) Then Beep MsgBox "Numerik olmayan bir deer girdiniz" End If End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If IsNumeric(Chr(KeyAscii)) = False And KeyAscii <> 8 Then KeyAscii = 0 End If End Sub Private Sub txtkalper_Change() labtopkalper = Val(txtsevper) * 0.4 + Val(txtkalper) * 0.6 End Sub Sub hesaplama() zamoran: z = InputBox("Zam orann giriniz ! Ondalk ksm varsa virglle ayrnz !") If Not IsNumeric(z) Then GoTo zamoran Cells(1, 23) = (z + 100) / 100 End Sub Private Sub TextBox1_Change() If TextBox1 = "" Then Exit Sub deg = Mid(TextBox1.Value, Len(TextBox1.Value), 1) If IsNumeric(deg) = True Then MsgBox "SADECE HARF GRNZ" TextBox1 = Mid(TextBox1.Value, 1, Len(TextBox1.Value) - 1) TextBox1.SetFocus End If End Sub Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 190 Then MsgBox ("Nokta yerine (.) Virgl (,) kullann") End If End Sub
If Not IsNumeric(TextBox1) Then SendKeys "{BS}" Userformun code blmne yaptr,textbox'lar oaltabilirsin kopyala yaptr,makrodaki textbox1'i 2,3,4 gibi deitir(userformdaki textbox saysna gre) Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0: MsgBox " Harf girilmeyecek,Sadece Rakam Giriniz ....." End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) 'Girilen deer numerik deilse Textboxten k engelliyor, bu durumda bota olamyor. If IsNumeric(TextBox1.Value) Then Cancel = False Else Cancel = True Beep ' 'beep' sesi retiyor MsgBox ("Sadece say girin!") ' Uyar penceresi ayor. End If End Sub Private Sub UserForm_Initialize() TextBox1.MaxLength = 8 End Sub Private Sub TextBox1_Change() If Not IsNumeric(TextBox1) Then SendKeys "{BS}" End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 End Sub
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox3 <> "" Then If Val(TextBox3) > Val(TextBox2) Then
Select Case MsgBox("Textbox 2 den byk veri giriine izin verilsin mi...!", vbYesNo Or vbInformation Or vbSystemModal Or vbMsgBoxRight Or vbDefault Case vbYes TextBox3.Value = Format(TextBox3.Value, "#,##0.00") TextBox2.Value = Format(TextBox2.Value, "#,##0.00") TextBox4.SetFocus Case vbNo Cancel = True TextBox3.Value = "" End End End End Select If If Sub
TextBox1.Text = Format(DTPicker1, "dd.mm.yyyy") Private Sub Text1_GotFocus() ' textbox aktif olduunda Screen.ActiveControl.SelStart = 0 ' balangc 0 olarak ata Screen.ActiveControl.SelLength = Len(Screen.ActiveControl.Text) ' uzunluu textboxnkine eitle End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 1 Or TextBox1.Value > 12 Then MsgBox "Hata oldu n'apcaz imdi. Elbette Exit olaynn Cancel argmann kullanacaz" Cancel = True End If TextBox1 = "" End Sub TEK BOK 1' KESER (BAKA YERE YAPITIRMAK N) Private Sub CommandButton2_Click() TextBox1.Cut End Sub 'TEK BOKA VER YAPITIRIR Private Sub CommandButton7_Click() TextBox11.Paste End Sub Private Sub TextBox1_Change() [a2] = TextBox1.Text End Sub Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Label2.Caption = KeyCode TextBox1.Value = "" End Sub
TextBox nesnesinden "cursor - imle" ktnda bu iin yaplmasn istersen; Kod: Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "#,### TL") End Sub Private Sub TextBox1_Change() RefreshTxtBx End Sub veya yle olabilir. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "#,### TL") End Sub ' Private Sub TextBox2_Change() RefreshTxtBx End Sub ' Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox2 = Format(TextBox2, "#,### TL") End Sub ' Private Sub RefreshTxtBx() Dim Val1 As Double, Val2 As Double On Error Resume Next Val1 = TextBox1 Val2 = TextBox2 On Error GoTo 0 TextBox3 = Format(Val1 + Val2, "#,### TL") End Sub Private Sub CommandButton1_Click() if Textbox1.value="" then MsgBox("Textbox1'i Bo Geemessiniz") Exit sub End if if Textbox2.value="" then MsgBox("Textbox2'i Bo Geemessiniz") Exit sub End if if Textbox3.value="" then MsgBox("Textbox3'i Bo Geemessiniz") Exit sub End if if Textbox4.value="" then MsgBox("Textbox4'i Bo Geemessiniz") Exit sub End if End Sub 1. Userform oluturun 2. ine iki tane textbox oluturun 3. Textbox1 nesnesinin Exit olayna Cancel = True yazdnzda kullanc bu nesneyi bo geemez Private Sub CommandButton1_Click() Dim t1 As Date Dim t2 As Long t1 = TextBox1.Value t2 = TextBox2.Value TextBox3 = Format(t1 + t2, "dd.mm.yyyy") End Sub Private Sub CommandButton1_Click() TextBox1 = Val(TextBox2.Value) + Val(TextBox3.Value) End Sub TextBox isimlerini kendinize gre deitiriniz Private Sub ekle_Click() UserForm2.TextBox1.Value = UserForm2.TextBox1.Value & vbcrlf & TextBox2.Value & vbcrlf & TextBox3.Value End Sub Range("a1").value= Textbox1.value & " " & Textbox2.value
Private Sub CommandButton1_Click() If TextBox1.Value = "" And TextBox2.Value = "" Then MsgBox "Ltfen Bo Olan Alanlar doldurun. Bo olan nesne ad: " & Chr(13) & TextBox1.Name & " " & TextBox2.Name, vbQuestion, "UYARI" Exit Sub End If For x = 1 To 2 If Controls("TextBox" & x).Value = "" Then MsgBox "Ltfen Bo Olan Alanlar doldurun. Bo olan nesne ad: " & Chr(13) & Controls("TextBox" & x).Name, vbQuestion, "UYARI" Exit Sub End If Next x End Sub Private Sub CommandButton1_Click() If TextBox1 = "" Then BosOge = BosOge & vbLf & TextBox1.Name If TextBox2 = "" Then BosOge = BosOge & vbLf & TextBox2.Name If BosOge <> "" Then MsgBox "Aadaki alanlar bo:" & BosOge End If End Sub 1. Bir adet Class Module an. ve aadaki kodlar yaptrn. Public WithEvents txt As MSForms.TextBox Private Sub txt_Change() txt = Format(txt, "###,###") End Sub '2.UserForm'un kod sayfasna Dim txtler() As New Class1 Private Sub UserForm_Initialize() Dim kontrol As Control, i As Integer i=1 For Each kontrol In UserForm1.Controls If Left(kontrol.Name, 7) = "TextBox" Then ReDim Preserve txtler(i) Set txtler(i).txt = kontrol i=i+1 End If Next End Sub Private Sub CommandButton1_Click() z = Range("A1").End(xlDown).Row + 1 If z > 65000 Then z = 2 Cells(z, 1) = TextBox1 Cells(z, 2) = TextBox2 Cells(z, 3) = TextBox3 Cells(z, 4) = TextBox4 Cells(z, 5) = TextBox5 End Sub Private Sub CommandButton1_Click() Dim toplam For i = 1 To 47 Step 3 toplam = toplam + Val(Controls("TextBox" & i)) Next TextBox50.Value = Format(toplam, "###,###") End Sub TextBox1= Val(TextBox2.Value) + Val(TextBox3.Value) Private Sub TextBox1_Change() TextBox1.Text = Format(TextBox1.Text, "0000") End Sub Private Sub TextBox1_Change() Me.TextBox1.Value = Format(Me.TextBox1.Value, "###,###") End Sub Private Sub TextBox1_Change() TextBox1 = Format(TextBox1, "###,0") End Sub
Bir UserForm zerine 3 adet TextBox nesnesi ve 1 adet CommandButton nesnesi yerletirin. Aadaki kodlar UserForm'unuzua kopyalayn. Private Sub CommandButton1_Click() Dim t1 As Double Dim t2 As Double t1 = TextBox1.Value t2 = TextBox2.Value TextBox3 = t1 + t2 End Sub Private Sub TextBox1_Change() TextBox1 = Format(TextBox1, "###,0") End Sub Private Sub TextBox2_Change() TextBox2 = Format(TextBox2, "###,0") End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If st = EmailType Then If RTrim(TextBox1.Text) <> "" Then If InStr(TextBox1.Text, " ") <> 0 Or InStr(TextBox1.Text, "@") = 0 Or InStr(TextBox1.Text, ".") = 0 Then MsgBox "Geersiz email adresi !!!", vbInformation ', 'App.Title Exit Sub TextBox1.SetFocus 'Cancel = False 'End If End If End If End If End Sub Textbox a bir format tanmlamayn ve command butona aadaki kodu yazarak deneyin. visual basic kodu: -------------------------------------------------------------------------------Private Sub CommandButton1_Click() a = TextBox7.Value * 1000 [a1] = a / 1000 [a1].NumberFormat = "General" End Sub Private Sub TextBox1_Change() TextBox1 = StrConv(TextBox1, vbUpperCase) End Sub Private Sub TextBox1_Change() TextBox1.Value = UCase(TextBox1.Value) [A1]=TextBox1.value End Sub Private Sub TextBox1_Change() On Error Resume Next [aa1] = "=bykharf(""" & TextBox1 & """)" [aa1] = "=upper(""" & TextBox1 & """)" TextBox1 = [aa1] End Sub Private Sub TextBox1_Change() On Error Resume Next TextBox1 = Evaluate("=bykharf(""" & TextBox1 & """)") TextBox1 = Evaluate("=upper(""" & TextBox1 & """)") End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "###,###.00") End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "###,###.00") End Sub Private Sub TextBox1_LostFocus() TextBox1 = Format(TextBox1, ".##") End Sub
ekli dosyamda textboxa metin girii yaptmda 1. satrnn x ten balamas ve birde textboxta yazlan metni exceldeki gibi nasl iki yana yaslayabilirim. yar visual basic kodu: Private Sub TextBox1_Change() If Len(TextBox1) = 1 Then TextBox1 = " " & TextBox1 End Sub Private Sub TextBox3_Enter() TextBox3 = Ccur(TextBox1) + Ccur(TextBox2) End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "#,### TL") End Sub Private Sub TextBox1_Change() RefreshTxtBx End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "#,### TL") End Sub ' Private Sub TextBox2_Change() RefreshTxtBx End Sub ' Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox2 = Format(TextBox2, "#,### TL") End Sub ' Private Sub RefreshTxtBx() Dim Val1 As Double, Val2 As Double On Error Resume Next Val1 = TextBox1 Val2 = TextBox2 On Error GoTo 0 TextBox3 = Format(Val1 + Val2, "#,### TL") End Sub TextBox1 = Format(TextBox1, "###,0") parasal olarak bunu kullann Private Sub CommandButton1_Click() Range("a1").Select ActiveCell.Formula = TextBox1 End Sub Excele kayderkenKod: Cells(1,1) = "'" & textbox1.text Private Sub TextBox1_Change() TextBox1 = "0" & Format(TextBox1, "###,###") End Sub TextBox1.TextAlign = fmTextAlignRight Option Explicit Private Sub Command1_Click() Text2.Text = Seslisay(Text1.Text) End Sub Function Seslisay(Metin As String) As Integer Dim sayac, i As Integer Const Harfler = "aeiou" For i = 1 To Len(Metin) If InStr(Harfler, LCase(Mid(Metin, i, 1))) <> 0 Then sayac = sayac + 1 End If Next i Seslisay = sayac End Function TextBox2 = cint(Sheets("9b").Cells(x, 7)) TextBox3 = cint(Sheets("9b").Cells(x, 8)). Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "dd""/""mm""/""yyyy") End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If TextBox1.Text > "" Then If Not IsDate(TextBox1.Text) Then MsgBox "Tarih geerli deil", vbInformation TextBox1.SetFocus Exit Sub End If End If End Sub Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean) tarih = Calendar2.Value TextBox6 = DateSerial(Year(tarih), Month(tarih) + 6, Day(tarih)) End Sub Dim Date1 As Date, Date2 As Date Dim yil As Integer, ay As Integer, gun As Integer Date1 = DateSerial(Year(Text1), Month(Text1), Day(Text1)) Date2 = DateSerial(Year(Text2), Month(Text2), Day(Text2)) Date2 = DateAdd("d", 1, Date2) 'BENM EKLEDM SATIR yil = DateDiff("yyyy", Date1, Date2) ay = DateDiff("m", Date1, Date2) + (Day(Date1) > Day(Date2)) yil = yil + ((ay - yil * 12) < 0) ay = ay Mod 12 gun = DateDiff("d", Date1, Date2) - DateDiff("d", Date1, DateAdd("yyyy", yil, DateAdd("m", ay, Date1))) Text3 = yil & " yl, " & ay & " ay ve " & gun & " gn." Private Sub TextBox1_Change() If Len(TextBox1.Text) < 10 Then TextBox1 = Replace(TextBox1, " ", "") Else TextBox1.Text = Format(TextBox1, "0(###) ### ## ##") End If End Sub Private Sub TextBox1_Change() If Len(TextBox1.Text) >= 16 Then TextBox1 = Left(TextBox1, 16) If Len(TextBox1.Text) < 10 Then TextBox1 = Replace(TextBox1, " ", "") Else TextBox1.Text = Format(TextBox1, "0(###) ### ## ##") End If End Sub Private Sub TextBox1_Change() If Len(TextBox1.Text) >= 15 Then TextBox1 = Left(TextBox1, 15) If Len(TextBox1.Text) < 10 Then TextBox1 = Replace(TextBox1, " ", "") Else TextBox1.Text = Format(TextBox1, "(###) ### ## ##") End If End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "(###)"".""###"".""##"".""##") End Sub Private Sub TextBox3_Enter() TextBox3 = CInt(TextBox1) + CInt(TextBox2) End Sub veya Private Sub TextBox3_Enter() TextBox3 = Val(TextBox1) + Val(TextBox2) End Sub Private Sub CommandButton1_Click() TextBox1.MaxLength = 7 End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "###,###.00") End Sub
Private Sub CommandButton1_Click() Dim i As Byte If Len(TextBox1) > 0 Then For i = 1 To Worksheets.Count Call Myxxrt(Worksheets(i).Name) Next End If End Sub Private Function Myxxrt(ShName As String) Dim MyRng As Range On Error Resume Next Set MyRng = Range(Sheets(ShName).Cells.Find(TextBox1, LookAt:=xlWhole).Address) MsgBox "Aranlan deer " & ShName & " sayfasnda " & MyRng.Address(False, False) & " hcresinde bulundu !" Set MyRng = Nothing End Function Public Function AutoType(c As Control, KeyAscii As Integer) As Integer AutoType = KeyAscii If KeyAscii > 95 And KeyAscii < 123 Then If c.SelStart = 0 Then AutoType = AutoType - 32 ElseIf Mid$(c.Text, c.SelStart, 1) < "!" Then AutoType = AutoType - 32 End If End If End Function Private Sub Text1_KeyPress(KeyAscii As Integer) KeyAscii = AutoType(Screen.ActiveControl, KeyAscii) End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, ("##,###.## Ytl")) End Sub Hibir deiiklik yapmadan gstermesi lazm mesela A1 hcrenizde gzkecekse bu veri (A1 hcreniz genel olsun) aadaki gibi yazabilirsiniz Private Sub TextBox6_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If TextBox6 Like "#" Then TextBox6 = TextBox6 & "/" Range("a1") = TextBox6 End Sub On Error GoTo ErrHand: With TextBox1 If KeyCode = vbKeyLeft Or KeyCode = vbKeyBack Then KeyCode = vbKeySelect .SelStart = .SelStart - 1 .SelLength = 1 ElseIf KeyCode = vbKeyRight Then KeyCode = vbKeySelect .SelStart = .SelStart + 1 .SelLength = 1 ElseIf KeyCode = vbKeyDelete Then KeyCode = vbKeySelect If .SelText = "." Then .SelText = "." Else .SelText = "#" End If .SelStart = .SelStart - 1 .SelLength = 1 ElseIf KeyCode = vbKeyHome Then KeyCode = vbKeySelect .SelStart = 0 .SelLength = 1 ElseIf KeyCode = vbKeyEnd Then KeyCode = vbKeySelect .SelStart = Len(TextBox1) - 1 .SelLength = 1 End If End With Exit Sub ErrHand: KeyCode = vbKeySelect TextBox1.SelStart = 0 TextBox1.SelLength = 1 End Sub
UserFormda TextBoxlar ayorsun.Diyelimki 5 tane.TextBox1,2....5.UserFormun Initialize ksmna Kod: Private Sub UserForm_Initialize() TextBox1.Text = Range("d5").Text TextBox2.Text = Range("d6").Text TextBox3.Text = Range("d7").Text TextBox4.Text = Range("d8").Text TextBox5.Text = Range("d9").Text End Sub
MsgBox TextBox1.Text & " SML AHISIN KAYDI GNCELLENMTR.", vbInformation + vbOKOnly, "KAYIT GNCELLEND" Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If IsNumeric(TextBox1) Then MsgBox "KAYDETMEKTE OLDUUNUZ KART BLM KARTIDIR. PERSONEL N BU KART KODUNUN ALTINDA PERSONEL K End Sub Tools>References blmnden microsoft speech object library'i ekleyin 1 adet UserForm oluturun 1 adet TextBox 1 adet CommanButton Dim konus As New SpeechLib.SpVoice Private Sub UserForm_Activate() TextBox1.Text = "buraya istediini yaz" End Sub Private Sub CommandButton1_Click() konus.Speak TextBox1.Text End Sub TextBox1.SetFocus Sub timerMsg() Dim alertTime MsgBox "The alarm will go off in 3 seconds!" alertTime = Now + TimeValue("00:00:03") Application.OnTime alertTime, "msg" End Sub Sub msg() MsgBox "Three Seconds is up!" End Sub Sub Test() MsgBox "A1'e bir deer girmek iin 5 saniyeniz var." Test2 End Sub Sub Test2() Static hr As Date If hr <> Now - TimeValue("00:00:05") Then hr = Now Application.OnTime Now + TimeValue("00:00:05"), "Test2" Else If IsEmpty(Range("A1")) Then MsgBox "Boom" Else MsgBox "Uuf" End If End If End Sub Kod: Private Sub CommandButton1_Click() Unload Me End Sub Private Sub TextBox1_Change() On Error Resume Next TextBox1 = Format(TextBox1.Value, "#,##0") TextBox2.Value = Format(TextBox1.Value / 1000000, "#,##0.00") End Sub
Denetim Ara Kutusu (Control Toolbox) Ara ubuundan ToggleButton If ToggleButton1.Value = True Then ToggleButton1.Caption = "SL" Range("A3") = Range("A1") + Range("A2") Else ToggleButton1.Caption = "TOPLA" Range("A3").ClearContents End If End Sub Private Sub CommandButton1_Click() For i = 1 To 5 Toolbar1.Buttons.Add.Caption = i For x = 1 To 5 Toolbar1.Buttons(i).ButtonMenus.Add.Text = x Toolbar1.Buttons(i).Style = tbrDropdown Next x Next i End Sub Private Sub CommandButton1_Click() For i = 1 To 5 Toolbar1.Buttons.Add.Caption = i For x = 1 To 5 Toolbar1.Buttons(i).ButtonMenus.Add.Text = x Toolbar1.Buttons(i).Style = tbrDropdown Next x Next i End Sub Option Explicit Sub AutoSum1() CommandBars.FindControl(ID:=226).Execute Application.SendKeys "~" End Sub Sub AutoSum2() With Application.CommandBars.FindControl(ID:=226) .Execute .Execute End With End Sub Bul = Evaluate("=SumProduct((B2:B65536 = ""A"") * (D2:D65536=""P""))") Sub Toplam_Alan_Gster() Dim ds, d, s Set ds = CreateObject("Scripting.FileSystemObject") Set d = ds.GetDrive(ds.GetDriveName("C:\")) s = UCase(d) & " Srcsnde Toplam Alan:" & Chr(13) _ + vbCrLf & FormatNumber(d.TotalSize) s = s & " Bytes" MsgBox s End Sub Sub Addieren() Dim rng As Range Set rng = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) rng.Formula = "=SUM(A1:A" & rng.Row - 1 & ")" End Sub Sub Toplama() Dim n As Integer Dim t As Integer For n = 1 To 5 t=t+n Next n MsgBox "Toplam sonucu : " & t End Sub
Private Sub
1. MySum = WorksheetFunction.Sum(Range("A1:A20")) MsgBox MySum 2. Range("a21") = WorksheetFunction.Sum(Range("a1:a20")) 3.. Range("A21").Formula = "=Sum(A1:A20)" 4. Range("A21").Formula = "=topla(A1:A20)+S(" & Chr(34) & "Bu forml makro ile yazlmtr" & Chr(34) & ")" Range("C1") = (Range("A1") + Range("A2")) / 2 Sub sfrgizle() For Each rngRow In ActiveSheet.UsedRange.Rows If Application.Sum(rngRow) = 0 Then rngRow.EntireRow.Hidden = True End If Next rngRow End Sub Sub sfrgizle() For Each rngRow In ActiveSheet.UsedRange.Rows If Application.Sum(rngRow) = 0 Then rngRow.EntireRow.Hidden = True End If Next rngRow End Sub Private Sub TreeView1_Click() On Error GoTo son Dim bak As Range Dim a As String a = UserForm1.TreeView1.SelectedItem.Text If a <> "" Then Sayfa2.Select For Each bak In Sayfa2.Range("B2:B" & WorksheetFunction.CountA(Sayfa2.Range("B1:B65000"))) If StrConv(bak.Value, vbUpperCase) = StrConv(a, vbUpperCase) Then ' .ComboBox1.Value, vbUpperCase) Then bak.Select With UserForm1 .TextBox1.Value = bak.Offset(0, 0) 'ad soyad .TextBox4.Value = bak.Offset(0, 1) 'grevi .TextBox2.Value = bak.Offset(0, 3) 'tc kimlik no .TextBox3.Value = bak.Offset(0, 2) 'sicil no End With Exit Sub End If Next bak Else Exit Sub End If son: MsgBox "Aradnz isimde bir kayt bulunamad" End Sub Private Sub TreeView1_DblClick() ActiveCell = TreeView1.SelectedItem.Text End Sub Sub Wert_aus_inputBox_in_A1() Cells(1, 1) = InputBox("Bitte geben Sie den Wert ein, der in Zelle A1 geschrieben werden soll:") End Sub Sub Wert_aus_inputBox_in_A1() Cells(1, 1) = InputBox("Bitte geben Sie den Wert ein, der in Zelle A1 geschrieben werden soll:") End Sub Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) MsgBox "Baslan Tuun Ascii Deeri :" & KeyAscii End Sub Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) MsgBox KeyCode End Sub
Sub MsqXP() Application.DisplayCommentIndicator = xlCommentIndicatorOnly End Sub Sub AffXP() Application.DisplayCommentIndicator = xlCommentAndIndicator End Sub Sub LstBO() 'Worksheets("LstBO").Select For Each cbar In CommandBars x=x+1 [A1] = "Nom de la barre d'outils" [A1].Offset(x, 0) = cbar.Name [B1] = "Nom local de la barre d'outils" [B1].Offset(x, 0) = cbar.NameLocal [C1] = "Visible" [C1].Offset(x, 0) = cbar.Visible Next End Sub Sub ResetAllCheckBoxesInUserForm() Dim ctrl As Control For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "CheckBox" Then ctrl.Value = False End If Next ctrl End Sub Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" ( _ ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1 Sub FindAllFiles() Dim strPathToSearch As String strPathToSearch = "C:\"
ShellExecute _ 0, _ "find", _ strPathToSearch, _ vbNullString, _ vbNullString, _ SW_SHOWNORMAL End Sub Sub ShowFileOpenDialog() Dim i As Integer i = Workbooks.Count ' count of open workbooks Application.Dialogs(xlDialogOpen).Show ' displays the Open-dialog Select Case Workbooks.Count - i Case Is <= 0 ' no new workbooks opened MsgBox "You did not open any new workbooks!" Exit Sub Case 1 ' add your own code to work on the opened workbook MsgBox "You opened this workbook: " & ActiveWorkbook.Name Case Else ' add your own code to work on the opened workbooks MsgBox "You have opened " & Workbooks.Count - i & " workbooks." End Select End Sub Sub hepsini_sil() If MsgBox("Projedeki btn kodlar siliyor dikkat etmek lazm." & vbCrLf & "Btn kodlar silinsin mi?", vbYesNo, "AMAN DKKAT!!!") = vbNo Then Exit Sub For Each modul In ThisWorkbook.VBProject.VBComponents With modul.codemodule .deletelines 1, .countoflines End With Next End Sub
Sub Test() For i = UserForms.Count - 1 To 0 Step -1 Unload UserForms(i) Next End Sub Sub Test2() For Each MyForm In UserForms Unload MyForm Next MyForm End Sub Sub MasqueColonneLigne() On Error Resume Next Application.ScreenUpdating = False Numligne = InputBox(Prompt:="Taper les numros de lignes. ( Ex. 8:12 - Maxi = 65536)") NumColonne = InputBox(Prompt:="Taper les numros de colonnes. ( Ex. J:D - Maxi = IV )") Rows(Numligne).Select Selection.EntireRow.Hidden = True Columns(NumColonne).Select Selection.EntireColumn.Hidden = True End Sub Sub Un_Hide_All() Dim sh As Worksheet For Each sh In Worksheets sh.Visible = True Next End Sub Sub UnhideAllSheets() Dim wsSheet As Worksheet For Each wsSheet In ActiveWorkbook.Worksheets wsSheet.Visible = xlSheetVisible Next wsSheet End Sub Sub UnhideSomeSheets() Dim sSheetName As String Dim sMessage As String Dim Msgres As VbMsgBoxResult For Each wsSheet In ActiveWorkbook.Worksheets If wsSheet.Visible = xlSheetHidden Then sSheetName = wsSheet.Name sMessage = "Unhide the following sheet?" _ & vbNewLine & sSheetName Msgres = MsgBox(sMessage, vbYesNo) If Msgres = vbYes Then wsSheet.Visible = xlSheetVisible End If Next wsSheet End Sub Sub InGross() For Each c In Selection.Cells c.Value = UCase$(c.Value) Next c End Sub Sub UpperCase() Dim cell As Range For Each cell In Selection.Cells If cell.HasFormula = False Then cell = UCase(cell) End If Next End Sub Sub InKlein() For Each c In Selection.Cells c.Value = LCase$(c.Value) Next c End Sub
Sub ProtectAllSheets() Dim ws As Worksheet Dim sOrigSheet As String Dim sOrigCell As String Dim J As Integer Dim sPWord As String Application.ScreenUpdating = False sOrigSheet = ActiveSheet.Name sOrigCell = ActiveCell.Address sPWord = InputBox("What password?", "Protect All") If sPWord > "" Then For Each ws In Worksheets ws.Select ws.Protect Password:=sPWord Next ws End If Application.GoTo Reference:=Worksheets("" & sOrigSheet & "").Range("" & sOrigCell & "") Application.ScreenUpdating = True End Sub Sub ChartUnProtect() Dim wks As Worksheet Dim cht As Chart Dim chtObj As ChartObject Dim PW As String PW = "mypass" 'Unprotect all Chart sheets For Each cht In ActiveWorkbook.Charts Sheets(cht.Name).Unprotect password:=PW Next 'Unlock all Chart objects on each worksheet For Each wks In ActiveWorkbook.Worksheets wks.Unprotect password:=PW For Each chtObj In wks.ChartObjects wks.DrawingObjects(chtObj.Name).Locked = False Next wks.Protect password:=PW Next End Sub Sub ProtectAllSheets() Dim ws As Worksheet Dim sOrigSheet As String Dim sOrigCell As String Dim J As Integer Application.ScreenUpdating = False sOrigSheet = ActiveSheet.Name sOrigCell = ActiveCell.Address For Each ws In Worksheets ws.Select ws.Protect Password:="Password" Next ws Application.GoTo Reference:=Worksheets("" & sOrigSheet & "").Range("" & sOrigCell & "") Application.ScreenUpdating = True End Sub Thisworkbook'a Option Explicit Sub Zeilen_pro_Spalte_zaehlen() Dim x As Integer, y As Long For x = 1 To ActiveSheet.UsedRange.Columns.Count y = Cells(65536, x).End(xlUp).Row MsgBox "Stun " & x & ", Satr " & y & " dolu hcredir" Next End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Static OldIndex As Integer Static OldCell As Range On Error Resume Next OldCell.Interior.ColorIndex = OldIndex If Not OldCell Is Nothing Then OldIndex = Target.Interior.ColorIndex End If Target.Interior.ColorIndex = 6 Set OldCell = Target End Sub Sub Klasr_Kopyala() Dim ds Set ds = CreateObject("Scripting.FileSystemObject") ds.CopyFolder "D:\Excelrnekleri", "C:\SXS" End Sub Dim sd As VBComponent Dim kodlar As CodeModule Dim Dosya Dim wb As Workbook i=2 On Error Resume Next Application.DisplayAlerts = False Set ObjFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Klasr Seiniz...", &H4, "") pth = ObjFolder.items.Item.Path ChDir (pth) Dosya = Dir("*.xls") While Dosya <> "" Set wb = Workbooks.Open(pth & "\" & Dosya) Windows(wb.Name).Visible = False For Each sd In wb.VBProject.VBComponents Set kodlar = sd.CodeModule basla = kodlar.CountOfDeclarationLines + 1 If Err.Number = 0 Then Do Until basla >= kodlar.CountOfLines If Err.Number <> 0 Then Err.Clear: Exit Do ThisWorkbook.Sheets(1).Cells(i, "A") = pth & "\" & Dosya ThisWorkbook.Sheets(1).Cells(i, "B") = kodlar.ProcOfLine(basla, vbext_pk_Proc) ThisWorkbook.Sheets(1).Cells(i, "C") = sd.Name basla = basla + kodlar.ProcCountLines(kodlar.ProcOfLine(basla, vbext_pk_Proc), vbext_pk_Proc) i=i+1 Loop Else Err.Clear End If Next Dosya = Dir wb.Close False Wend End Sub
Referanslardan Microsoft visual Basic for Applications Extensibility x.x sein Aktif kitaptaki makrolar, A stununa makronun adn, B stununu da yerini belirtecek ekilde listeler. Sub sirala() Dim sd As VBComponent Dim kodlar As CodeModule i=1 For Each sd In ActiveWorkbook.VBProject.VBComponents Set kodlar = sd.CodeModule basla = kodlar.CountOfDeclarationLines + 1 Do Until basla >= kodlar.CountOfLines Cells(i, "A") = kodlar.ProcOfLine(basla, vbext_pk_Proc) Cells(i, "B") = sd.Name basla = basla + kodlar.ProcCountLines(kodlar.ProcOfLine(basla, vbext_pk_Proc), vbext_pk_Proc) i=i+1 Loop Next End Sub Sub ResetAllOptionButtonsInUserForm() Dim ctrl As Control For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "OptionButton" Then ctrl.Value = False End If Next ctrl End Sub Sub Ekle_Nesne_TumSil() ActiveSheet.DrawingObjects.Delete End Sub Dim Picture As Object Dim Bak As String Dim Uzunluk As Byte Bak = InputBox("Hangi Trdeki Resim Silinecek?", "S. UZUNKPR", "WordArt") Uzunluk = Len(Bak) For Each Picture In ActiveSheet.shapes If Mid(Picture.Name, 1, Uzunluk) = Bak Then Picture.Delete End If Next Picture End Sub Sub sat_sut_giz() If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub If Rows(Rows.Count).Hidden = False And _ Columns(Columns.Count).Hidden = False Then Columns.Hidden = True Rows.Hidden = True With ActiveSheet.UsedRange .Columns.Hidden = False .Rows.Hidden = False End With Else Columns.Hidden = False Rows.Hidden = False End If End Sub Sub sat_sut_gos() If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub If Rows(Rows.Count).Hidden = True And _ Columns(Columns.Count).Hidden = True Then Columns.Hidden = False Rows.Hidden = False With ActiveSheet.UsedRange .Columns.Hidden = True .Rows.Hidden = True End With Else Columns.Hidden = True Rows.Hidden = True End If End Sub
Sub Blenden() If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub If Rows(Rows.Count).Hidden = False And _ Columns(Columns.Count).Hidden = False Then Columns.Hidden = True Rows.Hidden = True With ActiveSheet.UsedRange .Columns.Hidden = False .Rows.Hidden = False End With Else Columns.Hidden = False Rows.Hidden = False End If End Sub Thisworkbooka Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Static OldIndex As Integer Static OldCell As Range On Error Resume Next OldCell.Interior.ColorIndex = OldIndex If Not OldCell Is Nothing Then OldIndex = Target.Interior.ColorIndex End If Target.Interior.ColorIndex = 6 Set OldCell = Target End Sub Sub KorumaKoy() Dim ws As Worksheet For Each ws In Worksheets ws.Protect ("a") Next End Sub Sub KorumaKoy() Dim ws As Worksheet For Each ws In Worksheets ws.Protect ("a") Next End Sub Sub Reset_Values_All_WSheets() Dim wSht As Worksheet Dim myRng As Range Dim allwShts As Sheets Dim cel As Range Set allwShts = Worksheets For Each wSht In allwShts Set myRng = wSht.Range("A1:A5, B6:B10, C1:C5, D4:D10") For Each cel In myRng If Not cel.HasFormula And cel.Value <> 0 Then cel.Value = 0 End If Next cel Next wSht End Sub For Each sht In Worksheets sht.DrawingObjects.Delete Next Thisworkbook a Private Sub Workbook_SheetActivate(ByVal Sh As Object) ActiveWindow.Zoom = 80 End Sub
Sub Sayfagorunumu() Dim i As Integer Dim z As Variant Dim Sayfam As String 'kullancya sor z = InputBox("Oran gir", "Bytme-kltme " & _ "alma kitabndaki tm sayfalar", 100) If Not IsNumeric(z) Then Exit Sub 'girilen deer nmerik deilse dur If z < 10 Or z > 400 Then 'girilen rakam 10 ile 400 arasnda olmal MsgBox "Girdiiniz deer 10 ile 400 arasnda olmal " & vbCrLf & _ "Tekrar deneyin", vbExclamation Exit Sub End If Sayfam = ActiveSheet.Name Application.ScreenUpdating = False For i = 1 To ActiveWorkbook.Sheets.Count 'her sayfay istenen bykle getirir Sheets(i).Activate ActiveWindow.Zoom = z Next i Sheets(Sayfam).Activate Application.ScreenUpdating = True End Sub Sub KorumaKaldir() Dim ws As Worksheet For Each ws In Worksheets ws.Unprotect ("a") Next End Sub Sub a() On Error Resume Next Application.DisplayAlerts = False For Each Sh In Sheets Sh.Visible = False Next Sh End Sub Public bIsClosing As Boolean Dim wsSheet As Worksheet Sub HideAll() Application.ScreenUpdating = False For Each wsSheet In ThisWorkbook.Worksheets If wsSheet.CodeName = "Sheet1" Then wsSheet.Visible = xlSheetVisible Else wsSheet.Visible = xlSheetVeryHidden End If Next wsSheet Application.ScreenUpdating = True End Sub Sub ShowAll() bIsClosing = False For Each wsSheet In ThisWorkbook.Worksheets If wsSheet.CodeName <> "Sheet1" Then wsSheet.Visible = xlSheetVisible End If Next wsSheet Sheet1.Visible = xlSheetVeryHidden End Sub
Sub protectAll() Dim myCount Dim i myCount = Application.Sheets.Count Sheets(1).Select For i = 1 To myCount ActiveSheet.Protect If i = myCount Then End End If ActiveSheet.Next.Select Next i End Sub Sub SelectSheets1() Dim mySheet As Object For Each mySheet In Sheets With mySheet If .Visible = True Then .Select Replace:=False End With Next mySheet End Sub Sub SelectSheets() Dim myArray() As Variant Dim i As Integer For i = 1 To Sheets.Count ReDim Preserve myArray(i - 1) myArray(i - 1) = i Next i Sheets(myArray).Select End Sub Sub SelectSheets() Dim myArray() As Variant Dim i As Integer Dim j As Integer j=0 For i = 1 To Sheets.Count If Sheets(i).Visible = True Then ReDim Preserve myArray(j) myArray(j) = i j=j+1 End If Next i Sheets(myArray).Select End Sub Sub SayfaSirala() Dim i As Integer, j As Integer Dim KacSayfa As Integer, KucukMu As Integer Dim AktifSayfa As String Application.ScreenUpdating = False KacSayfa = Sheets.Count 'sayfalar sayyor AktifSayfa = ActiveSheet.Name 'activesheet'in ismini hatrlamak iin 'sralama For i = 1 To KacSayfa - 1 KucukMu = i For j = i + 1 To KacSayfa If LCase(Sheets(j).Name) < LCase(Sheets(KucukMu).Name) Then KucukMu = j Next j If KucukMu <> i Then Sheets(KucukMu).Move Before:=Sheets(i) Next i Sheets(AktifSayfa).Activate 'ilk activesheet'e dnyor Application.ScreenUpdating = True End Sub Sub Addieren() Dim Summen! Summen = 0 For i = 1 To Worksheets.Count Summen = Summen + Worksheets(i).[A1] Next MsgBox Summen End Sub
Sub Show_all_Drives() Dim myFSO As Object, myDrv As Object, drvCount, drvStr As String, vName As String, drvTyp As String Set myFSO = CreateObject("Scripting.FileSystemObject") Set drvCount = myFSO.Drives On Error Resume Next drvStr = "" For Each myDrv In drvCount Select Case myDrv.DriveType Case 0: drvTyp = "Unknown" Case 1: drvTyp = "Removable" Case 2: drvTyp = "Fixed" Case 3: drvTyp = "Network" Case 4: drvTyp = "CD-ROM" Case 5: drvTyp = "RAM Disk" End Select drvStr = drvStr & drvTyp & ": " & myDrv.DriveLetter & " - " '3 = Netzlaufwerk If myDrv.DriveType = 3 Then vName = myDrv.ShareName Else vName = myDrv.VolumeName End If drvStr = drvStr & vName & vbCrLf Next MsgBox drvStr End Sub Sub UnProtectAllSheets() Dim ws As Worksheet Dim sOrigSheet As String Dim sOrigCell As String Dim J As Integer Application.ScreenUpdating = False sOrigSheet = ActiveSheet.Name sOrigCell = ActiveCell.Address For Each ws In Worksheets ws.Select ws.Unprotect Password:="Password" Next ws Application.GoTo Reference:=Worksheets("" & sOrigSheet & "").Range("" & sOrigCell & "") Application.ScreenUpdating = True End Sub Private Sub CommandButton1_Click() Dim ctrl As Control For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "TextBox" Then ctrl.Text = "" End If Next ctrl
End Sub Trke Office programndaki formllerin orijinal halini, yani ngilizce yazln bir hcreye yazdrmak iin aadaki fonksiyonu kullanlabilir. Function Donustur(hucre As Range) As String Application.Volatile If hucre.HasArray Then Donustur = " {" & hucre.FormulaArray & "}" Else Donustur = hucre.FormulaArray End If End Function Sub OuvreTXT() lanceur = Shell("C:\windows\notepad.exe c:\ali.txt", 1) End Sub Burada ise bir TXT dosyas oluturuyoruz.Dosya isminden sonra False yazarsak eski bilgilerin stne yazlmaz ve File Already Exists yani Dosya Zaten V kinci ksm False olursa dosya ASCII,True olursa UNICODE olur. Sub Text_Dosyas_Olutur() Dim ds, a Set ds = CreateObject("Scripting.FileSystemObject") Set a = ds.CreateTextFile("C:\SXS\Deneme.txt", True, False) 'lk true Overwrite,kinci False ASCII true olursa Unicode End Sub
Sub a1txt() Var = [A1] FichierTXT = "C:\a\a.txt" ' modifier If Len(Dir(FichierTXT)) > 1 Then Kill FichierTXT Open FichierTXT For Output As 1 Print #1, Var Close End Sub Sub txt_import() pir = Application.GetOpenFilename("Txt-Dosyas , *.TXT") Workbooks.OpenText Filename:=pir, Origin:=xlWindows _ , StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon _ :=False, Comma:=False, Space:=False, Other:=False, FieldInfo _ :=Array(1, 1) End Sub
Dim FileName As String Dim FileNum As Integer Dim ResultStr As String Dim wsSheet As Worksheet Dim strValues() As String Dim lngRows As Long Dim lngRow As Long Dim intSheet As Integer Dim intCounter As Integer FileName = Application.GetOpenFilename("Textdateien " & _ "(*.txt; *.csv),*.txt; *.csv") If FileName = "" Or FileName = "Falsch" Then Exit Sub FileNum = FreeFile() Open FileName For Input As #FileNum Application.ScreenUpdating = False Workbooks.Add template:=xlWorksheet lngRows = ActiveSheet.Rows.Count lngRow = 1 intSheet = 1 ReDim strValues(lngRows, 1) Application.StatusBar = "Blatt " & intSheet & " wird eingelesen" Do While Seek(FileNum) <= LOF(FileNum) Line Input #FileNum, ResultStr If Left(ResultStr, 1) = "=" Then strValues(lngRow, 1) = "'" & ResultStr Else strValues(lngRow, 1) = ResultStr End If If lngRow < lngRows Then lngRow = lngRow + 1 Else ActiveSheet.Range("A1:A" & lngRows) = strValues ActiveWorkbook.Worksheets.Add after:=Worksheets(Worksheets.Count) ReDim strValues(lngRows, 1) lngRow = 1 intSheet = intSheet + 1 Application.StatusBar = "Blatt " & intSheet & " wird eingelesen" End If Loop Close ActiveSheet.Range("A1:A" & lngRows) = strValues If MsgBox("Sollen die eingelesenen Daten auf Spalten verteilt werden?", _ vbYesNo, "Text in Spalten") = vbNo Then Application.ScreenUpdating = True Application.StatusBar = "Fertig" Exit Sub End If intSheet = 0 For Each wsSheet In ActiveWorkbook.Worksheets intSheet = intSheet + 1 Application.StatusBar = "Daten von Blatt " & intSheet _ & " werden bearbeitet" With wsSheet .Range("A:A").TextToColumns Destination:=.Range("A1"), _ DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, _ ConsecutiveDelimiter:=False, _ Tab:=False, _ Semicolon:=True, _ Comma:=False, _ Space:=False, _ Other:=False End With Next wsSheet Application.ScreenUpdating = True Application.StatusBar = "Fertig" End Sub
Sub DelFile() If Len(Dir("c:\metin.txt")) > 0 Then Kill "c:\metin.txt" MsgBox "Dosya silinmitir." Else MsgBox "byle bir dosya yok" End If End Sub rnein C altndaki bir txt dosyasn amak iin; visual basic kodu: Shell "notepad.exe " & "c:\deneme.txt"
Kendi klasrndeki bir txt dosyasn amak ii; visual basic kodu: Shell "notepad.exe " & ActiveWorkbook.Path & "\deneme.txt" art setiiniz comboboxa aadaki kodu kopyalayn. visual basic kodu: Private Sub CmbSart_Change() For a = 2 To [a65536].End(3).Row If CmbUrun = Cells(a, "a") And CmbSart = Cells(a, "b") Then TxtFiyat = Cells(a, "c") Exit Sub End If Next End Sub
rn comboboxuna da aadaki kodu kopyalayn. visual basic kodu: Private Sub CmbUrun_Click() CmbSart_Change End Sub Sub UndoTest() Application.OnUndo "Entry delete", ThisWorkbook.Name & "!UndoOn" End Sub Sub UndoOn() Range("A1:A10").ClearContents End Sub Sub Enter() Dim intCounter As Integer For intCounter = 1 To 10 Cells(intCounter, 1).Value = intCounter Next intCounter Call UndoTest End Sub
'// This Sub creates a registry key for '// HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Excel\Options '// Creates Ref to Windows Script Host Object Model '// C:\WINDOWS\SYSTEM\WSHOM.OCX Const strKey As String = "HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Excel\Options\UndoHistory" Const strType As String = "REG_DWORD" Const dVal = 16 ' Change this NB: > 100 Not recomended by Microsoft Sub ChangeXlUndoHistory() Dim objWSH As Object Set objWSH = CreateObject("WScript.Shell") objWSH.RegWrite strKey, dVal, strType Set objWSH = Nothing MsgBox ReadRegEdit(strKey) End Sub '// To Read a Key Function ReadRegEdit(key) Dim Ws, Tmp Set Ws = CreateObject("WScript.Shell") Tmp = Ws.RegRead(key) If Tmp = "" Then ReadRegEdit = "" Else ReadRegEdit = Tmp End If Set Ws = Nothing End Function
Private Sub UserForm_Initialize() UserForm1.Caption = "pir" End Sub Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function EnableWindow Lib "User32" _ (ByVal hWnd As Long, ByVal bEnable As Long) As Long Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Sub UserForm_Activate() EnableWindow FindWindowA("XLMAIN", Application.Caption), 1 End Sub Private Sub UserForm_Initialize() Dim hWnd As Long hWnd = FindWindowA(vbNullString, Me.Caption) SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) Or &H20000 End Sub
Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub UserForm_Initialize() Dim hwnd As Long hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _ "X", "D") & "Frame", Me.Caption) SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF End Sub Private Sub UserForm_Activate() ' Rcupration de l'heure d'affichage de la BdD TimeDebut = Timer ' Donne la main excel pour facilit l'affichage de la BdD DoEvents ' Boucle tant que 2 secondes ne se sont pas coul While Timer < TimeDebut + 10 Wend ' Fermeture de la BdD Unload Me End Sub Private Sub UserForm_Activate() Application.Wait Now + TimeSerial(0, 0, 3) Unload Me End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then MsgBox "arpdan kapatmak yasaktr!" Cancel = True End If End Sub Private Sub UserForm_Activate() Application.Wait Now + TimeValue("00:00:02") Call kaydet Unload Me End Sub Sub kaydet() Sheets("sayfa1").Select End Sub Private Sub UserForm_activate() Dim T Me.Repaint T = Timer + 10 Do While Timer < T Loop Me.Hide End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = 0 Then Cancel = 1 MsgBox "Ltfen butonu kullannz", _ vbOKOnly + vbInformation, "k ptali" End If End Sub Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" (ByVal ClassName As String, _ ByVal WindowName As String) As Long Private Sub UserForm_Click() MsgBox FindWindow("ThunderDFrame", "UserForm1") End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Application.Quit End Sub Private Sub UserForm_Activate() UserForm1.Top = True End Sub Private Sub UserForm_Initialize() With UserForm1 .Height = Application.Height .Width = Application.Width End With End Sub MsgBox UserForm1.Controls.Count TextBox1.SetFocus OLDH = UserForm1.Height OLDW = UserForm1.Width Me.Caption = "SAYMANLIK LEM F K A P A N I Y O R..." PauseTime = 1 Start = Timer Do While Timer < Start + PauseTime DoEvents Loop Dim i As Integer For i = 1 To 220 With UserForm1 .Top = UserForm1.Top + 0.7 .Left = UserForm1.Left + 0.51 .Height = UserForm1.Height - 1.3 .Width = UserForm1.Width - 1 End With UserForm1.Repaint Next i With UserForm1 .Height = OLDH .Width = OLDW .StartUpPosition = 2 End With Unload Me Dim rectangle As RECT fen = GetActiveWindow() Call GetWindowRect(fen, rectangle) For num = 1 To 1750 Call MoveWindow(fen, 250 + 200 * Sin(num * 16.28 / 500), 200 + 200 * Cos(num * 2.28 / 500), 500, 500, True) Next Call MoveWindow(fen, rectangle.Left, rectangle.Top, rectangle.Right - rectangle.Left, rectangle.Bottom - rectangle.Top, True) Unload UserForm1 Application.Quit ActiveWorkbook.Close False End Sub
Private Declare Sub Sleep Lib "Kernel32" (ByVal Zeit As Long) Dim pir As Boolean Private Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, By Private Function CallWebSite(ByVal URL As String) As Long CallWebSite = ShellExecute(0&, vbNullString, URL, vbNullString, vbNullString, vbMaximizedFocus) End Function Private Sub CommandButton1_Click() Unload Me End Sub Private Sub Label1_Click() CallWebSite (Label1.Caption) End Sub Private Sub UserForm_QueryClose(Cancel As Integer, _ CloseMode As Integer) If CloseMode = vbFormControlMenu Then MsgBox "Bu ekilde kmak yasak !", 64, "Information" Cancel = True End If End Sub Private Sub UserForm_Activate() Me.Width = 40 Me.Height = 180 While Me.Width < 255 Me.Width = Me.Width + 1 Me.Height = Me.Height + 1 Me.StartUpPosition = 1 DoEvents Sleep 5 If pir = True Then Exit Sub Wend End Sub Private Sub UserForm_Click() Me.Width = 120 Me.Height = 180 pir = True End Sub Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long Private Sub UserForm_Activate() Dim hWndForm As Long, frmStyle As Long hWndForm = FindWindow(vbNullString, Me.Caption) frmStyle = GetWindowLong(hWndForm, (-16)) frmStyle = frmStyle Or &H80000 Or &H20000 Or &H10000 SetWindowLong hWndForm, (-16), frmStyle ShowWindow hWndForm, 5 DrawMenuBar hWndForm End Sub 'Ayr bir kod ise Userformun alnda tam ekran olarak gelmesi. Private Sub UserForm_Initialize() With Application Me.Top = .Top Me.Left = .Left Me.Height = .Height Me.Width = .Width End With End Sub
Private Sub UserForm_Initialize() With Application .WindowState = xlMaximized Zoom = Int(.Width / Me.Width * 100) Width = .Width Height = .Height End With End Sub Private Sub UserForm_Activate() UserForm1.Left = 600 UserForm1.Top = 425 End Sub Private Declare Function GetSystemMetrics Lib _ "user32" (ByVal nIndex As Long) As Long Private Const SM_CYSCREEN As Long = 1 Private Const SM_CXSCREEN As Long = 0 'Position Private Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, ByVal _ lpWindowName As String) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd _ As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _ ByVal nHeight As Long, ByVal bRepaint As Long) As Long Private Sub UserForm_Activate() BildschirmBreite = GetSystemMetrics(SM_CXSCREEN) BildschirmHhe = GetSystemMetrics(SM_CYSCREEN) UserformBreite = 350 UserformHhe = 450 wHandle = FindWindow(vbNullString, Me.Caption) MoveWindow wHandle, BildschirmBreite - UserformBreite, _ 0, UserformBreite, UserformHhe, 1 End Sub Private Sub CommandButton1_Click() Application.ScreenUpdating = False dolusay = WorksheetFunction.CountA(Worksheets("1").[a1:a65000]) + 1 Worksheets("1").Cells(dolusay, "a").Value = dolusay - 1 dolusay = WorksheetFunction.CountA(Worksheets("1").[a1:a65000]) Worksheets("1").Cells(dolusay, "b").Value = cbAd.Value dolusay = WorksheetFunction.CountA(Worksheets("1").[a1:a65000]) Worksheets("1").Cells(dolusay, "c").Value = TextBox1.Value End Sub Sheets("Formunuzun Bulunmasn istediiz sayfa").Select Application.ScreenUpdating = True End Sub Private Sub UserForm_Initialize() With Application Me.Top = .Top Me.Left = .Left Me.Height = .Height Me.Width = .Width End With End Sub Private Declare Function GetSystemMetrics Lib _ "user32" (ByVal nIndex As Long) As Long Private Const SM_CYSCREEN As Long = 1 Private Const SM_CXSCREEN As Long = 0 'Position Private Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, ByVal _ lpWindowName As String) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd _ As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _ ByVal nHeight As Long, ByVal bRepaint As Long) As Long Private Sub UserForm_Activate() BildschirmBreite = GetSystemMetrics(SM_CXSCREEN) BildschirmHhe = GetSystemMetrics(SM_CYSCREEN) wHandle = FindWindow(vbNullString, Me.Caption) MoveWindow wHandle, 0, 0, BildschirmBreite, BildschirmHhe, 1 End Sub
Bir adet Userform oluturun ve caption a uzun bireyler yazn. Tabiiki birde CommandButton koyacaksnz... Sub HarfHarf (ref As UserForm1) baslik = ref.Caption ref.Caption = "" For i = 0 To Len(baslik) If i = 0 Then ref.Caption = "" current = Timer Do While Timer - current < 0.1 DoEvents Loop GoTo Son Else End If ref.Caption = Left(baslik, i) current = Timer Do While Timer - current < 0.01 DoEvents Loop Son: Next i End Sub Private Sub CommandButton1_Click() HarfHarf Me End Sub Bir adet Userform oluturun ve caption a uzun bireyler yazn. Bir de CommandButton Sub HarfHarf (ref As UserForm1) baslik = ref.Caption ref.Caption = "" For i = 0 To Len(baslik) If i = 0 Then ref.Caption = "" current = Timer Do While Timer - current < 0.1 DoEvents Loop GoTo Son Else End If ref.Caption = Left(baslik, i) current = Timer Do While Timer - current < 0.01 DoEvents Loop Son: Next i End Sub Private Sub CommandButton1_Click() HarfHarf Me End Sub Private Sub CommandButton7_Click() Selection.AutoFilter Columns("B:B").Select Selection.AutoFilter Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("E6").Select End Sub
Userforma aadaki kodu; Private Sub UserForm_Initialize() For a = 2 To [c65536].End(3).Row If WorksheetFunction.CountIf(Range("c2:c" & a), Cells(a, "c")) = 1 Then ComboBox1.AddItem Cells(a, "c") Next ListBox1.ColumnCount = 9 ListBox1.ColumnWidths = "50;50;50;50;50;50;50;50;50" End Sub comboboxada aadaki kodu kopyalayarak deneyin. visual basic kodu: Private Sub ComboBox1_Click() TextBox1 = WorksheetFunction.SumIf([c:c], ComboBox1, [d:d]) TextBox2 = WorksheetFunction.SumIf([c:c], ComboBox1, [g:g]) TextBox3 = WorksheetFunction.SumIf([c:c], ComboBox1, [i:i]) For sat = 2 To [c65536].End(3).Row If Cells(sat, "c") = ComboBox1 Then c=c+1 For sut = 1 To 9 ListBox1.AddItem ListBox1.List(c - 1, sut - 1) = Cells(sat, sut) Next End If Next End Sub Bu bir API'dir Private Declare Function GetWindowLongA Lib "User32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function FindWindowA Lib "User32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub UserForm_Initialize() Dim hwnd As Long hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", "X", "D") & "Frame", Me.Caption) SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF End Sub
WS_SYSMENU As Long = &H80000 WS_THICKFRAME As Long = &H40000 WS_MINIMIZEBOX As Long = &H20000 WS_MAXIMIZEBOX As Long = &H10000 WS_POPUP As Long = &H80000000 WS_VISIBLE As Long = &H10000000 WS_EX_DLGMODALFRAME As Long = &H1 WS_EX_APPWINDOW As Long = &H40000 WS_EX_TOOLWINDOW As Long = &H80
Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" ( _ ByVal ClassName As String, _ ByVal WindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" ( _ ByVal hWnd As Long, _ ByVal Index As Long) As Long Private Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" ( _ ByVal hWnd As Long, _ ByVal Index As Long, _ ByVal NewLong As Long) As Long Const GWL_STYLE = -16 Private Sub UserForm_Initialize() Dim hWnd As Long Dim Style As Long If Val(Application.Version) >= 9 Then hWnd = FindWindow("ThunderDFrame", Me.Caption) Else hWnd = FindWindow("ThunderXFrame", Me.Caption) End If Style = GetWindowLong(hWnd, GWL_STYLE) Style = (Style And Not WS_SYSMENU) SetWindowLong hWnd, GWL_STYLE, Style End Sub Sub Auto_Open () Userform1.Show End Sub Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function EnableWindow Lib "User32" _ (ByVal hWnd As Long, ByVal bEnable As Long) As Long Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Sub UserForm_Activate() EnableWindow FindWindowA("XLMAIN", Application.Caption), 1 End Sub Private Sub UserForm_Initialize() Dim hWnd As Long hWnd = FindWindowA(vbNullString, Me.Caption) SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) Or &H20000 End Sub
Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function EnableWindow Lib "User32" _ (ByVal hWnd As Long, ByVal bEnable As Long) As Long Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Sub UserForm_Activate() EnableWindow FindWindowA("XLMAIN", Application.Caption), 1 End Sub Private Sub UserForm_Initialize() Dim hWnd As Long hWnd = FindWindowA(vbNullString, Me.Caption) SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) Or &H20000 End Sub
Dim iChartType As Long Private Sub UserForm_Activate() 'Initialise the selections cb3D = True obColumn = True obBitmap = True End Sub Private Sub btnOK_Click() Unload Me End Sub Private Sub cb3D_Click() Select Case True Case obColumn obColumn_Click Case obLine obLine_Click Case obArea obArea_Click End Select End Sub Private Sub obColumn_Click() iChartType = IIf(cb3D, xl3DColumn, xlColumnClustered) UpdateChart End Sub Private Sub obLine_Click() iChartType = IIf(cb3D, xl3DLine, xlLine) UpdateChart End Sub Private Sub obArea_Click() iChartType = IIf(cb3D, xl3DArea, xlArea) UpdateChart End Sub Private Sub obBitmap_Click() UpdateChart End Sub Private Sub obMetafile_Click() UpdateChart End Sub Private Sub UpdateChart() Dim oCht As Chart, lPicType As Long 'Find the chart object on the sheet Set oCht = Sheet1.ChartObjects(1).Chart 'Recalculate the sheet to give us a new set of random points Sheet1.Calculate 'Do we want a metafile or a bitmap? 'If doing a 1 to 1 copy, xlBitmap will give a 'truer' rendition. 'If scaling the image, xlPicture will give better results lPicType = IIf(obMetafile, xlPicture, xlBitmap) 'Update the chart type and copy it to the clipboard, as seen on screen With oCht .ChartType = iChartType .CopyPicture xlScreen, lPicType, xlScreen End With 'Paste the picture from the clipboard into our image control Set imgChtPic.Picture = PastePicture(lPicType) End Sub Private Sub btnSave_Click() Dim vFile As Variant, sFilter As String, lPicType As Long, oPic As IPictureDisp
Dim iChartType As Long Private Sub UserForm_Activate() 'Initialise the selections cb3D = True obColumn = True obBitmap = True End Sub Private Sub btnOK_Click() Unload Me End Sub Private Sub cb3D_Click() Select Case True Case obColumn obColumn_Click Case obLine obLine_Click Case obArea obArea_Click End Select End Sub Private Sub obColumn_Click() iChartType = IIf(cb3D, xl3DColumn, xlColumnClustered) UpdateChart End Sub Private Sub obLine_Click() iChartType = IIf(cb3D, xl3DLine, xlLine) UpdateChart End Sub Private Sub obArea_Click() iChartType = IIf(cb3D, xl3DArea, xlArea) UpdateChart End Sub Private Sub obBitmap_Click() UpdateChart End Sub Private Sub obMetafile_Click() UpdateChart End Sub Private Sub UpdateChart() Dim oCht As Chart, lPicType As Long 'Find the chart object on the sheet Set oCht = Sheet1.ChartObjects(1).Chart 'Recalculate the sheet to give us a new set of random points Sheet1.Calculate 'Do we want a metafile or a bitmap? 'If doing a 1 to 1 copy, xlBitmap will give a 'truer' rendition. 'If scaling the image, xlPicture will give better results lPicType = IIf(obMetafile, xlPicture, xlBitmap) 'Update the chart type and copy it to the clipboard, as seen on screen With oCht .ChartType = iChartType .CopyPicture xlScreen, lPicType, xlScreen End With 'Paste the picture from the clipboard into our image control Set imgChtPic.Picture = PastePicture(lPicType) End Sub Private Sub btnSave_Click() Dim vFile As Variant, sFilter As String, lPicType As Long, oPic As IPictureDisp
Private Sub Worksheet_Activate() bitis = 65000 baslangic = Now() For n = 2 To bitis Cells(n, 1).Value = n Cells(1, 1).Value = "leminiz yaplyor. %" & Int(n * 100 / bitis) & " Tamamland !" Next Cells(1, 1).Value = "leminiz yapld. " & Int(((Now() - baslangic) * 24 * 60 * 60)) & " sn.de Tamamland !" End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then MsgBox "Diese UserForm kann nur ber den Button 'Beenden' geschlossen werden!", vbOKOnly, "Schliessen der UserForm erfolglos !!!" Cancel = True End If End Sub Private Sub UserForm_Initialize() TextBox1.Value = ActiveSheet.Name Label1.Caption = ActiveSheet.Name End Sub Dier nesneleride aynen uygulanabilir. Private Sub UserForm_Click() MsgBox ActiveSheet.Name End Sub Private Sub UserForm_Activate() Do Label1.Caption = Format(Now, "dd.mm.yyyy - hh:mm:ss") DoEvents Loop End Sub Private Sub UserForm_DeActivate() UserForm_Activate False End Sub Kod: Private Sub UserForm_Activate() Do Label1.Caption = Format(Now, "dd.mm.yyyy - hh:mm:ss") DoEvents Loop End Sub Private Sub UserForm_DeActivate() UserForm_Activate False End Sub Private Sub UserForm_Initialize() WebBrowser1.Navigate "C:\Documents and Settings\xp\Belgelerim\Resimlerim\Resimlerim\Hareketli_resimler\0kop1.gif" WebBrowser2.Navigate "http://www.excel.web.tr/images/smiles/icon_hihoho.gif" End Sub Private Sub TextBox7_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox7 = Format(TextBox7.Value, "#,##0.00") If IsNumeric(TextBox7) And IsNumeric(TextBox6) Then If TextBox11 <> "" Then TextBox8 = (CCur(TextBox7) - CCur(TextBox7) * CCur(TextBox11) / 100) * CCur(TextBox6) Exit Sub End If TextBox8 = CCur(TextBox7) * CCur(TextBox6) End If End Sub Private Sub CommandButton1_Click() Application.ScreenUpdating = False Unload Me ThisWorkbook.Save ThisWorkbook.Close End Sub
Dim T As New cTimer Public gblnStop As Boolean Private Sub cmdBegin_Click() gblnStop = False T.StartTimer Do DoEvents Label1.Caption = Format(T.CheckTimer / 1000, "0.###") If gblnStop Then Label1.Caption = Format(T.StopTimer / 1000, "0.###"): Exit Do Loop End Sub Private Sub cmdEnd_Click() gblnStop = True End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) gblnStop = True T.StopTimer End Sub 'Projeye bir classmodule ekleyip adn cTimer yapn. Aadaki kodlar cTimer'in kod sayfasna yazn: Option Explicit Private Declare Function timeGetTime Lib "winmm.dll" () As Long ' timeGetTime fonksiyonu sistem zamann milisaniye cinsinden alr. ' Sistem zaman, Windows'un balatld zamandan itibaren geen zamandr. Public lStart As Long Public Sub StartTimer() lStart = timeGetTime End Sub Public Function StopTimer() As Long StopTimer = timeGetTime - lStart End Function Public Function CheckTimer() CheckTimer = timeGetTime - lStart End Function 'Normal modl ekleyip kod olarak aadakileri yazn: Sub ShowTimer() UserForm1.Show End Sub 'alma sayfasna bir buton ekleyip ShowTimer makrosunu atayn
Resim semek iin ComboBox'a ift tklayp oklu seim yapmanz ve A'a tklamak yeterlidir. ComboBox'tan seilen resim Image'de grnr. Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim FD As FileDialog Dim FFs As FileDialogFilters Dim stFileName As String Dim vaItem On Error GoTo Problem Set FD = Application.FileDialog(msoFileDialogOpen) With FD Set FFs = .Filters With FFs .Clear .Add "Pictures", "*.jpg" End With .AllowMultiSelect = True If .Show = False Then Exit Sub ComboBox1.Clear For Each vaItem In .SelectedItems ComboBox1.AddItem vaItem Next vaItem ComboBox1.ListIndex = 0 End With Exit Sub Problem: MsgBox "Geerli bir resim dosyas deil." End Sub Private Sub ComboBox1_Change() Image1.Picture = LoadPicture(ComboBox1.Text) End Sub
Resim semek iin ComboBox'a ift tklayp oklu seim yapmanz ve A'a tklamak yeterlidir. ComboBox'tan seilen resim Image'de grnr. Kod: Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim FD As FileDialog Dim FFs As FileDialogFilters Dim stFileName As String Dim vaItem On Error GoTo Problem Set FD = Application.FileDialog(msoFileDialogOpen) With FD Set FFs = .Filters With FFs .Clear .Add "Pictures", "*.jpg" End With .AllowMultiSelect = True If .Show = False Then Exit Sub ComboBox1.Clear For Each vaItem In .SelectedItems ComboBox1.AddItem vaItem Next vaItem ComboBox1.ListIndex = 0 End With Exit Sub Problem: MsgBox "Geerli bir resim dosyas deil." End Sub Private Sub ComboBox1_Change() Image1.Picture = LoadPicture(ComboBox1.Text) End Sub Private Sub UserForm_Activate() SAAT.Caption = Format(Time, "hh:mm:ss") End Sub Sub saat() UserForm1.Label1 = Format(Now(), "dd/mm/yyyy - hh:mm") zaman = TimeValue(DateAdd("s", 60 - Second(Now()), Now())) Application.OnTime zaman, "saat", , True End Sub Private Sub UserForm_Activate() Module1.saat End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Application.OnTime zaman, "saat", , False End Sub
Module Global zaman Sub saat() UserForm1.Label1 = Format(Now(), "dd/mm/yyyy - hh:mm") zaman = TimeValue(DateAdd("s", 60 - Second(Now()), Now())) Application.OnTime zaman, "saat", , True End Sub 'Userform ksmna Private Sub UserForm_Activate() Module1.saat End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Application.OnTime zaman, "saat", , False End Sub Private Sub UserForm_Initialize() Calendar1.Year = Year(Now) Calendar1.Month = Month(Now) End Sub 'bir nceki ay gsterecek commandbutton iin; Private Sub CommandButton1_Click() If Month(Now) = 1 Then Calendar1.Year = Year(Now) - 1 Calendar1.Month = Month(Now) + 11 Exit Sub End If Calendar1.Year = Year(Now) Calendar1.Month = Month(Now) - 1 End Sub 'imdiye geri dnecek commandbutton iin; Private Sub CommandButton2_Click() Calendar1.Year = Year(Now) Calendar1.Month = Month(Now) End Sub 'Bir sonraki ay gsterecek commandbutton iin; Private Sub CommandButton3_Click() If Month(Now) = 12 Then Calendar1.Year = Year(Now) + 1 Calendar1.Month = Month(Now) - 11 Exit Sub End If Calendar1.Year = Year(Now) Calendar1.Month = Month(Now) + 1 End Sub
combo1 de yllar combo2 de aylar (1,2,...12) 31 tanede textbox oldugunu varsaydim. Kod: Private Sub ComboBox2_Change() If ComboBox2 = 12 Then x = DateDiff("d", "1" & "." & ComboBox2 & "." & ComboBox1, "1" & "." & "1" & "." & ComboBox1 + 1) Else x = DateDiff("d", "1" & "." & ComboBox2 & "." & ComboBox1, "1" & "." & ComboBox2 + 1 & "." & ComboBox1) End If z=1 Dim ctrl As Control For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "TextBox" Then ctrl.Text = "" End If Next ctrl For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "TextBox" Then ctrl.Text = z If z = x Then Exit For z=z+1 End If Next ctrl End Sub Private Sub CommandButton1_Click() TextBox1 = Val(TextBox2.Value) + Val(TextBox3.Value) End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Workbooks("nomduclasseur.xls").Close False End Sub
WS_SYSMENU As Long = &H80000 WS_THICKFRAME As Long = &H40000 WS_MINIMIZEBOX As Long = &H20000 WS_MAXIMIZEBOX As Long = &H10000 WS_POPUP As Long = &H80000000 WS_VISIBLE As Long = &H10000000 WS_EX_DLGMODALFRAME As Long = &H1 WS_EX_APPWINDOW As Long = &H40000 WS_EX_TOOLWINDOW As Long = &H80
Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" ( _ ByVal ClassName As String, _ ByVal WindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" ( _ ByVal hWnd As Long, _ ByVal Index As Long) As Long Private Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" ( _ ByVal hWnd As Long, _ ByVal Index As Long, _ ByVal NewLong As Long) As Long Const GWL_STYLE = -16 Private Sub UserForm_Initialize() Dim hWnd As Long Dim Style As Long If Val(Application.Version) >= 9 Then hWnd = FindWindow("ThunderDFrame", Me.Caption) Else hWnd = FindWindow("ThunderXFrame", Me.Caption) End If Style = GetWindowLong(hWnd, GWL_STYLE) Style = (Style And Not WS_SYSMENU) SetWindowLong hWnd, GWL_STYLE, Style End Sub Sub ResetAllCheckBoxesInUserForm() Dim ctrl As Control For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "CheckBox" Then ctrl.Value = False End If Next ctrl End Sub sub dosyabul() dim a as string a = application.findfile msgbox a end sub Sub ResetAllOptionButtonsInUserForm() Dim ctrl As Control For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "OptionButton" Then ctrl.Value = False End If Next ctrl End Sub Sub ResetAllTextBoxesInUserForm() Dim ctrl As Control For Each ctrl In UserForm1.Controls If TypeName(ctrl) = "TextBox" Then ctrl.Text = "" End If Next ctrl End Sub
Private Sub TextBox1_Change() [a2] = TextBox1.Text End Sub Private Sub CommandButton1_Click() UserForm1.Hide Worksheets("sayfa1").PrintPreview Worksheets("sayfa1").PageSetup.PrintArea = "" Application.Visible = False UserForm1.Show End Sub UserForm kod modulne: Kod: Private Sub CommandButton1_Click() Sheets("Sayfa1").Range("B" & ComboBox1.ListIndex + 2) = TextBox1 End Sub C:\Den altnda A ve B xls dosyalarm var. A userform1 de 5 tane commandbutton var B de de 5 tane userform var. Yapmak istediim u; A.xls Userform1 deki Commandbutton1 e tklandnda Commandbutton2 e tklandnda Commandbutton3 e tklandnda Commandbutton4 e tklandnda Commandbutton5 e tklandnda B.xls B.xls B.xls B.xls B.xls deki userform1 alsn deki userform2 alsn deki userform3 alsn deki userform4 alsn deki userform5 alsn
'
Aadaki kodu B.xls de bir Modle yazn. Kod: Sub ac() UserForm1.Show End Sub Aadaki koduda Butonunuzun olduu sayfann Kod blmne yaznz. Kod: Private Sub CommandButton1_Click() Application.Run "B.xls!ac" End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then MsgBox "UserForm kann nur mit Klick auf 'Beenden' geschlossen werden !" Cancel = True End If End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Application.ScreenUpdating = False Workbooks("Combo rnekleri.xls").Close True End Sub
Dim EB As Object, LB As Object Dim vaList As Variant Dim oldText As String Sub TryIt() Sheets("Dialog1").Show End Sub Sub SetEditBox() With ActiveDialog Set EB = .EditBoxes(1) Set LB = .ListBoxes(1) .Focus = EB.Name End With EB.Text = "" LB.ListIndex = 0 vaList = LB.List End Sub Sub EditBoxAction() Dim i As Variant Dim ebText As String, lbText As String Dim iNums As Integer Static fSendKeys As Boolean If fSendKeys = True Then fSendKeys = False Exit Sub End If fSendKeys = False ebText = EB.Text If ebText = "" Then LB.ListIndex = 0 Else i = Application.Match(ebText & "*", vaList, 0) If IsError(i) = False Then LB.ListIndex = i lbText = LB.List(i) If Len(ebText) > Len(oldText) Or Left(ebText, Len(oldText)) <> ebText Then iNums = Len(lbText) - Len(ebText) If iNums > 0 Then SendKeys Right(lbText, iNums) & "+{LEFT " & iNums & "}" fSendKeys = True End If End If Else LB.ListIndex = 0 End If End If oldText = ebText End Sub Sub ListBoxAction() With LB EB.Text = LB.List(LB.ListIndex) End With oldText = EB.Text ActiveDialog.Focus = "ebMonth" SendKeys "{RIGHT}" End Sub
'Define a variable type to store the window coordinates Type typRect16 Left As Integer Top As Integer Right As Integer Bottom As Integer End Type 'Get the dimensions of the screen Declare Function GetSystemMetrics16 Lib "User" Alias "GetSystemMetrics" (ByVal nIndex As Integer) As Integer 'Get the handle for a window Declare Function FindWindow16 Lib "User" Alias "FindWindow" (ByVal szClass$, ByVal szTitle$) As Integer 'Get the dimensions of the window Declare Sub GetWindowRect16 Lib "User" Alias "GetWindowRect" (ByVal hWnd As Integer, lpRect As typRect16) 'Set the dimensions of the window Declare Sub Movewindow16 Lib "User" Alias "Movewindow" (ByVal hWnd As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, By '* Declare Windows API calls and data types - 32 bit for Windows 95 and NT * 'Define a variable type to store the window coordinates Type typRect32 Left As Long Top As Long Right As Long Bottom As Long End Type 'Get the dimensions of the screen Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long 'Get the handle for a window Declare Function FindWindow32 Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 'Get the dimensions of the window Declare Function GetWindowRect32 Lib "user32" Alias "GetWindowRect" (ByVal hWnd As Long, lpRect As typRect32) As Long 'Set the dimensions of the window Declare Function Movewindow32 Lib "user32" Alias "MoveWindow" (ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVa Sub CentreDialog() If InStr(1, Application.OperatingSystem, "32") = 0 Then CentreDialog16 Else CentreDialog32 End If End Sub Sub CentreDialog16() On Error Resume Next '*** DIMENSION VARIABLES *** Dim tRect As typRect16 'Variables to retrieve the screen dimensions with GetSystemMetrics API. Dim iScreenWidth As Integer Dim iScreenHeight As Integer 'Variable to store the window handle with FindWindow API. Dim ihWnd As Integer 'Variables to calculate the new dimensions for the window. Dim iWidth As Integer Dim iHeight As Integer Dim iLeft As Integer Dim iTop As Integer 'Get the handle of the dialog box window - 'bosa_sdm_XL' is the class name 'for an Excel 5 dialog box. ihWnd = FindWindow16("bosa_sdm_XL", ActiveDialog.DialogFrame.Text) 'Only continue if a valid handle is returned If ihWnd <> 0 Then 'Get the width and height of the screen in pixels iScreenWidth = GetSystemMetrics16(0) iScreenHeight = GetSystemMetrics16(1) 'Get the dimensions of the dialog box window in pixels GetWindowRect16 ihWnd, tRect 'Calculate the width and height of the dialog box iWidth = Abs(tRect.Right - tRect.Left) iHeight = Abs(tRect.Top - tRect.Bottom) 'Calculate the new position of the dialog box in pixels iLeft = (iScreenWidth - iWidth) / 2 iTop = (iScreenHeight - iHeight) / 2 'Move the dialog box to the centre of the screen Movewindow16 ihWnd, iLeft, iTop, iWidth, iHeight, True End If End Sub Sub CentreDialog32() On Error Resume Next '*** DIMENSION VARIABLES *** Dim tRect As typRect32 'Variables to retrieve the screen dimensions with GetSystemMetrics API. Dim iScreenWidth As Long Dim iScreenHeight As Long 'Variable to store the window handle with FindWindow API.
Dim dlg As DialogSheet ' global variable Sub SheetNavigation() Dim ws As Worksheet Application.ScreenUpdating = False Set dlg = ActiveWorkbook.DialogSheets.Add With dlg.DialogFrame .Left = 0 .Top = 0 .Height = 300 ' dialog height .Width = 300 ' dialog width End With dlg.Buttons(1).Left = 245 ' position of button1 dlg.Buttons(2).Left = 245 ' position of button2 With dlg.ListBoxes.Add(10, 15, 230, 275) ' size of listbox For Each ws In ActiveWorkbook.Worksheets If ws.Visible Then .AddItem ws.Name Next ws .ListIndex = 0 .OnAction = "DisplaySheet" End With dlg.DialogFrame.Text = "Select the worksheet you want to activate" dlg.Visible = False Application.ScreenUpdating = True If dlg.Show Then Worksheets(dlg.ListBoxes(1).List(dlg.ListBoxes(1).ListIndex)).Activate End If Application.DisplayAlerts = False dlg.Delete Application.DisplayAlerts = True Set ws = Nothing Set dlg = Nothing End Sub Private Sub DisplaySheet() Sheets(dlg.ListBoxes(1).List(dlg.ListBoxes(1).ListIndex)).Activate End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then MsgBox "Bitte mit dem Button 'Beenden' schlieen!", vbOKOnly, "Websuche bei kmbuss.de" Cancel = True End If End Sub Private Sub cmdStopAlarm_Click() Me.Height = 55 End Sub 'Userformu ama (daraltlan) Private Sub cmdStopAlarm_Click() Me.Height = 185 End Sub Private Sub UserForm_Activate() If InputBox("ifreyi giriniz") <> "pir" Then MsgBox ("ifreyi bilemediniz.Bilgiler zerinde degiiklik yapamazsnz.....!") TextBox1.Locked = True End If End Sub Private Sub UserForm_Activate() If InputBox("ifreyi giriniz") <> "pir" Then MsgBox ("ifreyi bilemediniz:Form Kapatlacak..!") Unload Me End If End Sub Private Sub UserForm_Activate() ' Forma ifre koyma (ifre bilgisayarn saati) rnek (10:02) If InputBox("ifreyi giriniz") <> Mid(Time, 1, 5) Then MsgBox ("ifreyi bilemediniz.bilgiler zerinde degiiklik yapamazsnz.") Text1.Locked = True End If End Sub Private Sub UserForm_Activate() Application.WindowState = xlMaximized Me.Left = Application.Width - Me.Width Me.Top = 0 End Sub
With Application .WindowState = xlMaximized Zoom = Int(.Width / Me.Width * 100) Width = .Width Height = .Height End With End Sub Fullscren ile ama bu seferde userin zerindeki nesneler farkllk gsterecek.zm yok.VB Kullanrsan olur.. Bu kodlar kod sayfann en bana yazarsan 3 Dme oluur.Kullanc istedii gibi bytr kltr. Kod: Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long ' Private Sub UserForm_Activate() Dim hWndForm As Long, frmStyle As Long hWndForm = FindWindow(vbNullString, Me.Caption) frmStyle = GetWindowLong(hWndForm, (-16)) frmStyle = frmStyle Or &H80000 Or &H20000 Or &H10000 SetWindowLong hWndForm, (-16), frmStyle ShowWindow hWndForm, 5 DrawMenuBar hWndForm End Sub Ayr bir kod ise Userformun alnda tam ekran olarak gelmesi. Kod: Private Sub UserForm_Initialize() With Application Me.Top = .Top Me.Left = .Left Me.Height = .Height Me.Width = .Width End With End Sub Private Sub UserForm_Initialize() With UserForm1 .Height = Application.Height .Width = Application.Width End With End Sub Private Sub UserForm_Initialize() With UserForm1 .Height = Application.Height .Width = Application.Width End With End Sub Private Sub UserForm_Initialize() UserForm1.Height = Application.Height UserForm1.Width = Application.Width End Sub
1 adet UserForm '1 adet Label 'Aadaki kodlar UserForm'un kod blmne yaptrnz. Dim webtr Private Sub UserForm_Activate() webtr = GetSetting("snr", "snrla", "webtr", 0) If webtr >= 5 Then 'burdaki 5 rakam userformun ka kere alacan belirtiyor. SaveSetting "snr", "snrla", "webtr", 111111 MsgBox "zgnm UserForm 5 kere alm." & Chr(10) _ & "Aslanm hereyin fazlas HARAM", vbOKOnly, "Uyar" Unload Me End Else webtr = webtr + 1 SaveSetting "snr", "snrla", "webtr", webtr Label1.Caption = webtr & " oldu." End If End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True End Sub Aklama: UserFormun bandaki kapat butonunu pasif yapar (arpya basnca userform kapanmaz) Kod: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True End Sub Bu da UserFormun arp iaretine tklaynca Mesaj kutusuyla uyar veriyor Kod: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then MsgBox "arpdan kapatmak yasaktr!" Cancel = True End If End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0: MsgBox " Harf girilmeyecek,Sadece Rakam Giriniz ....." End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then MsgBox "arpdan kapatmak yasaktr!" Cancel = True 'Bu satr MsgBox tan nce de yazabilirsiniz End If End Sub Private Sub CommandButton2_Click() Unload Me End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode <> 1 Then Cancel = True End Sub Private Sub UserForm_Initialize() CommandButton2.Cancel = True End Sub Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 27 Then Unload Me End Sub Userformdaki optionbuttona aadaki kodlar Private Sub OptionButton1_Click() Me.Height = 153 zaman = Now + TimeValue("00:00:05") Application.OnTime zaman, "boyut" End Sub 'Bir module de aadaki kodlar yazn Sub boyut() UserForm4.Width = 320 End Sub
Private Sub UserForm_Initialize() TextBox1.Value = Range("A1").Value TextBox2.Value = Range("A2").Value TextBox3.Value = Range("A3").Value End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Range("A1").Value = TextBox1.Value Range("A2").Value = TextBox2.Value Range("A3").Value = TextBox3.Value End Sub "FindWindowA" (ByVal lpClassName As String, ByVal _ lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long, ByVal dwNewLong As Long) As Long Private Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _ ByVal wParam As Integer, ByVal lParam As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal _ hWnd As Long) As Long Private wHandle As Long Private Sub UserForm_Initialize() On Error Resume Next Me.Caption = "pir" Image1.Visible = False If Val(Application.Version) >= 9 Then wHandle = FindWindow("ThunderDFrame", Me.Caption) Else wHandle = FindWindow("ThunderXFrame", Me.Caption) End If If wHandle = 0 Then Exit Sub hIcon = Image1.Picture SendMessage wHandle, &H80, True, hIcon SendMessage wHandle, &H80, False, hIcon frm = GetWindowLong(wHandle, -20) frm = frm And Not &H1 SetWindowLong wHandle, -20, frm DrawMenuBar wHandle End Sub UserForm'un Properties lerinden ShowModal ksmn False yaparsanz UserForm aktif iken hcrelerde gezebilirsiniz Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub UserForm_Initialize() Dim hwnd As Long hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _ "X", "D") & "Frame", Me.Caption) SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF End Sub
Private Declare Function GetWindowLongA Lib "User32" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "User32" _ (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub UserForm_Initialize() Dim hwnd As Long hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _ "X", "D") & "Frame", Me.Caption) SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF End Sub Private Sub CommandButton1_Click() TextBox1 = Val(TextBox2.Value) + Val(TextBox3.Value) End Sub maximize yapmak iinde Kod: Private Sub UserForm_Activate() Application.WindowState = xlMaximized Me.Left = Application.Width - Me.Width Me.Top = 0 End Sub Private Sub UserForm_Initialize() Dim i% Dim TMP$ ComboBox1.Clear For i = 1 To 12 TMP = Format(DateSerial(2004, i, 1), "mmmm") ComboBox1.AddItem TMP Next i ComboBox1.ListIndex = 0 End Sub Private Sub UserForm_Initialize() Dim i% Dim TMP$ ComboBox1.Clear For i = 1 To 12 TMP = Format(DateSerial(2004, i, 1), "mmmm") ComboBox1.AddItem TMP Next i ComboBox1.ListIndex = 0 End Sub Private Sub TextBox1_Change() [a2] = TextBox1.Text End Sub Private Sub CommandButton1_Click() UserForm1.PrintForm End Sub Gerekli olanlar 1 adet userform zerine commanbutton, Commandbutton'a yazacanz kod: Kod: Private Sub CommandButton1_Click() UserForm1.PrintForm End Sub
"FindWindowA" (ByVal lpClassName As String, ByVal _ lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long, ByVal dwNewLong As Long) As Long Private Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _ ByVal wParam As Integer, ByVal lParam As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal _ hWnd As Long) As Long Private wHandle As Long Private Sub UserForm_Initialize() On Error Resume Next Me.Caption = "pir" Image1.Visible = False If Val(Application.Version) >= 9 Then wHandle = FindWindow("ThunderDFrame", Me.Caption) Else wHandle = FindWindow("ThunderXFrame", Me.Caption) End If If wHandle = 0 Then Exit Sub hIcon = Image1.Picture SendMessage wHandle, &H80, True, hIcon SendMessage wHandle, &H80, False, hIcon frm = GetWindowLong(wHandle, -20) frm = frm And Not &H1 SetWindowLong wHandle, -20, frm DrawMenuBar wHandle End Sub Private Sub UserForm_Initialize() UserForm1.Caption = "pir" End Sub
Private Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, ByVal _ lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long, ByVal dwNewLong As Long) As Long Private Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _ ByVal wParam As Integer, ByVal lParam As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal _ hWnd As Long) As Long Private wHandle As Long Private Sub UserForm_Initialize() On Error Resume Next Me.Caption = "www.excel.web.tr" Image1.Visible = False If Val(Application.Version) >= 9 Then wHandle = FindWindow("ThunderDFrame", Me.Caption) Else wHandle = FindWindow("ThunderXFrame", Me.Caption) End If If wHandle = 0 Then Exit Sub hIcon = Image1.Picture SendMessage wHandle, &H80, True, hIcon SendMessage wHandle, &H80, False, hIcon frm = GetWindowLong(wHandle, -20) frm = frm And Not &H1 SetWindowLong wHandle, -20, frm DrawMenuBar wHandle End HarfHarf(ref As UserForm1) Sub Sub baslik = ref.Caption ref.Caption = "" For i = 0 To Len(baslik) If i = 0 Then ref.Caption = "" current = Timer Do While Timer - current < 0.1 DoEvents Loop GoTo Son Else End If ref.Caption = Left(baslik, i) current = Timer Do While Timer - current < 0.01 DoEvents Loop Son: Next i End Sub Private Sub CommandButton1_Click() HarfHarf Me End Sub
Bu CommandButton3 butonu UserForm6'daki mi?Yoksa UserForm3'de ayr bir CommandButton3'mi Var. Eer UserForm3'de ayr bir CommandButton3 var ise; UserForm''n Initialize olayna visual basic kodu: -------------------------------------------------------------------------------Private Sub UserForm_Initialize() CommandButton1.Visible = False End Sub --------------------------------------------------------------------------------
Yazmanz gerek ..AKsi halde UserForm6 Unload Me ile kapanacandan dediiniz (UserForm6 zerindeyse CommandButton3) yapamazsnz.(*)
Prensip olarak .Visible =True ve False ile gizlemeleri yapabilirsiniz. Gizlemeyipte Aktif veya Aktif olmamasn isterseniz .Enabled =True veya False yazmanz gerek. Kolay Gelsin. Sub assist() Application.Assistant.Visible = True Assistant.Animation = msoAnimationIdle Set SB = Assistant.NewBalloon SB.Animation = msoAnimationCheckingSomething SB.BalloonType = msoBalloonTypeButtons SB.Heading = "istediiniz uyar!!" SB.Text = _ "Ich bin Dein persnlicher Assistent" If SB.Show = msoBalloonButtonOK Then Assistant.Visible = False End If end sub Sub auto_open() Beep MsgBox "Mesaj Buraya!!", vbCritical, "nemli" End Sub Sub Dene() MsgBox "aa", 16, "hata" End Sub Sub Denee() MsgBox "aa", 64, "hata" End Sub Sub auto_open() Beep MsgBox "Mesaj Buraya!!", vbCritical, "nemli" End Sub kaz mesaj veya benzeri bir sebeple hazrladnz bir UserForm'un ekranda bir sre Aktif/Deaktif durumda olmasn ve bu srada "Bip" sesiyle kullancy ik Private Declare Function FlashWindow Lib "user32" ( _ ByVal hwnd As Long, ByVal bInvert As Long) As Long Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Sub UserForm_Activate() Dim hWndForm As Long Dim i As Byte hWndForm = IIf(Application.Version < 9, _ FindWindow("ThunderXFrame", Me.Caption), _ FindWindow("ThunderDFrame", Me.Caption)) For i = 1 To 6 Application.Wait Now + TimeValue("00:00:01") Call FlashWindow(hWndForm, True) Beep Next End Sub
Sub Meldung() For i = 1 To 100 Beep Next i Meld = MsgBox("Termin nicht vergessen!", 0, "A c h t u n g") End Sub Sayfa korumas olan hcreler seildiinde uyar mesaj veren bir kod oluturulabilir. Aadaki kodu sayfann kod sayfasna kopyalayarak deneyin. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveCell.AllowEdit = False Then MsgBox "BU HCRE KORUMA ALTINDADIR" End Sub Sub Title_Caption() Application.Caption = "Mahmut_Bayram" End Sub Option Explicit Public AppCap$ Public ActWinCap$ Private Sub Worksheet_Activate() Application.Caption = Worksheets(1).Range("A1").Value ActiveWindow.Caption = Worksheets(1).Range("B1").Value & " / " & _ Worksheets(1).Range("C1").Value & " / " & _ Worksheets(1).Range("D1").Value & " / " & _ Worksheets(1).Range("E1").Value End Sub Private Sub Worksheet_Change(ByVal Target As Range) Application.Caption = Worksheets(1).Range("A1").Value ActiveWindow.Caption = Worksheets(1).Range("B1").Value & " / " & _ Worksheets(1).Range("C1").Value & " / " & _ Worksheets(1).Range("D1").Value & " / " & _ Worksheets(1).Range("E1").Value End Sub 'ThisWorkbook a Option Explicit Public AppCap$ Public ActWinCap$ Private Sub Workbook_Activate() Application.Caption = Worksheets(1).Range("A1").Value ActiveWindow.Caption = Worksheets(1).Range("B1").Value & " / " & _ Worksheets(1).Range("C1").Value & " / " & _ Worksheets(1).Range("D1").Value & " / " & _ Worksheets(1).Range("E1").Value End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.Caption = AppCap ActiveWindow.Caption = ActWinCap End Sub Private Sub Workbook_Deactivate() Application.Caption = AppCap ActiveWindow.Caption = ActWinCap End Sub Private Sub Workbook_Open() Application.Caption = Worksheets(1).Range("A1").Value ActiveWindow.Caption = Worksheets(1).Range("B1").Value & " / " & _ Worksheets(1).Range("C1").Value & " / " & _ Worksheets(1).Range("D1").Value & " / " & _ Worksheets(1).Range("E1").Value End Sub
Sub uclu() Buttons = vbYesNoCancel + vbQuestion + vbDefaultButtons2 x = MsgBox("Tulardan birine tklayn", Buttons, "Mesaj") Select Case x Case vbYes MsgBox "Evet Butonunu tkladnz!" Case vbNo MsgBox "Hayr Butonunu tkladnz!" Case vbCancel MsgBox "ptal Butonunu tkladnz!" End Select End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Set rng = Columns("C:C") If Not (Intersect(Target, rng) Is Nothing) Then rng.ColumnWidth = 30 Else rng.ColumnWidth = 10.71 End If End Sub Dim cmb As CommandBar Set cmb = Application.CommandBars("Standard") With cmb.Controls.Add(Type:=msoControlButton, _ Temporary:=True) .Caption = "Meine 1. Prozedur" .BeginGroup = True .FaceId = 59 .OnAction = "MeineProzedur1" End With With cmb.Controls.Add(Type:=msoControlButton, _ Temporary:=True) .Caption = "Meine 2. Prozedur" .FaceId = 49 .OnAction = "MeineProzedur2" End With Set cmb = Nothing End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim cmb As CommandBar Set cmb = Application.CommandBars("Standard") With cmb .Controls("Meine 1. Prozedur").Delete .Controls("Meine 2. Prozedur").Delete End With Set cmb = Nothing End Sub Sub MeineProzedur1() MsgBox Application.UserName End Sub Sub MeineProzedur2() MsgBox Now() End Sub Sub test() GetValuesFromAClosedWorkbook "C:", "Book1.xls", _ "Sheet1", "A1:K30" End Sub Sub GetValuesFromAClosedWorkbook(fPath As String, _ fName As String, sName, cellRange As String) With ActiveSheet.Range(cellRange) .FormulaArray = "='" & fPath & "\[" & fName & "]" _ & sName & "'!" & cellRange .Value = .Value End With End Sub
Sub GetSheets() Dim j As Integer Dim NumSheets As Integer NumSheets = Sheets.Count For j = 1 To NumSheets Cells(j, 1) = Sheets(j).Name Next j End Sub Run ilem yapabilmesi iin altrmak istediiniz makronun bulunduu Excel dosyasn daha nceden am olmalsnz Sub ExcelMakrosunuCalistir() Dim xlApp As Object Set xlApp = CreateObject("Excel.Application") xlApp.Run (FormAc) End Sub Appication.Run(varsa argmanlar1, varsa argmanlar2) Sub DatenUmwandeln() Dim MyRange As Range Dim Cell As Range Application.ScreenUpdating = False Set MyRange = ActiveCell.CurrentRegion.Columns(7) For Each Cell In MyRange Cell.Select Application.SendKeys "{F2}+{ENTER}", True Next Cell End Sub Sub Auto_Open() Dim i As Integer Dim j As Integer If Worksheets.Count = 1 Then Exit Sub For i = 1 To Worksheets.Count - 1 For j = i + 1 To Worksheets.Count If Worksheets(j).Name < Worksheets(i).Name Then Worksheets(j).Move before:=Worksheets(i) End If Next j Next i End Sub Sub ViewCode() Application.Goto Reference:="Makro1" End Sub Bu kodu bir butona ataynz:
Application.GoTo Refe
Kod: Private Sub Workbook_Open() Application.VBE.MainWindow.Visible = False '// Close ALL windows 1st! CmdControl 1695, False '// Visual basics Editor CmdControl 186, False '// Macros... CmdControl 184, False '// Record New Macro... CmdControl 1561, False '// View Code CmdControl 1605, False '// Design Mode Application.OnDoubleClick = "Dummy" Application.CommandBars("ToolBar List").Enabled = False Application.OnKey "%{F11}", "Dummy" 'Workbooks.Open "C:\" 'add your stuff here ActiveWorkbook.RunAutoMacros xlAutoOpen End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) CmdControl 1695, True '// Visual basics Editor CmdControl 186, True '// Macros... CmdControl 184, True '// Record New Macro... CmdControl 1561, True '// View Code CmdControl 1605, True '// Design Mode Application.OnDoubleClick = "" Application.CommandBars("ToolBar List").Enabled = True 'thisone Application.OnKey "%{F11}", "" End Sub Sub CmdControl(Id As Integer, TF As Boolean) Dim CBar As CommandBar Dim C As CommandBarControl On Error Resume Next For Each CBar In Application.CommandBars Set C = CBar.FindControl(Id:=Id, recursive:=True) If Not C Is Nothing Then C.Enabled = TF Next End Sub Sub Dummy() MsgBox "Kstl Men" End Sub
Kod: Sub Klasor_olustur() Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.CreateFolder("C:\YeniKlasor") End Sub 2-Klasr Ad Deitirme Kod: Sub Klasor_ad_degistir() Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.MoveFolder "C:\YeniKlasor\eski_adi", "C:\YeniKlasor\yeni_adi" End Sub 3-Klasr Silme Kod: Sub Klasor_sil() Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.DeleteFolder ("C:\YeniKlasor") End Sub 4-Klasr Tama Kod: Sub Klasor_tasi() Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.MoveFolder "C:\YeniKlasor", "D:\YeniKlasor" End Sub 5-Klasr Kopyalama Kod: Sub Klasor_kopyala() Const OverWriteFiles = True Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.CopyFolder "C:\YeniKlasor", "C:\EskiKlasor", OverWriteFiles End Sub 6-Alt Klasr Listesi Kod: Sub Klasor_altklasor_listesi() Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("C:\YeniKlasor") Set colSubfolders = objFolder.Subfolders For Each objSubfolder In colSubfolders MsgBox objSubfolder.Name, objSubfolder.Size Next End Sub Private Sub CommandButton1_Click() If TextBox1 > 1 And TextBox1 <= 3600# Then iade = TextBox1 * 0.08 If TextBox1 >= 3601# And TextBox1 <= 7200# Then iade = (((TextBox1 - 3600#) * 0.06) + (3600# * 0.08)) If TextBox1 >= 7201# And TextBox1 >= 7201# Then iade = (((TextBox1 - 7200#) * 0.04) + (7200# * 0.07)) MsgBox iade End Sub Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim r As Integer r = Cells(65536, 2).End(xlUp).Row Cells(r + 1, 2) = Range("a1") Application.ScreenUpdating = True End Sub
VERLER BULUR Private Sub CommandButton6_Click() VERLER BULUR Dim bak As Range PrivateEach CommandButton6_Click() For Sub bak In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000"))) Dim bak As Range If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then For Each bak In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000"))) bak.Select If StrConv(bak.Value,ActiveCell.Offset(0, -1).Value TextBox1.Value = vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then bak.Select TextBox2.Value = ActiveCell.Offset(0, 1).Value TextBox1.Value = ActiveCell.Offset(0, -1).Value TextBox3.Value = ActiveCell.Offset(0, 2).Value TextBox2.Value = ActiveCell.Offset(0, 1).Value Exit Sub TextBox3.Value = ActiveCell.Offset(0, 2).Value End If Exit Next bak Sub End "Aradnz isimde bir kayt bulunamad" MsgBoxIf Next End Subbak MsgBox "Aradnz isimde bir kayt bulunamad" 'VER ARATIRKEN STUN SEMN GEN TUTARSAK BTN SAYFADA VER ARATABLRZ. End Sub Private Sub CommandButton1_Click() 'VER ARATIRKEN STUN SEMN GEN TUTARSAK BTN SAYFADA VER ARATABLRZ. Dim bak As Range PrivateEach CommandButton1_Click() For Sub bak In Range("a1:v" & WorksheetFunction.CountA(Range("a1:v65000"))) Dim bak As Range If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then For Each bak In Range("a1:v" & WorksheetFunction.CountA(Range("a1:v65000"))) bak.Select If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then bak.Select Exit Sub Exit End If Sub End If Next bak NextMsgBox "Aradnz isimde bir kayt bulunamad" bak MsgBox "Aradnz isimde bir kayt bulunamad" End Sub End Sub VERLER DETRR (DZENLEME YAPILANLARI KAYDEDER) Private Sub CommandButton8_Click() Dim bak As Range For Each bak In Range("b1:b" & WorksheetFunction.CountA(Range("b1:b65000"))) If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then bak.Select ActiveCell.Value = ComboBox1.Value ActiveCell.Offset(0, 1).Value = TextBox2.Value ActiveCell.Offset(0, 2).Value = TextBox3.Value Workbooks("KTAP2.XLS").Save MsgBox "Verileriniz Baaryla Deitirildi", , "KAYIT" ComboBox1.Value = WorksheetFunction.Count(Range("A1:A65000")) + 1 Unload UserForm1 UserForm1.Show Exit Sub End If Next bak End Sub VERLER DETRR (DZENLEME YAPILANLARI KAYDEDER) Private Sub CommandButton8_Click() Dim bak As Range For Each bak In Range("b1:b" & WorksheetFunction.CountA(Range("b1:b65000"))) If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then bak.Select ActiveCell.Value = ComboBox1.Value ActiveCell.Offset(0, 1).Value = TextBox2.Value ActiveCell.Offset(0, 2).Value = TextBox3.Value Workbooks("KTAP2.XLS").Save MsgBox "Verileriniz Baaryla Deitirildi", , "KAYIT" ComboBox1.Value = WorksheetFunction.Count(Range("A1:A65000")) + 1 Unload UserForm1 UserForm1.Show Exit Sub End If Next bak End Sub
Eer Sizin alma kitabnz sizden bakasnn deitirip kaydetmesini istemiyorsanz ki sorunuzdan bunu anladm yle bir koruma altna alabilirsiniz.Kodla Private Sub Workbook_BeforeSave _ (ByVal SaveAsUI As Boolean, Cancel As Boolean) sifre = InputBox("Kayt iin ifreyi girmelisiniz", _ "KAYIT", "ifre girin") If sifre = "xxrt" Then MsgBox "Kayt ilemi tamamland", vbInformation, _ "KAYIT BAARILI" Else MsgBox "Yanl ifre girdiniz." & Chr(13) & _ "Dosya kaydedilemedi", vbCritical, "HATALI FRE" Cancel = True End If End Sub VER GRME LSTE KUTUSU Private Sub ListBox1_Click() TextBox1.Value = ListBox1.Value End Sub VER GRME LSTE KUTUSU Private Sub TextBox1_Change() End Sub VER GRME LSTE KUTUSU Private Sub TextBox2_Change() End Sub VER GRME LSTE KUTUSU Private Sub TextBox3_Change() End Sub VER GRME LSTE KUTUSU Private Sub ListBox1_Click() TextBox1.Value = ListBox1.Value End Sub VER GRME LSTE KUTUSU Private Sub TextBox1_Change() End Sub VER GRME LSTE KUTUSU Private Sub TextBox2_Change() End Sub VER GRME LSTE KUTUSU Private Sub TextBox3_Change() End Sub DEER DETRC BUTONU LEV Private Sub SpinButton1_Change() TextBox1 = SpinButton1 'DEERN DETRLECE TextBox%SpinButton End Sub 'COMBOBOX&TEXTBOX'DAK VERLER AAI DORU KAYDIRIR. Private Sub SpinButton2_Change() TextBox1.Value = ActiveCell.Offset(0, 0).Value ComboBox1.Value = ActiveCell.Offset(0, 1).Value TextBox3.Value = ActiveCell.Offset(0, 2).Value TextBox4.Value = ActiveCell.Offset(0, 3).Value TextBox5.Value = ActiveCell.Offset(0, 4).Value TextBox6.Value = ActiveCell.Offset(0, 5).Value ActiveCell.Offset(1, 0).Select 'BRER BRER HC.AAI KAYDIRIR. End Sub
DEER DETRC BUTONU LEV Private Sub SpinButton1_Change() TextBox1 = SpinButton1 'DEERN DETRLECE TextBox%SpinButton End Sub 'COMBOBOX&TEXTBOX'DAK VERLER AAI DORU KAYDIRIR. Private Sub SpinButton2_Change() TextBox1.Value = ActiveCell.Offset(0, 0).Value ComboBox1.Value = ActiveCell.Offset(0, 1).Value TextBox3.Value = ActiveCell.Offset(0, 2).Value TextBox4.Value = ActiveCell.Offset(0, 3).Value TextBox5.Value = ActiveCell.Offset(0, 4).Value TextBox6.Value = ActiveCell.Offset(0, 5).Value ActiveCell.Offset(1, 0).Select 'BRER BRER HC.AAI KAYDIRIR. End Sub Sub imprSansLigneVide() For Each Ligne In ActiveSheet.UsedRange.Rows If Ligne.Cells(1, 1).Value = Empty Then 'si la cellule de la colonne A est vide, la ligne est masque Ligne.EntireRow.Hidden = True End If Next 'Recherche de la derniere cellule ActiveCell.SpecialCells(xlLastCell).Select dercell = ActiveCell.Address 'definition de la zone d'impression zoneIMP = Range("A1", dercell).Address ActiveSheet.PageSetup.PrintArea = zoneIMP ActiveWindow.SelectedSheets.PrintOut Copies:=1 End Sub Excel de iki ayr stuna girilen verileri bir stn iine veri kayb olmadan toplamak. 'Bir adet modul oluturun ve iindeki kodlar modeln iine kopyalayn. Dim Sh_Src As String, Sh_Tgt As String Dim Sh_Src_Row As Integer, Sh_Src_Bas_Row As Integer, Sh_Src_Son_Row As Integer Sayfa = "sayfa1" Sh_Src_Bas_Row = 1 Sh_Src_Son_Row = 10 On Error GoTo Hata For Sh_Src_Row = Sh_Src_Bas_Row To Sh_Src_Son_Row If Trim(Sheets(Sayfa).Cells(Sh_Src_Row, "A")) = "" Then MsgBox "(Bo Veri)" & vbCrLf & "Hata Yeri!" & vbCrLf & "Sayfa Ad : " & Safya & vbCrLf & "Stn Ad : A" & Sh_Tgt_Row & "", vbCritical, "Hata..." Exit Sub Else Selection.Cells(C).Value = Selection.Cells(A).Value & " " & Selection.Cells(B).Value End If Next MsgBox "Aktarm lemi Bitti!", vbInformation, "BLG" Exit Sub Hata: MsgBox "Hata olutu!" & vbCrLf & Err.Number & " : " & Err.Description, vbCritical, "HATA OLUTU!" Sub HideRows() For Each rngRow In ActiveSheet.UsedRange.Rows If Application.Sum(rngRow) = 0 Then rngRow.EntireRow.Hidden = True End If Next rngRow End Sub Sub verili_yaz() Dim wc As Integer For wc = 1 To ThisWorkbook.Worksheets.Count ThisWorkbook.Worksheets(wc).PrintOut Next wc End Sub
Sub PrintAllSheets() Dim First As Integer, Last As Integer '// Assumning Sheet1 is 1st sheet Sheets("Sheet1").Activate Last = Sheets.Count For First = 1 To Last With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With ActiveSheet.PageSetup.PrintArea = "" '// set up the way you want here, this is just an example! With ActiveSheet.PageSetup .CenterHeader = "&F!&A" .RightHeader = "" .LeftFooter = "" .CenterFooter = "Page " & First & " of " & Last .RightFooter = "" & Application.Text(Now(), "yyyy") .PrintHeadings = False .PrintGridlines = False .PrintNotes = False .CenterHorizontally = True .CenterVertically = False .Orientation = xlPortrait .Draft = False .PaperSize = xlPaperLetter .FirstPageNumber = xlAutomatic .BlackAndWhite = False .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 End With ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True If First <> Last Then ActiveSheet.Next.Select Next First End Sub VERLER A'DAN Z'YE SIRALAR YAZILAN LKHARFE ENYAKIN SM BULUR Private Sub ComboBox1_Change() 'ListFillRange A2:A64997(vba zellikler mensne girilecek hc. Adreside buradan verilir.) ActiveWindow.ScrollRow = ComboBox1.ListIndex + 2 End Sub Private Sub ComboBox1_GotFocus() ActiveSheet.ComboBox1.ListIndex = -1 Rows("2:65000").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Dim no no = ActiveWindow.ScrollRow If KeyCode = 13 Then Cells(no, 1).Activate End Sub
VERLER SLER Private Sub CommandButton7_Click() Dim say As Integer Dim i As Integer Dim bos As Range For Each bos In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000"))) If ComboBox1.Value = "" Or bos = "" Or ActiveCell = "" Then MsgBox "nce aradnz veriyi BUL ile bulmalsnz" Exit Sub End If Next bos Range(ActiveCell.Offset(0, -1).Address(False, False) & ":" & ActiveCell.Offset(0, 2).Address(False, False)).Delete Shift:=xlUp say = WorksheetFunction.CountA(Range("A2:A65000")) For i = 1 To say Cells(i + 1, 1) = i Next i Workbooks("kitap2.XLS").Save MsgBox "Veriniz Silindi", , "KAYIT" ComboBox1.RowSource = "Veri!B1:B" & say + 1 TextBox1.Value = WorksheetFunction.Count(Range("A1:A65000")) + 1 Unload UserForm1 UserForm1.Show End Sub VERLER SLER Private Sub CommandButton7_Click() Dim say As Integer Dim i As Integer Dim bos As Range For Each bos In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000"))) If ComboBox1.Value = "" Or bos = "" Or ActiveCell = "" Then MsgBox "nce aradnz veriyi BUL ile bulmalsnz" Exit Sub End If Next bos Range(ActiveCell.Offset(0, -1).Address(False, False) & ":" & ActiveCell.Offset(0, 2).Address(False, False)).Delete Shift:=xlUp say = WorksheetFunction.CountA(Range("A2:A65000")) For i = 1 To say Cells(i + 1, 1) = i Next i Workbooks("kitap2.XLS").Save MsgBox "Veriniz Silindi", , "KAYIT" ComboBox1.RowSource = "Veri!B1:B" & say + 1 TextBox1.Value = WorksheetFunction.Count(Range("A1:A65000")) + 1 Unload UserForm1 UserForm1.Show End Sub VERLER A'DAN Z'YE SIRALAR YAZILAN LKHARFE ENYAKIN SM BULUR Private Sub ComboBox1_Change() 'ListFillRange A2:A64997(vba zellikler mensne girilecek hc. Adreside buradan verilir.) ActiveWindow.ScrollRow = ComboBox1.ListIndex + 2 End Sub Private Sub ComboBox1_GotFocus() ActiveSheet.ComboBox1.ListIndex = -1 Rows("2:65000").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Dim no no = ActiveWindow.ScrollRow If KeyCode = 13 Then Cells(no, 1).Activate End Sub
Sub ara() On Error Resume Next Application.ScreenUpdating = False sat = Sayfa1.Columns(1).Find(Sayfa2.[A1].Value).Row Sayfa1.Range("A" & sat, "F" & sat).Copy s = WorksheetFunction.CountA(Sayfa2.[B1:B65536]) Sayfa2.Range("B" & s + 1).PasteSpecial Paste:=xlPasteValues Application.CutCopyMode = False End Sub Sayfa1 Kod sayfasna;Kod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$a$1" Then Range("D54").Select End Sub Kodu yazdktan sonra A1 Hcresine geldiinizde D54 Hcresine gelecektir.Gerisini siz yaparsnz.Seilen Hcreyi renk vermek istersenizKod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$F$10" Then Range("d54").Select Range("d54").Interior.ColorIndex = 6 End Sub Seilen Hcreye Formul yazdrmak istersenizKod: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$F$10" Then Range("d4").Select Range("d54").Formula = "=A1+A3" End Sub qc = WorksheetFunction.Ceiling([e5], 0.5) sat = 9 '*********** 3 kademe bol = 3: GoSub dagit '*********** 5 kademe bol = 5: GoSub dagit '*********** 7 kademe bol = 7: GoSub dagit '*********** 12 kademe bol = 12: GoSub dagit Exit Sub dagit: sat = sat + 1 st = WorksheetFunction.RoundUp(qc / bol, 0.5) par1 = qc - ((bol - 1) * st) par: If par1 < 0.5 Then st = st - 0.5 par1 = qc - ((bol - 1) * st) End If If par1 < 0.5 Then GoTo par If par1 < st Then Cells(sat, 6) = par1 Cells(sat, 6 + (bol - 1) * 2) = st Else Cells(sat, 6) = st Cells(sat, 6 + (bol - 1) * 2) = par1 End If For x = 8 To 6 + ((bol - 2) * 2) Step 2 Cells(sat, x) = st Next x Return End Sub KTAPTAK VERLER FORMLLER BOZMADAN SLER Sub ResetModel() Range("A1").SpecialCells(xlCellTypeConstants, xlNumbers).ClearContents End Sub
KTAPTAK VERLER FORMLLER BOZMADAN SLER Sub ResetModel() Range("A1").SpecialCells(xlCellTypeConstants, xlNumbers).ClearContents End Sub Sub Optimale_Breite() Columns("A:IV").Select Range(Selection, Selection.End(xlToRight)).Select Cells.EntireColumn.AutoFit End Sub
ComboBox1.RowSource = "sayfa1!b1:b1000" OrganizeComboBox End Sub BU BLM MODL KISMINA YAZILACAK. Dim MyForm As Variant Option Base 1 ' Sub OrganizeComboBox() Dim noData, i, j, k, m As Integer Dim MyComboArray() Dim MyRevizedComboArray() Dim MyData As Range Dim SortedColl As New Collection Dim Swap1, Swap2 As Variant ' For Each MyControl In UserForms(MyForm).Controls ' i=0 j=0 k=0 ' If TypeName(MyControl) = "ComboBox" Then noData = MyControl.ListCount ReDim MyComboArray(noData) For Each MyData In Range(MyControl.RowSource) i=i+1 MyComboArray(i) = MyData Next For m = 1 To UBound(MyComboArray) If Not WorksheetFunction.IsNumber(MyComboArray(m)) Then MyComboArray(m) = UCase(MyComboArray(m)) MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") End If Next For i = 1 To UBound(MyComboArray) For j = i + 1 To UBound(MyComboArray) - 1 If MyComboArray(i) = MyComboArray(j) Then MyComboArray(i) = "" End If Next Next ' MyControl.RowSource = "" ' For i = 1 To UBound(MyComboArray) If MyComboArray(i) <> "" Then k=k+1 ReDim Preserve MyRevizedComboArray(k) MyRevizedComboArray(k) = MyComboArray(i) End If Next ' i=0 j=0 For i = 1 To UBound(MyRevizedComboArray) SortedColl.Add MyRevizedComboArray(i) Next ' 'On Error Resume Next 'For i = 1 To UBound(MyRevizedComboArray) 'MyRevizedComboArray(i) = WorksheetFunction.Small(MyRevizedComboArray, i) 'Next For i = 1 To SortedColl.Count - 1 For j = i + 1 To SortedColl.Count If SortedColl(i) > SortedColl(j) Then Swap1 = SortedColl(i) Swap2 = SortedColl(j) SortedColl.Add Swap1, before:=j SortedColl.Add Swap2, before:=i SortedColl.Remove i + 1 SortedColl.Remove j + 1 End If Next j
ComboBox1.RowSource = "sayfa1!b1:b1000" OrganizeComboBox End Sub BU BLM MODL KISMINA YAZILACAK. Dim MyForm As Variant Option Base 1 ' Sub OrganizeComboBox() Dim noData, i, j, k, m As Integer Dim MyComboArray() Dim MyRevizedComboArray() Dim MyData As Range Dim SortedColl As New Collection Dim Swap1, Swap2 As Variant ' For Each MyControl In UserForms(MyForm).Controls ' i=0 j=0 k=0 ' If TypeName(MyControl) = "ComboBox" Then noData = MyControl.ListCount ReDim MyComboArray(noData) For Each MyData In Range(MyControl.RowSource) i=i+1 MyComboArray(i) = MyData Next For m = 1 To UBound(MyComboArray) If Not WorksheetFunction.IsNumber(MyComboArray(m)) Then MyComboArray(m) = UCase(MyComboArray(m)) MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") MyComboArray(m) = Replace(MyComboArray(m), "", "") End If Next For i = 1 To UBound(MyComboArray) For j = i + 1 To UBound(MyComboArray) - 1 If MyComboArray(i) = MyComboArray(j) Then MyComboArray(i) = "" End If Next Next ' MyControl.RowSource = "" ' For i = 1 To UBound(MyComboArray) If MyComboArray(i) <> "" Then k=k+1 ReDim Preserve MyRevizedComboArray(k) MyRevizedComboArray(k) = MyComboArray(i) End If Next ' i=0 j=0 For i = 1 To UBound(MyRevizedComboArray) SortedColl.Add MyRevizedComboArray(i) Next ' 'On Error Resume Next 'For i = 1 To UBound(MyRevizedComboArray) 'MyRevizedComboArray(i) = WorksheetFunction.Small(MyRevizedComboArray, i) 'Next For i = 1 To SortedColl.Count - 1 For j = i + 1 To SortedColl.Count If SortedColl(i) > SortedColl(j) Then Swap1 = SortedColl(i) Swap2 = SortedColl(j) SortedColl.Add Swap1, before:=j SortedColl.Add Swap2, before:=i SortedColl.Remove i + 1 SortedColl.Remove j + 1 End If Next j
Private Sub CommandButton5_Click() Dim bak As Range Dim say As Integer For Each bak In Range("A1:A" & WorksheetFunction.CountA(Range("A1:A65000"))) If bak.Value = ComboBox1.Value Then MsgBox "Bu Kayt numaras bulundu." Exit Sub End If Next bak For Each bak In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000"))) If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then MsgBox "Bu isimde bir kaydnz bulundu" Exit Sub End If Next bak say = WorksheetFunction.CountA(Range("B1:B65000")) TextBox1.Value = say Cells(say + 1, 1).Value = TextBox1.Value Cells(say + 1, 2).Value = ComboBox1.Value Cells(say + 1, 3).Value = TextBox2.Value Cells(say + 1, 4).Value = TextBox3.Value Workbooks("kitap2.XLS").Save MsgBox "Verileriniz Kaydedildi", , "KAYIT" ComboBox1.RowSource = "Veri!B2:B" & say + 1 TextBox1.Value = WorksheetFunction.Count(Range("A1:A65000")) + 1 Unload UserForm1 UserForm1.Show End Sub 'BU KOD FORMA YAZILIR Private Sub UserForm_Initialize() Dim say As Integer Sheets("Veri").Select TextBox1.Locked = True If Range("B2") = "" Then say = WorksheetFunction.CountA(Range("B1:B65000")) ComboBox1.RowSource = "Veri!B2:B" & say + 1 Else say = WorksheetFunction.CountA(Range("B1:B65000")) ComboBox1.RowSource = "Veri!B2:B" & say End If TextBox1.Value = say ComboBox1.SetFocus End Sub
Private Sub CommandButton5_Click() Dim bak As Range Dim say As Integer For Each bak In Range("A1:A" & WorksheetFunction.CountA(Range("A1:A65000"))) If bak.Value = ComboBox1.Value Then MsgBox "Bu Kayt numaras bulundu." Exit Sub End If Next bak For Each bak In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000"))) If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then MsgBox "Bu isimde bir kaydnz bulundu" Exit Sub End If Next bak say = WorksheetFunction.CountA(Range("B1:B65000")) TextBox1.Value = say Cells(say + 1, 1).Value = TextBox1.Value Cells(say + 1, 2).Value = ComboBox1.Value Cells(say + 1, 3).Value = TextBox2.Value Cells(say + 1, 4).Value = TextBox3.Value Workbooks("kitap2.XLS").Save MsgBox "Verileriniz Kaydedildi", , "KAYIT" ComboBox1.RowSource = "Veri!B2:B" & say + 1 TextBox1.Value = WorksheetFunction.Count(Range("A1:A65000")) + 1 Unload UserForm1 UserForm1.Show End Sub 'BU KOD FORMA YAZILIR Private Sub UserForm_Initialize() Dim say As Integer Sheets("Veri").Select TextBox1.Locked = True If Range("B2") = "" Then say = WorksheetFunction.CountA(Range("B1:B65000")) ComboBox1.RowSource = "Veri!B2:B" & say + 1 Else say = WorksheetFunction.CountA(Range("B1:B65000")) ComboBox1.RowSource = "Veri!B2:B" & say End If TextBox1.Value = say ComboBox1.SetFocus End Sub Sub veriaktar() Sheets("sayfa1").Range("D3:D12").Copy sat = Sheets("sayfa2").Cells(65536, 2).End(xlUp).Row Sheets("sayfa2").Cells(sat + 1, 2).PasteSpecial Paste:=xlPasteValues, Transpose:=True Application.CutCopyMode = False End Sub Sub Dme1_Tklat() Selection.Copy 'seili alan kopyala Range("A:A").End(xlDown).Offset(1, 0).Select 'en son satra git ActiveSheet.Paste 'yaptr Application.CutCopyMode = False 'kopyalanlar iptal et End Sub
SON SATIRA GTRR Private Sub CommandButton1_Click() Dim alan, satrsays, sonsatr Set alan = Cells(1, 1).CurrentRegion satrsays = alan.Rows.Count sonsatr = satrsays + 1 Cells(sonsatr, 1).Select End Sub SON HCREYE GTRR Sub ActivateNextBlankDown() Range("A1").Select ActiveCell.Offset(1, 0).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop End Sub 'LABELDEN SAYFANIN VERLEN ADRESNE VERSZ SON HCREYE YAZDIRIR Private Sub Label1_Click() Range("A1").Select ActiveCell.Offset(1, 0).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ActiveCell.FormulaR1C1 = "ZIMPARALI VALYAN PROBLEM" End End Sub SON SATIRA GTRR Private Sub CommandButton1_Click() Dim alan, satrsays, sonsatr Set alan = Cells(1, 1).CurrentRegion satrsays = alan.Rows.Count sonsatr = satrsays + 1 Cells(sonsatr, 1).Select End Sub SON HCREYE GTRR Sub ActivateNextBlankDown() Range("A1").Select ActiveCell.Offset(1, 0).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop End Sub 'LABELDEN SAYFANIN VERLEN ADRESNE VERSZ SON HCREYE YAZDIRIR Private Sub Label1_Click() Range("A1").Select ActiveCell.Offset(1, 0).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ActiveCell.FormulaR1C1 = "ZIMPARALI VALYAN PROBLEM" End End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) For Each linkler In ActiveWorkbook.ActiveSheet.Hyperlinks linkler.SubAddress = Right(linkler.SubAddress, Len(linkler.SubAddress) - InStr(linkler.SubAddress, "!")) Next End Sub Sub version_number() Dim mtext mtext = "Programn Ad: " & Application.Name _ & Chr(13) & "letim Sistemi: " & _ Application.OperatingSystem & Chr(13) & _ "Version Numaras: " & Application.Version _ & Chr(13) & "Yapm Numaras: " & Application.Build MsgBox mtext End Sub
Sub SetFigures() Dim iDecimals As Integer Dim bCommas As Boolean Dim sFormat As String Dim CellRange As Range Dim TestCell As Range bCommas = False 'Change as desired Set CellRange = Selection For Each TestCell In CellRange If Abs(TestCell.Value) < 1 Then iDecimals = 5 Else iDecimals = 5 - Int(Log(Abs(TestCell.Value)) / Log(10#)) End If sFormat = "0" If bCommas Then sFormat = "#,##0" If iDecimals < 0 Then sFormat = "General" If iDecimals > 0 Then sFormat = sFormat & _ "." & String(iDecimals, "0") TestCell.NumberFormat = sFormat Next TestCell End SplitCells() Sub Sub Tstring = Selection.Value For i = 1 To Len(Tstring) If Mid(Tstring, i, 1) = "," Then z = z + 1 Next i ReDim y(z + 1) For i = 1 To Len(Tstring) If Mid(Tstring, i, 1) <> "," Then x = x & Mid(Tstring, i, 1) End If If Mid(Tstring, i, 1) = "," Then y(c) = x c=c+1 x = "" End If Next i y(z) = x For i = 0 To UBound(y) Selection.Offset(i + 1, 0).Value = y(i) Next i End Sub
Sub Test3() Dim WSH_Shell As Object Dim MyVer As String, RegKey As String Dim MySetting As Integer MyVer = Application.Version RegKey = "HKLM\Software\Microsoft\Office\" & MyVer & "\Excel\Security\AccessVBOM" Set WSH_Shell = CreateObject("WScript.Shell") WSH_Shell.RegWrite RegKey, 1, "REG_DWORD" End Sub Durumu dzeltmek iin aadaki kodu kullann. Kod: Sub PanZehir() Dim WSH_Shell As Object Dim MyVer As String, RegKey As String Dim MySetting As Integer MyVer = Application.Version RegKey = "HKLM\Software\Microsoft\Office\" & MyVer & "\Excel\Security\AccessVBOM" Set WSH_Shell = CreateObject("WScript.Shell") WSH_Shell.RegDelete RegKey End Sub [i]30 Basla = Timer 40 Cells(satr, 5) = Now() Cells(satr, 6).Value = Cells(2, 4).Value Application.Wait (Now + TimeSerial(0, 0, 5)) 'Do While Timer < Basla + 2 'DoEvents 'Loop 'Daha evvel bunu kullanmay denedim. ama ilemciyi fazla kullanyor diye kullanmaktan vazgetim.
satr = satr + 1 Simdi2 = Now() If DateDiff("n", Simdi, Simdi2) <= 4 Then GoTo 30[/i] Declare Function sndPlaySound32 Lib "winmm.dll" Alias _ "sndPlaySoundA" (ByVal lpszSoundName As String, _ ByVal uFlags As Long) As Long Sub Klang() Call sndPlaySound32("D:\Programme\ICQ\Connect.wav", 0) End Sub Declare Function sndPlaySound32 Lib "winmm.dll" _ Alias "sndPlaySoundA" (ByVal lpszSoundName _ As String, ByVal uFlags As Long) As Long Sub wav_cal() On Error Resume Next ChDir "a" If Err = 76 Then GoTo pir End pir: Call sndPlaySound32("C:\excel\warning.wav", 1) End Sub Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpzSoundName As String, ByVal uFlags As Long) As Long Sub Musique() If Application.CanPlaySounds Then Call sndPlaySound32("D:\creedenc.wav", 0) 'Changer le chemin...("D:\.....", 0) End If End Sub Sub Auto_Open() Worksheets("Sheet1").OnCalculate = "PlayIt" End Sub Sub PlayIt() If Range("A1").Value > 5 Then ExecuteExcel4Macro ("SOUND.PLAY(, ""C:\Windows\Media\Tada.wav"")") End If End Sub
Declare Function sndPlaySound32 Lib "winmm.dll" Alias _ "sndPlaySoundA" (ByVal lpszSoundName As String, _ ByVal uFlags As Long) As Long Sub Klang() Call sndPlaySound32("D:\Programme\ICQ\Connect.wav", 0) End Sub Sub PlayIt() ExecuteExcel4Macro ("SOUND.PLAY(, ""C:\Windows\Media\Tada.wav"")") End Sub Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Sub Klang() Call sndPlaySound32("D:\Programme\ICQ\Connect.wav", 0) End Sub Private Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Long, ByVal dwFlags As Long) As Long Const SND_SYNC = &H0 Const SND_ASYNC = &H1 Const SND_FILENAME = &H20000 Sub PlayWAV() WAVFile = "dogbark.wav" WAVFile = ThisWorkbook.Path & "\" & WAVFile Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME) End Sub 'Yukardaki kod ilem yaplrken almaya devam eder. Ses alarken kod ilemini durdurmak iin u kod yazlr: Call PlaySound(WAVFile, 0&, SND_SYNC Or SND_FILENAME) Public Sub gotoTMWebSite() On Error Resume Next ShellExecute 0&, vbNullString, "www.pirsa.com", vbNullString, _ vbNullString, vbNormalFocus On Error GoTo 0 End Explicit Option Sub Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" ( _ ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Private Const SW_SHOWNORMAL = 1 Sub FindAllFiles() Dim strPathToSearch As String strPathToSearch = "C:\" ShellExecute _ 0, _ "find", _ strPathToSearch, _ vbNullString, _ vbNullString, _ SW_SHOWNORMAL End Sub Sub ShowVBEHelp() Shell "c:\windows\winhelp.exe veenob3.hlp", vbNormalFocus End Sub
Sub WinExit() 'marche bien sous XP With CreateObject("Shell.Application") .ShutdownWindows End With End Sub Sub ExitWindows9598() ValRetour = Shell("C:\WINDOWS\rundll32.exe user.exe,exitwindows") End Sub Sub RedemarWindows98() ValRetour = Shell("C:\WINDOWS\Rundll32.exe shell32,SHExitWindowsEx") End Sub Excel 97 ve nceki srmlerde almaz. Public Declare Function SetTimer Lib "user32" ( _ ByVal HWnd As Long, ByVal nIDEvent As Long, _ ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Public Declare Function KillTimer Lib "user32" ( _ ByVal HWnd As Long, ByVal nIDEvent As Long) As Long Public TimerID As Long Public TimerSeconds As Single Sub StartTimer() TimerSeconds = 1 ' how often to "pop" the timer. 1'den kk olabilir. TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc) End Sub Sub EndTimer() On Error Resume Next KillTimer 0&, TimerID End Sub Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _ ByVal nIDEvent As Long, ByVal dwTimer As Long) ' Burdaki prosedr Windows tarafndan arlr. ' Timerla ilgili kodlar buraya yazlacak. End Sub Declare Function ExitWindowsEx& Lib "user32" _ (ByVal uFlags&, ByVal wReserved&) Global Global Global Global Const Const Const Const EWX_FORCE = 8 EWX_LOGOFF = 0 EWX_REBOOT = 2 EWX_SHUTDOWN = 1
Sub calistir() Dim Kapatma_Zamani As Variant Kapatma_Zamani = InputBox("Windows ne zaman kapansn?", , _ Format(Now + TimeSerial(0, 1, 0), "hh:mm:ss")) If Kapatma_Zamani = "" Then Exit Sub Application.OnTime TimeValue(Kapatma_Zamani), "Windowsu_Kapat" End Sub Sub Windowsu_Kapat() Dim LResult LResult = ExitWindowsEx(EWX_SHUTDOWN, 0&) End Sub Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags&, ByVal wReserved&) Global Global Global Global Const Const Const Const EWX_FORCE = 8 EWX_LOGOFF = 0 EWX_REBOOT = 2 EWX_SHUTDOWN = 1
Declare Function GetTickCount& Lib "kernel32" () Sub WindowsStart() saat = GetTickCount& / 1000 / 60 / 60 dakika = (saat - Int(saat)) * 60 saniye = (dakika - Int(dakika)) * 60 time1 = TimeSerial(Int(saat), Int(dakika), Int(saniye)) H = Hour(Time) - Hour(time1) M = Minute(Time) - Minute(time1) S = Second(Time) - Second(time1) WS = TimeSerial(H, M, S) MsgBox "Windows al zaman = " & WS & vbCrLf _ & "Windows alma sresi = " & time1, vbInformation, "Windows..." End Sub Private Declare Function SHShutDownDialog Lib "shell32" _ Alias "#60" (ByVal YourGuess As Long) As Long Private Sub ShutDown() SHShutDownDialog 0 End Sub Declare Function GetUserName Lib "advapi32.dll" _ Alias "GetUserNameA" (ByVal lpBuffer As String, _ nSize As Long) As Long Sub ShowUserName() Dim Buffer As String * 100 Dim BuffLen As Long BuffLen = 100 GetUserName Buffer, BuffLen MsgBox Left(Buffer, BuffLen - 1) End Sub Const HedefKlasor As String = "C:\Baylav\" Dim Klasor As Object Dim zipKlasoru As Variant Dim DosyaAdi As String Dim Tamp As String Dim RetVal As Long Set Klasor = CreateObject("Shell.Application").BrowseForFolder(0, "Klasr Seiniz !", 0, 0) If Klasor Is Nothing Then Exit Sub zipKlasoru = Klasor.Items.Item.Path DosyaAdi = Klasor.Items.Item.Name & ".zip" If Not CreateObject("Scripting.FileSystemObject").FolderExists(HedefKlasor) Then MkDir HedefKlasor End If DosyaAdi = HedefKlasor & DosyaAdi If InStr(1, DosyaAdi, " ", vbTextCompare) <> 0 Then DosyaAdi = "" & DosyaAdi & "" End If Tamp = "" & zipKlasoru & "" RetVal = Shell("C:\Program Files\Winzip\" & "Winzip32 -min -a " & DosyaAdi & " " & Tamp, vbNormalFocus) 'hata veririse Winzip32 -min -a yazan yere Winzip32 -min -r yazp sadece klasrn yerini gsterince de olabilir. If RetVal = 0 Then MsgBox "Hata Var kontrol ediniz." Exit Sub End If MsgBox "lem Tamam" End Sub
Sub MotherBoardInfo() Dim strComputerName As String Dim strNameSpace As String Dim strClassName As String Dim objWMIMboard As Object Dim objWMIService As Object Dim objWMI_Mboards As Object Dim strRet As String strComputerName = "." strNameSpace = "root\cimv2" strClassName = "Win32_BaseBoard" On Error Resume Next If Err.Number <> 0 Then MsgBox "WMI yklenmemi! Programdan klacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub On Error GoTo 0 End If Set objWMIService = GetObject("winmgmts:\\" & strComputerName & _ "\" & strNameSpace) Set objWMI_Mboards = objWMIService.ExecQuery _ ("Select * from " & strClassName) For Each objWMIMboard In objWMI_Mboards strRet = "retici Firma = " & objWMIMboard.Manufacturer & vbCrLf strRet = strRet & "Seri Numaras = " & objWMIMboard.SerialNumber MsgBox strRet, vbInformation, "Ana Kart Bilgileri (Raider )" Next End InstalledProgsByMSI() Sub Sub Dim MyOBJ As Object Dim MyProg As Variant Dim MyMsg As String On Error Resume Next If Err.Number <> 0 Then MsgBox "WMI yklenmemi! Programdan klacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub On Error GoTo 0 End If strComputer = "." Set MyOBJ = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set MSISoftware = MyOBJ.ExecQuery _ ("Select * from Win32_Product") MyMsg = MyMsg & "MSI ile yklenen programlar hakknda:" & vbCrLf For Each MyProg In MSISoftware MyMsg = MyMsg & String(50, "-") & vbCrLf MyMsg = MyMsg & "Program: " & MyProg.Name & vbCrLf MyMsg = MyMsg & "Versiyon: " & MyProg.Version & vbCrLf MyMsg = MyMsg & "retici: " & MyProg.Vendor & vbCrLf MyMsg = MyMsg & "Kurulum: " & Left(MyProg.InstallDate, 4) & "/" & _ Mid(MyProg.InstallDate, 5, 2) & "/" & _ Mid(MyProg.InstallDate, 7, 2) & vbCrLf Next MsgBox MyMsg, vbInformation, "Programlar hakknda...... (Raider )" End Sub
Sub InfoBIOS() Dim MyOBJ As Object Dim MyBios As Variant Dim MyMsg As String On Error Resume Next Set MyOBJ = GetObject("WinMgmts:").instancesOf _ ("Win32_Bios") If Err.Number <> 0 Then MsgBox "WMI yklenmemi! Programdan klacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub On Error GoTo 0 End If For Each MyBios In MyOBJ MyMsg = String(50, "-") & vbCrLf MyMsg = MyMsg & "retici Firma : " & MyBios.Manufacturer & vbCrLf MyMsg = MyMsg & "BIOS Seri Numaras : " & MyBios.SerialNumber & vbCrLf Next MsgBox MyMsg, vbInformation, "BIOS Bilgileri (Raider )" End InfoVideoController() Sub Sub Dim MyOBJ As Object Dim MyVideoController As Variant Dim MyMsg As String On Error Resume Next Set MyOBJ = GetObject("WinMgmts:").instancesOf _ ("Win32_VideoController") If Err.Number <> 0 Then MsgBox "WMI yklenmemi! Programdan klacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub On Error GoTo 0 End If For Each MyVideoController In MyOBJ MyMsg = MyMsg & "Ekran Kart bilgileri :" & vbCrLf MyMsg = MyMsg & String(50, "-") & vbCrLf MyMsg = MyMsg & "retici Firma : " & MyVideoController.AdapterCompatibility & _ " (" & MyVideoController.Caption & ")" & vbCrLf MyMsg = MyMsg & "Yatay znrlk : " & MyVideoController.CurrentHorizontalResolution & vbCrLf MyMsg = MyMsg & "Dikey znrlk : " & MyVideoController.CurrentVerticalResolution & vbCrLf MyMsg = MyMsg & "Renk kalitesi : " & MyVideoController.CurrentBitsPerPixel & " bps" & vbCrLf MyMsg = MyMsg & "Video Modu : " & MyVideoController.VideoModeDescription & vbCrLf MyMsg = MyMsg & "lemci : " & MyVideoController.VideoProcessor & vbCrLf Next MsgBox MyMsg, vbInformation, "Ekran Kart Bilgileri (Raider )" End Sub Sub InfoPointingDevices() Dim MyOBJ As Object Dim MyPtgDev As Variant Dim MyMsg As String On Error Resume Next Set MyOBJ = GetObject("WinMgmts:").instancesOf _ ("win32_pointingdevice") If Err.Number <> 0 Then MsgBox "WMI yklenmemi! Programdan klacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub On Error GoTo 0 End If For Each MyPtgDev In MyOBJ MyMsg = MyMsg & "*****************************" & vbCrLf MyMsg = MyMsg & "lemci : " & Trim(MyCPU.Name) & vbCrLf MyMsg = MyMsg & "Ad : " & MyPtgDev.Name & vbCrLf MyMsg = MyMsg & "retici : " & MyPtgDev.Manufacturer & vbCrLf MyMsg = MyMsg & "Buton adedi : " & MyPtgDev.NumberOfButtons & vbCrLf Next MsgBox MyMsg, vbInformation, "Mouse Bilgileri (Raider )" End Sub
Sub InfoNetworkAdapter() Dim MyOBJ As Object Dim MyNetworkAdapter As Variant Dim MyMsg As String On Error Resume Next Set MyOBJ = GetObject("WinMgmts:").instancesOf _ ("Win32_NetworkAdapter") If Err.Number <> 0 Then MsgBox "WMI yklenmemi! Programdan klacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub End If MyMsg = MyMsg & "Network Adaptrleri hakknda:" & vbCrLf For Each MyNetworkAdapter In MyOBJ MyMsg = MyMsg & vbCrLf MyMsg = MyMsg & "retici Firma : " & MyNetworkAdapter.Manufacturer & vbCrLf MyMsg = MyMsg & "Ad : " & MyNetworkAdapter.Name & vbCrLf MyMsg = MyMsg & "Tip : " & MyNetworkAdapter.AdapterType & vbCrLf Next MsgBox MyMsg, vbInformation, "Network Sub SysInfo() Dim MyMsg As String, oSystem As Object, Item As Object Set oSystem = GetObject("winmgmts:").instancesOf("Win32_ComputerSystem") For Each Item In oSystem MyMsg = "Bilgisayar hakknda " & vbCrLf MyMsg = MyMsg & "-------------------------------" & vbCrLf MyMsg = MyMsg & "Ad: " & item.Name & vbCrLf MyMsg = MyMsg & "Tip: " & item.SystemType & vbCrLf MyMsg = MyMsg & "retici: " & item.Manufacturer & vbCrLf MyMsg = MyMsg & "Model: " & item.Model & vbCrLf MyMsg = MyMsg & "RAM: " & item.TotalPhysicalMemory \ 1024000 & " Mb" & vbCrLf MyMsg = MyMsg & "Domain: " & item.Domain & vbCrLf MyMsg = MyMsg & "Kaytl kullanc: " & item.UserName & vbCrLf MsgBox MyMsg, vbInformation, "Sistem Bilgileri...... (Raider )" Next Set oSystem = Nothing End Sub
Dim strComputerName As String Dim strNameSpace As String Dim strClassName As String Dim OS As Object Dim objWMIService As Object Dim Osinf As Object Dim strManufacturer As String, strRegisteredUser As String, strSerialNumber As String Dim strVersionId As String, strVersionName As String strComputerName = "." strNameSpace = "root\cimv2" strClassName = "Win32_OperatingSystem" ' On Error Resume Next If Err.Number <> 0 Then MsgBox "WMI yklenmemis! Programdan ikilacak...", vbExclamation, _ "Windows Management Instrumentation" Exit Sub On Error GoTo 0 End If Set objWMIService = GetObject("winmgmts:\\" & strComputerName & "\" & strNameSpace) Set Osinf = objWMIService.ExecQuery("Select * from " & strClassName) For Each OS In Osinf strManufacturer = "retici Firma = " & OS.Manufacturer & vbCrLf strRegisteredUser = "Kayitli Kullanici = " & OS.RegisteredUser & vbCrLf strSerialNumber = "Windows Seri Numarasi = " & OS.SerialNumber & vbCrLf strVersionId = "Windows Versiyonu ID = " & OS.Version & vbCrLf strVersionName = "Windows Versiyonu = " & OS.Name strServicePack = "Gncelleme = " & OS.CSDVersion & vbCrLf strVersionName = Mid(strVersionName, 1, InStr(1, strVersionName, "|") - 1) & vbCrLf strInstallDate = "Windows kurulum tarihi = " & Left(OS.InstallDate, 4) & "/" & Mid(OS.InstallDate, 5, 2) & "/" & Mid(OS.InstallDate, 7, 2) & vbCrLf MsgBox strManufacturer & strRegisteredUser & _ strSerialNumber & strVersionId & strVersionName & strServicePack & strInstallDate, _ vbInformation, "Windows Bilgileri (Raider )" Next End Sub Sub OuvreWord() MyAppID = Shell("Winword.EXE C:\test.doc", 1) AppActivate MyAppID End Sub 'MyAppID = Shell("Winword.EXE ""C:\Mes documents\test.doc""", 1)
Dim fontName As String, i As Long, fontCount As Long, fontSize As Integer Dim stdFont As String fontSize = 0 fontSize = InputBox("Enter Sample Font Size Between 8 And 30", _ "Select Sample Font Size", 12) If fontSize = 0 Then Exit Sub If fontSize < 8 Then fontSize = 8 If fontSize > 30 Then fontSize = 30 Set FontNamesCtrl = Application.CommandBars("Formatting").FindControl(ID:=1728) If FontNamesCtrl Is Nothing Then Set FontCmdBar = Application.CommandBars.Add("TempFontNamesCtrl", _ msoBarFloating, False, True) Set FontNamesCtrl = FontCmdBar.Controls.Add(ID:=1728) End If Application.ScreenUpdating = False fontCount = FontNamesCtrl.ListCount Documents.Add stdFont = ActiveDocument.Paragraphs(1).Range.Font.Name ' add heading With ActiveDocument.Paragraphs(1).Range .Text = "Installed fonts:" End With LS 2 ' list font names and font example on every other line For i = 0 To FontNamesCtrl.ListCount - 1 fontName = FontNamesCtrl.List(i + 1) If i Mod 5 = 0 Then Application.StatusBar = "Listing font " & _ Format(i / (fontCount - 1), "0 %") & " " & _ fontName & "..." With ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count).Range .Text = fontName .Font.Name = stdFont End With LS 1 tFormula = "abcdefghijklmnopqrstuvwxyz" If Application.International(wdProductLanguageID) = 47 Then tFormula = tFormula & "" End If tFormula = tFormula & UCase(tFormula) tFormula = tFormula & "1234567890" With ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count).Range .Text = tFormula .Font.Name = fontName End With LS 2 Next i ActiveDocument.Content.Font.Size = fontSize Application.StatusBar = False If Not FontCmdBar Is Nothing Then FontCmdBar.Delete Set FontCmdBar = Nothing Set FontNamesCtrl = Nothing ActiveDocument.Saved = True Application.ScreenUpdating = True Application.ScreenRefresh End Sub Private Sub LS(lCount As Integer) ' adds lCount new paragraph(s) at the end of the document Dim i As Integer With ActiveDocument.Content For i = 1 To lCount .InsertParagraphAfter Next i End With End Sub
Sub WordAc() fName = Application.InputBox("Dosya ismi girin...", "Dosya") If fName <> 0 Then ActiveSheet.Name = fName Range("A1:E25").Copy Set objword = CreateObject("Word.Application") objword.Visible = True Set MyDoc = objword.Documents.Add(DocumentType:=wdNewBlankDocument) objword.Selection.PasteSpecial Link:=False, DataType:=10 objword.activedocument.SaveAs "C:\" & fName & ".doc" End If End Sub excelden worde aktarma yaplyor ama ben worde text olarak yaptrmak istiyorum ki word biimlendirmelerini yapabileyim.yani obje olarak deil metin ol DataType:=10 Yukardaki data tipini aadaki ile deitirin. DataType:=2 Sub worde() fName = Application.InputBox("Dosya ismi girin...", "Dosya") If fName <> 0 Then ActiveSheet.Name = fName f = InputBox("Kanc Satra Kadar Aktarsn?", "Aktarlacak Blge") Range("A1: " & f).Copy Set objword = CreateObject("Word.Application") objword.Visible = True Set MyDoc = objword.Documents.Add(DocumentType:=wdNewBlankDocu ment) objword.Selection.PasteSpecial Link:=False, DataType:=2 objword.activedocument.SaveAs "C:\" & fName & ".doc" End If Application.CutCopyMode = False End Sub Private Sub Workbook_Open() wpad = Shell("C:\Program Files\Windows NT\Accessories\wordpad.exe", vbNormalFocus) SendKeys "Excelden baka programa yazdrabiliyorum", True SendKeys "{enter}" SendKeys "Excel 'i {tab}Seviyorum", True SendKeys "{enter}" SendKeys "Yaasnnnn!!!!", True End Sub Hatta kodun sonuna printout yazp yazc kts da alnabilir. Bu kodu fikirlerinizle daha da gelitirip harikalar yaratabilirsiniz. SendKeys Tu Kodlarndan Bazlar Backspace = {bksp} caps lock = {capslock} num lock = {numlock} scroll lock = {scrolllock} insert = {ins} delete = {del} end = {end} home = {home} page up = {pgup} page down= {pgdn} sa ok = {right} sol ok = {left} alt ok = {down} st ok = {up} tab = {tab} F1 = {F1} F2 = {F2} F3 ..... Sub ResetValuesToZero2() For Each n In Worksheets("Mahmut").Range("WorkArea1") n.Value = 0 End If Next n End Sub
'J.E. McGimpsey http://www.mcgimpsey.com/excel/noprintrange.html Dim vFontArr As Variant Dim oWkSht As Worksheet Dim rNoPrintRange As Range Dim rCell As Range Dim rArea As Range Dim i As Long Dim bOldScreenUpdating As Boolean Cancel = True With Application .EnableEvents = False bOldScreenUpdating = .ScreenUpdating .ScreenUpdating = False End With For Each oWkSht In ActiveWindow.SelectedSheets On Error Resume Next Set rNoPrintRange = oWkSht.Range("NoPrintRange") On Error GoTo 0 If Not rNoPrintRange Is Nothing Then With rNoPrintRange ReDim vFontArr(1 To .Count) i=1 For Each rArea In .Areas For Each rCell In rArea With rCell vFontArr(i) = .Font.ColorIndex If .Interior.ColorIndex = xlColorIndexNone Then .Font.Color = RGB(255, 255, 255) 'white Else .Font.ColorIndex = .Interior.ColorIndex End If i=i+1 End With Next rCell Next rArea oWkSht.PrintOut i=1 For Each rArea In .Areas For Each rCell In rArea rCell.Font.ColorIndex = vFontArr(i) i=i+1 Next rCell Next rArea End With Else oWkSht.PrintOut End If Set rNoPrintRange = Nothing Next oWkSht With Application .ScreenUpdating = bOldScreenUpdating .EnableEvents = True End With End Sub
Private Sub Workbook_AddinInstall() CmdNommer End Sub Private Sub Workbook_AddinUninstall() DelNommer End Sub Public Const Nommer = "Dfinir un nom..." Sub CmdNommer() Dim cBar As CommandBar, Ctrl As CommandBarButton Set cBar = Application.CommandBars("Cell") Set Ctrl = cBar.Controls.Add(msoControlButton, ID:=878, before:=1) With Ctrl .Caption = Nommer .FaceId = 1838 .Style = msoButtonIconAndCaption End With End Sub Sub DelNommer() On Error Resume Next Application.CommandBars("Cell").Controls(Nommer).Delete End Sub X eklinde uyar penceresi Kod: Sub auto_open() Beep MsgBox "Mesaj Buraya!!", vbCritical, "nemli" End Sub Sub Test() Workbooks("pirsa.xla").IsAddin = False End Sub z = "C:\belgelerim\" Set fs = Application.FileSearch With fs .LookIn = z .Filename = "*.xls" If .Execute(SortBy:=msoSortByFileName, _ SortOrder:=msoSortOrderAscending) > 0 Then MsgBox "Toplam " & .FoundFiles.Count & _ " dosya bulundu." For I = 1 To .FoundFiles.Count ' MsgBox .FoundFiles(i) A$ = .FoundFiles(I) Next I Else MsgBox "Belirtilen Klasrde Herhangi Bir Dosya Bulunamad." End If End With Sub SentenceCase() Dim v As Variant Dim s As String Dim j As Long Dim cell As Range For Each cell In Selection.Cells If cell.HasFormula = False Then s = cell.Text v = split(s, ".") For j = 0 To UBound(v) s = Application.Trim(v(j)) s = StrConv(s, vbLowerCase) s = UCase(Left$(s, 1)) & Mid$(s, 2) v(j) = s Next cell = Application.Trim(Join(v, ". ")) End If Next End Sub
Aadaki kodu deneyin. Bu kod active sayfay yeni bir dosyaya aktarr ve o dosyay ak olan dosyanzn bulunduu klasre kaydedip kapatr. Sub kopyala() ad = ActiveWorkbook.Name adr = ActiveWorkbook.Path Workbooks.Add ad2 = ActiveWorkbook.Name Set s1 = Workbooks(ad2) Workbooks(ad).Activate ActiveSheet.Copy after:=s1.Sheets(s1.Sheets.Count) For a = 1 To s1.Sheets.Count - 1 Application.DisplayAlerts = False s1.Sheets(1).Delete Next s1.SaveAs Filename:=adr & "\" & s1.Name & ".xls" s1.Close End Sub 'Joe Was 'Make cell range font flash, x times, x fast, in x color, 'when Ctrl-z is pressed. Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed 'Make this cell range font flash! Set myCell = Range("A1:AF12") Application.DisplayStatusBar = True Application.StatusBar = "... u an flash yaz gsterisi var ltfen biraz bekleyin...! " 'Make cell font flash to this color! 'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30, 'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11, 'Gray-50% 16, Gray-25% 15, Bright Cyan 8. newColor = 3 'Make the cell range flash fast: 0.01 to slow: 0.99 fSpeed = 0.3 'Make cell flash, this many times! Do Until x = 15 'Run loop! DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = xlAutomatic Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub Sub reSetFlash() 'Re-set cell range color if edit break on color, Ctrl-r to re-set! ActiveCell.Select Selection.Interior.ColorIndex = xlNone End Sub
Sub CheckRng() If Range("B1") < Date Then If Range("B1").Font.ColorIndex = xlColorIndexAutomatic Then Range("B1").Font.Color = vbRed Else Range("B1").Font.ColorIndex = xlColorIndexAutomatic End If Else Range("B1").Font.ColorIndex = xlColorIndexAutomatic Exit Sub End If StartTimer End Sub For i = 1 To 10 ComboBox1.AddItem i Next i ile combobox n iini 1 den 10 kadar doldurdum. combobox n deeri deitii an ilgili satrdan deerleri textboxlara al aadaki gibi yaptm. Alnt: Private Sub ComboBox1_Change() TextBox1.Text = Sheets("sayfa1").Cells(4 + ComboBox1, 2) TextBox2.Text = Sheets("sayfa1").Cells(4 + ComboBox1, 3) TextBox3.Text = Sheets("sayfa1").Cells(4 + ComboBox1, 4) End Sub yukardaki 4 + ComboBox1 deki 4 seini verilerin 5. satrdan itibaren balad iin eklendi. kaydete basldnda ilgili satrdaki deiikleri yapta aadaki ekilde. Alnt: Private Sub CommandButton1_Click() Sheets("sayfa1").Cells(4 Sheets("sayfa1").Cells(4 Sheets("sayfa1").Cells(4 Sheets("sayfa1").Cells(4 End Sub yukardaki 4 lerin sebebini yukarda syledim. + + + + ComboBox1, ComboBox1, ComboBox1, ComboBox1, 2) 3) 4) 5) = TextBox1.Text = TextBox2.Text = TextBox3.Text = TextBox2.Text * TextBox3.Text
Function yas(dogum) On Error GoTo son Dim yil, ay, gun As Integer tarih = Date If dogum <> "" Then dogum = CDate(dogum) If dogum = "" Then yas = "": GoTo son: If dogum > tarih Then yas = "": GoTo son 'yil hesaplama yil = Year(tarih) - Year(dogum) If Month(tarih) < Month(dogum) Then yil = yil - 1 If Month(tarih) = Month(dogum) And Day(tarih) < Day(dogum) Then yil = yil - 1 'Ay ay = Month(tarih) - Month(dogum) If Month(tarih) <= Month(dogum) Then ay = 12 + ay If Day(tarih) < Day(dogum) Then ay = ay - 1 If ay = 12 Then ay = 0 'gn kacceker = Day((DateSerial(Year(tarih), Month(tarih), 1) - 1)) gun = Day(tarih) - Day(dogum) If Day(tarih) < Day(dogum) Then gun = kacceker - Day(dogum) + Day(tarih) yas = yil & " Yl, " & ay & " Ay, " & gun & " gn." son: If Err > 0 Then yas = "Hata" End Function Function Ya(DogumTarihi As Date) If DogumTarihi = 0 Then Ya = "Tarih Girmediniz" Else Select Case Month(Date) Case Is < Month(DogumTarihi) Ya = Year(Date) - Year(DogumTarihi) - 1 Case Is = Month(DogumTarihi) If Day(Date) >= Day(DogumTarihi) Then Ya = Year(Date) - Year(DogumTarihi) Else Ya = Year(Date) - Year(DogumTarihi) - 1 End If Case Is > Month(DogumTarihi) Ya = Year(Date) - Year(DogumTarihi) End Select End If End Function bu fonksiyona gre doum tarihinin a1 hcresinde olduunu varsayarsak forml u ekilde olacak =Ya(A1) Dim DoumGn As Date Dim Ya DoumGn = "01/01/1977" Ya = FormatNumber(DateDiff("m", DoumGn, Now) / 12, 1) If Ya < 18 Then MsgBox "Ya: " & Ya & vbLf & "18 yadan kk" Else MsgBox "Ya: " & Ya & vbLf & "18 yadan byk" End If Sub tabloyaaktar() Set s1 = Sheets("bilgi") Set s2 = Sheets("sonuc") s2.[c3:ag40].ClearContents For a = 2 To s1.[a65536].End(3).Row sat = Day(s1.Cells(a, "a")) + 2 sut = Day(s1.Cells(a, "b")) + 2 s2.Cells(sat, sut) = 1 + s2.Cells(sat, sut) Next End Sub
Sub FixArea() Dim C As Range Dim Msg$, TMP$ Msg = "Type in the range to exclude:" Set C = Application.InputBox(prompt:=Msg, Type:=8) TMP = C.NumberFormat C.NumberFormat = ";;;" ActiveSheet.Range("A1:A50").PrintPreview C.NumberFormat = TMP End Sub Bir sutun da ki en son dolu hcreye gitmenin en basit yolu (Aralarda boluk yok 'kabul edilerek) xlup 'Buna gre I stununun en son dolu olan satr Range("I65536").End(xlUp).Row 'Yazdrlacak alan ise ActiveSheet.PageSetup.PrintArea = "$A$3:$I$" & Range("I65536").End(xlUp).Row 'veya ActiveSheet.PageSetup.PrintArea = Selection.Address End Sub Sub FixArea() Dim C As Range Dim Msg$, TMP$ Msg = "Type in the range to exclude:" Set C = Application.InputBox(prompt:=Msg, Type:=8) TMP = C.NumberFormat C.NumberFormat = ";;;" ActiveSheet.Range("A1:A50").PrintPreview C.NumberFormat = TMP End Sub Sub yazalan_se() bilgi = "Yazdrmak istediiniz hcre araln girin. " bilgi = bilgi + "Size uygun olann yazmak iin silin ve yazn." + Chr$(13) + Chr$(10) bilgi = bilgi + "TAMAM'a tklayn." + Chr$(13) + Chr$(10) bilgi = bilgi + "PTAL veya ESC basarsanz btn tabloyu seersiniz." + Chr$(13) + Chr$(10) dme = "A12:K40" a$ = InputBox(bilgi, "YAZDIRMA ALANINI SEMEK", dme) ActiveSheet.PageSetup.PrintArea = a$ ActiveWindow.SelectedSheets.PrintPreview Range("A13").Select End Sub Sub Recupzone() Set zoneIMP = Range(ActiveSheet.PageSetup.PrintArea) MsgBox zoneIMP.Address() End Sub Sub PrintRpt3() With Worksheets("Sayfa1").PageSetup .CenterHorizontally = True .PrintArea = "$A$3:$F$15" .PrintTitleRows = ("$A$1:$A$2") .Orientation = xlPortrait .FitToPagesWide = 1 .FitToPagesTall = 1 End With Worksheets("Sayfa1").PrintOut End Sub If ActiveSheet.PageSetup.PrintArea = "" Then MsgBox "Yazdrma alan yok" Else MsgBox "Yazdrma Alan: " & ActiveSheet.PageSetup.PrintArea End If Private Sub Workbook_BeforePrint(Cancel As Boolean) If Cells(1, 1) <> 1 Then Cancel = True End Sub 'Bu rnek A1 hcresi 1 den farkl ise yazdrmay iptal eder
Adaki kod filter yaptn tm alanlara bakarak en az birinde seim yaplm ise sayfay gnderir aksi halde mesaj verir.. Set s1 = ActiveSheet Secilmi = False If s1.AutoFilterMode = True Then For i = 1 To s1.AutoFilter.Filters.Count If s1.AutoFilter.Filters.Item(i).On Then Secilmi = True Next i If Not Secilmi Then MsgBox "Hi Bir Szme lemi Yaplam" Cancel = True End If End If 'Tarih alannz 4. sutun ise ve siz burada mutlaka bir seim olmasn istiyorsanz o zaman dng kullanmadan unu deneyin : s1.AutoFilter.Filters.Item(4).On Then Secilmi = True '4 alanda seim yaplp yaplmadn kontrol ediyor. Private Sub Workbook_BeforePrint(Cancel As Boolean) Cancel = True MsgBox ("zgnz kt almak yasak") End Sub Private Sub Workbook_BeforePrint(Cancel As Boolean) If ActiveSheet.Name = "Sheet1" Then Cancel = True End Sub Private Sub yaz_Click() On Error Resume Next soru = MsgBox("Sayfa Yazdrlacak, nizleme Yapmak stiyor musunuz?", vbYesNo, "nizleme") If soru = vbYes Then DataAc.Hide Sheets("Print").PrintPreview DataAc.Show Range("A1").Select Else Sheets("Print").PrintOut End If End Sub Sub yazdir() ActiveSheet.PageSetup.PrintArea = "$A$2:$C$" & [a65536].End(3).Row ActiveSheet.PrintOut End Sub ActiveSheet.PageSetup.PrintArea = "$B$1:$F$50" ActiveSheet.PrintOut Copies:=1 A1 hcresindeki yazya renk ve font boyutu efektleri uygular. Sub efekt() Dim ff, a, step, i As Integer ff = 6 step = 3 For a = 1 To 30 ff = ff + step If ff > 15 Or ff < 8 Then step = -step For i = 1 To 20 [A1].Font.ColorIndex = a + 1 [A1].Font.Size = ff Next Next [A1].Font.Size = 16 End Sub Sub FormatRange() Workbooks("Kitap1").Sheets("Sayfa1").Range("A1:D5") _ .Font.Bold = True End Sub Sub ChangePrinter() Application.Dialogs(xlDialogPrinterSetup).Show End Sub Sub LanceTestImp() ValRetour = Shell("C:\WINDOWS\RUNDLL32.EXE msprint2.dll,RUNDLL_PrintTestPage", 1) End Sub
Dim rngArr() As Range, c As Range Dim i As Integer Dim j As Integer ReDim rngArr(1 To 1) For Each wsh In ActiveWorkbook.Worksheets i=i+1 If i > 1 Then ' resize array ReDim Preserve rngArr(1 To i) End If On Error Resume Next Set c = wsh.Cells.SpecialCells(xlCellTypeLastCell) If Err = 0 Then On Error GoTo 0 'Prevent empty rows Do While Application.CountA(c.EntireRow) = 0 _ And c.EntireRow.Row > 1 Set c = c.Offset(-1, 0) Loop Set rngArr(i) = wsh.Range(wsh.Range("A1"), c) End If Next wsh 'Add temp.Worksheet Set wshTemp = Sheets.Add(after:=Worksheets(Worksheets.Count)) On Error Resume Next With wshTemp For i = 1 To UBound(rngArr) If i = 1 Then Set c = .Range("A1") Else Set c = _ ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) Set c = c.Offset(2, 0).End(xlToLeft) ' skip one row End If 'Copy-paste range (prevent empty range) If Application.CountA(rngArr(i)) > 0 Then rngArr(i).Copy c End If Next i End With On Error GoTo 0 Application.CutCopyMode = False ' prevent marquies With ActiveSheet.PageSetup .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 End With ' Fit to 1 page
'Preview New Sheet ActiveWindow.SelectedSheets.PrintPreview 'Print Desired Number of Copies i = InputBox("Print how many copies?", "ExcelTips", 1) If IsNumeric(i) Then If i > 0 Then ActiveSheet.PrintOut Copies:=i End If End If 'Delete temp.Worksheet? If MsgBox("Delete the temporary worksheet?", _ vbYesNo, "ExcelTips") = vbYes Then Application.DisplayAlerts = False wshTemp.Delete Application.DisplayAlerts = True End If End Sub
Private Declare Function EnumPrintersA Lib "Winspool.drv" _ (ByVal Flags As Long, ByVal name As String, ByVal Level As Long, _ pPrinterEnum As Long, ByVal cdBuf As Long, _ pcbNeeded As Long, pcReturned As Long) As Long Private Explicit Function lstrlenA Li Option Declare Sub AutoCorrectRead() Dim oList As Variant, i As Integer With Application.AutoCorrect oList = .ReplacementList For i = 1 To UBound(oList) Cells(i, 1) = oList(i, 1) Cells(i, 2) = oList(i, 2) Next i End With End Sub Sub AutoCorrectWrite() Columns("A:B").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Range("G20").Select Dim i As Integer With Application.AutoCorrect For i = 1 To Range("a1").CurrentRegion.Rows.Count .AddReplacement Cells(i, 1), Cells(i, 2) Next i End With End Sub Option Explicit 'Mahmut Bayram 2005 Sub AutoCorrectRead() 'zum Auslesen, danach Tabelle zum Zielrechner Dim oList As Variant, i As Integer With Application.AutoCorrect oList = .ReplacementList For i = 1 To UBound(oList) Cells(i, 1) = oList(i, 1) Cells(i, 2) = oList(i, 2) Next i End With End Sub WORD ARD YAZILARINA HAREKET VERR Sub Animasyon3() ActiveSheet.Shapes("WordArt 3").Select m = 20 For i = 1 To m Selection.ShapeRange.TextEffect.PresetShape = msoTextEffectShapeCurveUp Next i For i = 1 To m Selection.ShapeRange.TextEffect.PresetShape = msoTextEffectShapeCurveDown Next i Selection.ShapeRange.TextEffect.PresetShape = msoTextEffectShapePlainText Range("a1").Select End Sub Sub Dialog_29() Application.Dialogs(xlDialogFont).Show End Sub Sub Dialog_31() Application.Dialogs(xlDialogFormatFont).Show End Sub
Sub yazitipleri() Dim SchrNr As Integer, Schriftliste As Object, Text As Variant Set Schriftliste = Application.CommandBars("formatting").FindControl(Id:=1728) Application.ScreenUpdating = False On Error Resume Next [A:D].ClearContents For SchrNr = 0 To Schriftliste.ListCount - 1 Cells(SchrNr + 1, 1).Value = Schriftliste.List(SchrNr + 1) Cells(SchrNr + 1, 2).Value = "" 'Eurosymbol Cells(SchrNr + 1, 3).Value = "abcdefghijklmnopqrstuvwxyz" Cells(SchrNr + 1, 4).Value = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Cells(SchrNr + 1, 2).Font.Name = Schriftliste.List(SchrNr + 1) Cells(SchrNr + 1, 3).Font.Name = Schriftliste.List(SchrNr + 1) Cells(SchrNr + 1, 4).Font.Name = Schriftliste.List(SchrNr + 1) Next [A:D].EntireColumn.AutoFit Application.ScreenUpdating = True ' Warnmeldung zuviele Schriften hier einstellbar: If SchrNr > 200 Then Text = Chr(13) & Chr(13) & "Achtung!" & Chr(13) & _ "Sie haben viel zu viele Schriftarten installiert" End If MsgBox " Es wurden insgesamt " & SchrNr & " Schriftarten gefunden." _ & Chr(13) & "Im Feld mit der Roten Schrift sieht man das Eurosymbol," _ & Chr(13) & " wenn die Schrift Eurofhig ist," _ & Chr(13) & " sonst nur ein Kstchen" & Text End Sub Sub Krmzbul() For X = 1 To [A65536].End(3).Row For Y = 1 To Len(Cells(X, 1)) If Cells(X, 1).Characters(Start:=Y, Length:=Y).Font.ColorIndex = 3 Then Cells(X, 2).Value = "Krmz" End If Next Next EndKOD VERLEN ADRESTEK YAZILARI YANIP SNDRR BU Sub Sub FlashFont() Dim newColor As Integer Dim myCell As Range Dim x As Integer Dim fSpeed Set myCell = Range("A1:D1") Application.DisplayStatusBar = True Application.StatusBar = "... u an flash yaz gsterisi var ltfen biraz bekleyin...! " newColor = 4 'yeil fSpeed = 0.3 Do Until x = 15 'sre DoEvents Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = newColor Loop Start = Timer Delay = Start + fSpeed Do Until Timer > Delay DoEvents myCell.Font.ColorIndex = xlAutomatic Loop x=x+1 Loop Application.StatusBar = False Application.DisplayStatusBar = Application.DisplayStatusBar End Sub
Private Sub CommandButton3_Click() Dim dsy dsy = InputBox("Ltfen LEAD TIME'a ait ayn adn giriniz?", "Lead Time Dosyas Oluturma", Format(Now, "mmmm_yyyy")) If dsy = Cancel Then Exit Sub On Error GoTo 10 MkDir "C:\LEAD TME\" & dsy Set NewBook = Workbooks.Add With NewBook .SaveAs "C:\LEAD TME\" & dsy & "\" & "Lead_time_" & dsy & ".xls" End With Windows("LEAD TME.xls").Activate Cells.Select Selection.Copy Windows("Lead_time_" & dsy & ".xls").Activate ActiveSheet.Paste Range("A2").Select Range("Z1:AG9").Select Application.CutCopyMode = False Selection.Delete Shift:=xlToLeft Range("A2").Select ActiveWorkbook.Save ActiveWorkbook.Close Windows("LEAD TME.xls").Activate Range("A2").Select ActiveWorkbook.Save Unload UserForm1 Exit Sub 10: MsgBox "Dosya ismini kontrol edip tekrar deneyiniz.", vbExclamation, "UYARI!!!!!!!" End Sub Sub Datensicherung() Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:="C:\Datensicherung.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Application.DisplayAlerts = True End Sub Sub date_backup() zaman = Application.Text(Now(), "mm-dd-yy hh-mm") isim = "Yedek" & zaman & ".XLS" ActiveWorkbook.SaveCopyAs isim End Sub Sub NeueSymbolleiste() Dim cmdB As CommandBar Set cmdB = CommandBars.Add("MyToolbar", temporary:=True) With cmdB .Left = 50 .Top = 100 .Visible = True End With End Sub Sub Dialog_43() Application.Dialogs(xlDialogNew).Show End Sub Sub Dialog_45() Application.Dialogs(xlDialogOpen).Show End Sub Sub Sayfa_Ekle() ThisWorkbook.Sheets.Add Sheets(ActiveSheet.Name).Name =sheets("sayfa1"). [a1].value End Sub Kopyalama iin aadaki kodu deneyin. visual basic kodu: -------------------------------------------------------------------------------Sub kopyala() Sheets("Sayfa1").Copy After:=Workbooks("Kitap1").Sheets(1) End Sub
Sub CreateWindow() Dim wnParent As Window Dim wnChild As Window 'make a reference to be used later Set wnParent = ActiveWindow 'create a new window that will be the smaller window wnParent.NewWindow Set wnChild = ActiveWindow 'change the size of the windows With Application wnChild.WindowState = xlNormal wnChild.Top = .Top + (.Height * 0.2) wnChild.Height = .Height * 0.4 wnChild.Left = .Left + .Width * 0.6 wnChild.Width = .Width * 0.35 wnParent.Top = 1 wnParent.Left = 1 wnParent.Height = .Height * 0.85 wnParent.Width = .Width * 0.95 End With End Sub Private Sub Workbook_NewSheet(ByVal Sh As Object) Sh.Move After:=Sheets(Sheets.Count) End Sub Dim Korunansayfalar() Korunansayfalar = Array("koru01", "koru02", "koru03", "koru04", "koru05") Krn_Dzi_vs = UBound(Korunansayfalar) + 1 ............... bu_Kit_ss = Bu_wb.Worksheets.Count If bu_Kit_ss <= Krn_Dzi_vs Then 'bu alma kitabndaki alma sayfas, diziden kk veya eitmi kontrol et.
Dim ParaStr As String Dim Lira As String, Kurus As String If Not IsNumeric(Para) Then GoTo SayiDegil ParaStr = Format(Abs(Para), "0.00") Lira = Left(ParaStr, Len(ParaStr) - 3) Kurus = Right(ParaStr, 2) ParaCevir = IIf(Para < 0, "Eksi ", "") & Cevir(Lira) & " Lira " & Cevir(Kurus) & " Kuru" Exit Function SayiDegil: ParaCevir = "GRLEN DEER SAYI DEL!" End Function Private Function Cevir(SayiStr As String) As String Dim Rakam(15) Dim c(3), Sonuc, e Birler = Array("", "bir", "iki", "", "drt", "be", "alt", "yedi", "sekiz", "dokuz") Onlar = Array("", "on", "yirmi", "otuz", "krk", "elli", "altm", "yetmi", "seksen", "doksan") Binler = Array("trilyon", "milyar", "milyon", "bin", "") SayiStr = String(15 - Len(SayiStr), "0") + SayiStr For i = 1 To 15 Rakam(i) = Val(Mid$(SayiStr, i, 1)) Next i Sonuc = "" For i = 0 To 4 c(1) = Rakam(i * 3 + 1) c(2) = Rakam(i * 3 + 2) c(3) = Rakam(i * 3 + 3) If c(1) = 0 Then e = "" ElseIf c(1) = 1 Then e = "yz" Else e = Birler(c(1)) + "yz" End If e = e + Onlar(c(2)) + Birler(c(3)) If e <> "" Then e = e + Binler(i) If (i = 3) And (e = "birbin") Then e = "bin" Sonuc = Sonuc + e Next i If Sonuc = "" Then Sonuc = "Sfr"
Cevir = UCase(Mid(Sonuc, 1, 1)) + Mid(Sonuc, 2, Len(Sonuc) - 1) End Function Sub Dialog_44() Application.Dialogs(xlDialogNewWebQuery).Show End Sub Sub ilan() yer = Worksheets("OkBil").Range("j5").Value 'yer tanmlama sihirbaz OkBil sayfasnda se j5 hcresini se MsgBox " Sayn " & yer & " pirs@1.00 Programna Ho Geldiniz!" 'mesaj ver Bana Sayn koy birletir(&) tanml yer ile birletir(&) evranz gelen-gide End Sub Private Sub UserForm_Layout() ' Von Bert Krn ' http://www.forum.excelabc.de/ Me.Move Application.Width / 2 - Me.Width / 2, Application.Height / 2 - Me.Height / 2 End Sub
A1'de tarih B1'de ka yl eklenecei olmal Sub PratikVB1() MsgBox Format(Day([A1]), "00") & "." & Format(Month([A1]), "00") & "." & Year([A1]) + [B1] End Sub Sub PratikVB2() MsgBox Day([A1]) & "." & Month([A1]) & "." & Year([A1]) + [B1] End ShowStars() Sub Sub Cells.Select Selection.Interior.ColorIndex = 1 Range("A1").Select Randomize StarWidth = 35 StarHeight = 35 For i = 1 To 10 TopPos = Rnd() * (ActiveWindow.UsableHeight - StarHeight) LeftPos = Rnd() * (ActiveWindow.UsableWidth - StarWidth) Set NewStar = ActiveSheet.Shapes.AddShape _ (msoShape4pointStar, LeftPos, TopPos, StarWidth, StarHeight) NewStar.Fill.ForeColor.SchemeColor = Int(Rnd() * 56) Application.Wait Now + TimeValue("00:00:01") DoEvents Next i Application.Wait Now + TimeValue("00:00:02") Set myShapes = Worksheets(1).Shapes For Each shp In myShapes If Left(shp.Name, 9) = "AutoShape" Then shp.Delete Application.Wait Now + TimeValue("00:00:01") End If Next Cells.Select Selection.Interior.ColorIndex = 2 Range("A1").Select End Sub
Dim Jahr As Integer Jahr = InputBox("Bitte Das Jahr 4-stellig eingeben", "Jahresabfrage", _ IIf(Month(Date) > 9, Year(Date) + 1, Year(Date))) alt = Application.SheetsInNewWorkbook 'alt auslesen Application.SheetsInNewWorkbook = 13 'verndern Workbooks.Add Application.SheetsInNewWorkbook = alt 'zurcksetzen For i = 1 To 12 Set WS = Worksheets(i) With WS.[a1:E3] .HorizontalAlignment = xlCenter .MergeCells = True .Font.Name = "Arial" .Font.Size = 20 .Font.Bold = True .Font.Italic = True .NumberFormat = "mmmm yyyy" End With WS.[a1] = DateSerial(Jahr, i, 1) WS.Name = Format(WS.[a1], "MMMM") WS.[A5:A36].NumberFormat = "DDD DD.MM.YY" WS.Columns(5).HorizontalAlignment = xlRight 'Datum eintragen For x = 0 To 30 If Month(WS.[a1] + x) = Month(WS.Cells(x + 6, 1)) Or x = 0 Then WS.Cells(x + 7, 1) = WS.[a1] + x If Weekday(WS.Cells(x + 7, 1)) = 1 Then _ Range(WS.Cells(x + 7, 1), WS.Cells(x + 7, 5)).Interior.ColorIndex = 48 If Weekday(WS.Cells(x + 7, 1)) = 7 Then _ Range(WS.Cells(x + 7, 1), WS.Cells(x + 7, 5)).Interior.ColorIndex = 15 If Weekday(WS.Cells(x + 7, 1)) = 2 Then WS.Cells(x + 7, 5) = _ "KW " & DatePart("ww", WS.Cells(x + 7, 1), vbMonday, vbFirstFourDays) WS.Cells(x + 7, 1).Borders.Weight = xlThin With Range(WS.Cells(x + 7, 2), WS.Cells(x + 7, 5)) .Borders(xlEdgeLeft).Weight = xlThin .Borders(xlEdgeTop).Weight = xlThin .Borders(xlEdgeBottom).Weight = xlThin .Borders(xlEdgeRight).Weight = xlThin End With 'Feiertage eintragen und formatieren WS.Cells(x + 7, 2) = FeiertagCH(WS.Cells(x + 7, 1)) If WS.Cells(x + 7, 2) <> "" Then If Right(WS.Cells(x + 7, 2), 1) = "*" And _ WS.Cells(x + 7, 2).Interior.ColorIndex = xlNone Then Range(WS.Cells(x + 7, 1), WS.Cells(x + 7, 3)).Interior.ColorIndex = 15 Else Range(WS.Cells(x + 7, 1), WS.Cells(x + 7, 5)).Interior.ColorIndex = 48 End If End If End If Next x Next i With Worksheets(13) .Name = "bersicht" .PageSetup.Orientation = xlLandscape With .Columns("A:F") .ColumnWidth = 19.5 ' weitere Formatierungen der Spalten End With For i = 1 To 6 .Cells(2, i) = Format(DateSerial(0, i, 1), "MMMM") .Cells(20, i) = Format(DateSerial(0, i + 6, 1), "MMMM") Range(.Cells(2, i), .Cells(19, i)).BorderAround ColorIndex:=0, Weight:=xlThin Range(.Cells(20, i), .Cells(38, i)).BorderAround ColorIndex:=0, Weight:=xlThin Next i End With End Sub Function FeiertagCH(datum As Date) Dim J As Integer Dim O As Date Dim D As Integer J = Year(datum) D = (((255 - 11 * (J Mod 19)) - 21) Mod 30) + 21 O = DateSerial(J, 3, 1) + D + (D > 48) + 6 - _ ((J + J \ 4 + D + (D > 48) + 1) Mod 7) Select Case datum Case Is = DateSerial(J, 1, 1)
Sub haftabul() Dim tarih, hafta, aralik, gun tarih = Date hafta = DatePart("ww", tarih, vbMonday, vbFirstJan1) Range("A2").Value = hafta Range("A3").Value = Weekday(tarih, vbMonday) gun = Range("A3").Value Select Case Range("A3").Value Case 1 [A4].Value = Date & " - " & Date + 6 [B3].Value = "Pazartesi" Case 2 [A4].Value = Date - 1 & " - " & Date + 5 [B3].Value = "Sal" Case 3 [A4].Value = Date - 2 & " - " & Date + 4 [B3].Value = "aramba" Case 4 [A4].Value = Date - 3 & " - " & Date + 3 [B3].Value = "Perembe" Case 5 [A4].Value = Date - 4 & " - " & Date + 2 [B3].Value = "Cuma" Case 6 [A4].Value = Date - 5 & " - " & Date + 1 [B3].Value = "Cumartesi" Case 7 [A4].Value = Date - 6 & " - " & Date [B3].Value = "Pazar" Case Else End Select aralik = Range("A4").Value MsgBox "Bugn: " & Date & " ---> Yln " & hafta & ". Haftas" _ & Chr(13) & Chr(13) & hafta & ". Hafta ---> " & aralik _ & Chr(13) & Chr(13) & "Geen Gn: " & gun End Sub Private Function PathExists(pname) As Boolean ' Eer yol varsa DORU dndrr Dim x As String On Error Resume Next x = GetAttr(pname) And 0 If Err = 0 Then PathExists = True _ Else PathExists = False End Function Sub NumberClients() Dim c As Range Dim j As Integer If Selection.Columns.Count > 1 Then MsgBox "Only select the cells you want numbered" Exit Sub End If j=0 For Each c In Selection If Not c.Rows.Hidden Then j=j+1 c.Value = j Else c.Clear End If Next c End Sub Sub Doldur() Dim i As Integer [F1].FormulaR1C1 = "=ROUND(RC[-3],2)" For i = 2 To 1000 Cells(i, 6).Select Selection.FillDown Next i End Sub
Private Declare Function CreateRoundRectRgn Lib "gdi32" _ (ByVal X1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long, _ ByVal X3 As Long, ByVal Y3 As Long) As Long Private Declare Function SetWindowRgn Lib "user32" _ (ByVal hWnd As Long, ByVal hRgn As Long, _ ByVal bRedraw As Boolean) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 'CommandButton auf der Form plazieren, da das 'x' zum schlieen 'nicht mehr angezeigt wird. Private Sub cmdEnde_Click() Unload Me End Sub Private Sub UserForm_Initialize() 'Gre der Userform Me.Width = 350: Me.Height = 350 'Position des CommandButton zum Abbrechen cmdEnde.Left = (Me.Width - cmdEnde.Width) / 3 cmdEnde.Top = Me.Height * 0.6 End Sub Private Sub UserForm_Activate() Dim x As Long, y As Long, n As Long, mWnd As Long x = Me.Width y = Me.Height n = 4000 'bei kleinem Wert nur abgerundete Ecken mWnd = FindWindow(vbNullString, Me.Name) SetWindowRgn mWnd, CreateRoundRectRgn(0, 0, x, y, n, n), True End Sub
Private Declare Function CreateRoundRectRgn Lib "gdi32" _ (ByVal X1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long, _ ByVal X3 As Long, ByVal Y3 As Long) As Long Private Declare Function SetWindowRgn Lib "user32" _ (ByVal hWnd As Long, ByVal hRgn As Long, _ ByVal bRedraw As Boolean) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 'CommandButton auf der Form plazieren, da das 'x' zum schlieen 'nicht mehr angezeigt wird. Private Sub cmdEnde_Click() Unload Me End Sub Private Sub UserForm_Initialize() 'Gre der Userform Me.Width = 350: Me.Height = 350 'Position des CommandButton zum Abbrechen cmdEnde.Left = (Me.Width - cmdEnde.Width) / 3 cmdEnde.Top = Me.Height * 0.6 End Sub Private Sub UserForm_Activate() Dim x As Long, y As Long, n As Long, mWnd As Long x = Me.Width y = Me.Height n = 4000 'bei kleinem Wert nur abgerundete Ecken mWnd = FindWindow(vbNullString, Me.Name) SetWindowRgn mWnd, CreateRoundRectRgn(0, 0, x, y, n, n), True End Sub Private Sub UserForm_Activate() On Local Error GoTo hata Show Print "kat kayna"; Printer.PaperBin Print "renk modu"; Printer.ColorMode Print "kopya says"; Printer.Copies Print "Yazcnn ismi"; Printer.DeviceName Print "src"; Printer.DriverName Print "ift ynl yazma"; Printer.Duplex Print "yataylk-dikeylik"; Printer.Orientation Print "sayfa boyutu"; Printer.PaperSize Print "kullanlan port"; Printer.Port Print "basm kalitesi"; Printer.PrintQuality Print "yazc varsaylan m"; Printer.TrackDefault Print "lekleme"; Printer.Zoom hata: MsgBox ("ykl bir yazc yok veya yaznz ak deil") End Sub Sub Test() Dim Impr Impr = Printer If IsEmpty(Impr) Then MsgBox "No Printer", vbCritical Else Application.ScreenUpdating = False Application.ThisWorkbook.Activate With Range("A1").Resize(UBound(Impr)) .Value = WorksheetFunction.Transpose(Impr) .Sort [A1] End With Columns(1).AutoFit End If End Sub
(lpFrequency As LARGE_INTEGER) As Long Declare Function QueryPerformanceCounter Lib "kernel32" _ (lpPerformanceCount As LARGE_INTEGER) As Long Type LARGE_INTEGER lowpart As Long highpart As Long End Type Sub TestHighResolutionTimer() Dim FirstCount As LARGE_INTEGER Dim SecondCount As LARGE_INTEGER Dim TimerOverhead As Long, Counter As Long QueryPerformanceCounter FirstCount QueryPerformanceCounter SecondCount TimerOverhead = SecondCount.lowpart - FirstCount.lowpart QueryPerformanceCounter FirstCount ' Procedure to time For Counter = 1 To 10000000 Next ' End procedure to time QueryPerformanceCounter SecondCount MsgBox "Timer counts: " & Format(SecondCount.lowpart FirstCount.lowpart - TimerOverhead, "#,##0") End Sub Sub GetHighResolutionTimerFrequency() Dim Freq As LARGE_INTEGER If QueryPerformanceFrequency(Freq) = 0 Then MsgBox "Your computer does not support the high performance timer" Else MsgBox "Your computer's high resolution timer frequency is " & Format(Freq.lowpart, "#,##0") & " counts per second" End If End Sub Sub Zam5() Dim i As Range For Each i In Range("D1:D1000") i = "=(RC[-1]*0.05)+RC[-1]" Next i End Sub Sub Zam10() Dim i As Range For Each i In Range("E1:E1000") i = "=(RC[-2]*0.1)+RC[-2]" Next i End Sub
Frm_Boite_Message adnda bir form oluturun ve CmdOK adnda bir komut butonu ekleyin. Declare Function GetTickCount Lib "Kernel32" () As Long Sub Minuterie(Milliseconde As Long) Dim Arret As Long Arret = GetTickCount() + Milliseconde Do While GetTickCount() < Arret DoEvents Loop End Sub Sub Decompte(Optional I As Integer = 5) Frm_Boite_Message.Show False Do While I <> 0 Frm_Boite_Message.CmdOK.Caption = I Minuterie 1000 I=I-1 Loop Unload Frm_Boite_Message End Sub Sub Test() Decompte 10 End Sub Sub timer() Application.Wait Now + TimeValue("00:00:10") MsgBox ("10 saniye geti!") End Sub Sub donen_tarih() Dim C As Range Dim i% Set C = ActiveCell For i = 1 To 2000 C = Right(C, Len(C.Value) - 1) + Left(C, 1) Application.Wait Now + TimeSerial(0, 0, 1) Next i End Sub Eer yksek performansl bir saya gerekli deilse; 1) A1 hcresinde 0-60 saniye saydktan sonra durmas iin: Kod: Sub Test1() Start = Timer Do DoEvents Finnish = Timer [a1] = Format(Finnish - Start, "00") Loop While Finnish - Start <= 60 End Sub
2) 60 saniye saydktan sonra tekrar balamas iin; Kod: Sub Test2() ResumeSub: Start = Timer Do DoEvents Finnish = Timer [a1] = Format(Finnish - Start, "00") Loop While Finnish - Start <= 60 GoTo ResumeSub: End Sub Private Sub UserForm_Activate() Application.OnTime Now + TimeValue("00:00:05"), "KillTheForm" End Sub
ThisWorkbook a yazlacak Private Sub Workbook_Open() UserForm1.Show End Sub 'Module e yazlacak Sub KapatForm1() ' zaman 10 saniye olarak ayarland Application.OnTime Now + TimeValue("00:00:10"), "KF1" End Sub Sub KF1() UserForm1.Hide UserForm2.Show End Sub 'UserForm1 kod sayfasna yazlacak Private Sub UserForm_Activate() KapatForm1 End Sub Sub tarih() Application.OnTime Now + [a1], procedure:="zaman" End Sub Sub zaman() Application.OnTime TimeValue("12:00:00"), "makro"' End Sub
eColumn.Hidden = _ ).EntireColumn.Hidden
u atayn.Kod:
n..Tabi bu yntem tam istediiniz deil ama yinede rnek olarak bulunsun.Kod:
ows).Value
od:
ha rahat alrsnz.stediinizi yanl anlam olabilirim ama bu kodlar ile daha rahat modifiye edebilirsiniz istediiniz ekle. Listbox'nzn propertiesinde columncount'da k
tei) Then
lar kullanlr. lk metot modlde, ikinci metot ise alma sayfasnn kod 'sayfasnda kullanlmalldr.
Sub CommanButton1_Click()
erli olacaktr.
e olayn kullanmalsnz. Eer Hseyin Bey'in dedii gibi gizlemiseniz o zman Activate olayn kullanmalsnz.
u !"
n wird")
":") - 1) & Chr$(13) & Chr$(13) & "Zeilennummer: " & Left(u, InStr(u, ":") - 1) & Chr$(13) & Chr$(13) & "Adresse: " & Left(t, InStr(t, ":") - 1) & Left(u, InStr(u, ":") -
Chr$(13) & Chr$(13) & "Satr Numaras: " & Left(u, InStr(u, ":") - 1) & Chr$(13) & Chr$(13) & "Hcre Adresi: " & Left(t, InStr(t, ":") - 1) & Left(u, InStr(u, ":") - 1), _
lpWindowName As String) As Long ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
ri baska bir kitaba tasimak" gibi ilk okundugunda anlasilacak sorulardan secmek cok daha hizli cevap almanizi saglar. aklinizda bulunsun.
ows).Value
7")) & ";" & CDbl(CDate("24.10.2007")) & ";" & CDbl(CDate("25.10.2007")) & ";" & _ ;" & CDbl(CDate("02.01.2008")) & ";" & CDbl(CDate("03.01.2008")) & "}"
DAY(" & Adres & ",2)=5),ISERROR(VLOOKUP(" & Adres & ",Bayramlar,1,0))),10,IF(AND(OR(WEEKDAY(" & Adres & ",2)=2,WEEKDAY(" & Adres & ",2)=4),ISERROR(VLO
archDirection:=bas)
wap(x, y)
istIndex = comb.ListIndex
eispielmappe_113.XLS"
rar birde bunu deneyin a1 hresine yazdnz rakan kadar sayfa kts alabilirsiniz
e, ByVal Y As Single)
Y As Single)
g, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
lacaktr.
" & Sheets("EVRAK DEFTER").Cells(i, 3) & "-" & Sheets("EVRAK DEFTER").Cells(i, 4) & "-" & Sheets("EVRAK DEFTER").Cells(i, 5)
e, ByVal Y As Single)
e, ByVal Y As Single)
Y As Single)
" = False
= True
Sub SaveWithBackup()
Kullanc Tanml Fonksiyonlar listesine atacaktr. Excelde fonksiyon listesini 'amak iin Forml ubuundaki fx etiketine tklayalm ve listeden Kullanc Tanml Fonksiyonla 1 hcresine yazlacak forml; =CARPIM(A1;B1) eklinde olacaktr
datevalue('" & trh2.Value & "')-1 and crkod='" & Text1 & "'order by tarih")
2005 "
2005 "
Sub yaz()
"[";HCRE("DosyaAd"))-1)
"[";HCRE("DosyaAd"))-5)
& Worksheets("Sayfa1").Range("B1")
= 64 , Sktrlm = 128")
rla/Temizle")
PathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpF
"C" BLMNE "Resim" adnda bir klasr ap iine resimleri kiilerin kendi isimleriyle kaydedin.
;NSAN!A1;EER(A1="MAYIS";MAYIS!A1;EER(A1="HAZRAN";HAZRAN!A1))))))+EER(A1="TEMMUZ";TEMMUZ!A1;EER(A1="AUSTOS";AUSTOS!A1;EER(A1="EY
n hcrede bir forml bulunmaktadr. 'Farzedelim ki hatal hcrede aadaki gibi bir forml olsun.
in ierisinde bulunduu bir toplama 'dizisini hatal olarak gsterecektir. O halde bu hcreye ya boluk deeri ya da sfr deeri atayabiliriz. Ama unutmaynz sfr deeri a
inizi Grecektir.
dbutona tkladmzda yanp snme ilemi c1 hcresinde almaya balayacaktr.Ben C1 hcresini semitim. Siz istediiniz hcreyi seebilirsiniz tabi ki.
saatini kaydettiriyorum.
ile isimli prosedr direkt olarak veya baka bir prosedrn iinden tetikleyerek 'altrn.
anc Read Only olmadan balanabilir ve Save edildii anda dier kullanclarn Save ettikleri grlebilir
Transpose:=False
0; " "; veri11; " "; veri12; " "; veri13; " "; veri14
a Visual Basic'i aarak Import etmeniz yeterli olacaktr. Artk File mensnden Make Exe komutunu tklayarak exe halinde derleyebilirsiniz.
nn A1:C500 eriminde A stununda bunu ara; bulduunda 2nci stun (B stununu)daki deeri yaz; eer A5 ile bulduun tamamyla ayn ise demek.
bilir vs.) okuyacak ve birbirleriyle XORlayp sonucu forml yazlan hcrede gsterecek.
n aklda kalmas iin anlaml olmasna dikkat edilmeli ve kullanlamayacak isimlere dikkat!).
onlara benzer. Giri deerlerini alacak, stnde ilem yapacak ve sonucunda bir deer dndrecek Excel Visual Basic Dzenleyicisini (Aralar Makro altnda yada Alt+F
deiken bir erim, tercihsel olarak MultipCells olarak dier erim fonksiyonla birlikte girecek ve fonksiyondan Long tipinde deer dnecek.
numuz
cak. Bu dosyann herhangi bir yerine imdi formlmz yazalm a sonucunda 0 yazacak
orml yazdmz hcrede #AD? hata mesaj grnr. Bu formln tanmlanamadn gsterir. Bu sorun ise eklentilerle alr. Yani Excel her aldnda belirlenen her ekl
n, Insert mensnden bir Module ekleyelim. Yukarda verilen kodlar ayn ekilde yazalm.
ein BenimMakrolarm adyla kaydedelim. Bu alma kitab src:\Documents and Settings\Kullanc Ad\Application Data\Microsoft\AddIns\ dizininde kaydedilecektir.
retleyerek Tamam butonuna basalm. Kullanlabilir eklentiler: penceresinde bizim yazdmz eklenti de grlecektir. Bunu iaretlediimizde, her zaman Excel alrken bizim
biliriz
zerine bir textbox ile command buton yerletirin. Command butona aadaki kodlar balayn. Arayacanz veriyi textbox a girerek buldurabilirsiniz.
or.
o, "RESM KAYIT")
or.
o, "RESM KAYIT")
boBox'a ift tklayp oklu seim yapmanz ve A'a tklamak yeterlidir. 'ComboBox'tan seilen resim Image'de grnr.
ceki kodda dosyada tek sayfa varsa hata verecektir, onun yerine hcrelerin tamamn sildirebilirsiniz.
m formllerini yazdrr. Yani aktif hcreye kendi stndeki, balangta myRange 'alannda belirtilen alan kadar hcrenin (rnekte 3 hcre) toplama formln yazdrr.
g As Long, ByVal wParam As Long, lParam As Any) As Long , ByVal Y2 As Long) As Long draw As Boolean) As Long
l Y As Single)
, "v" deyimi ok kompleks olduunda, IF() iinde 2 kez kullanm tercih edilebilir. rnekler:
lim. imdi Exceli kapatalm ve herhangi bir excel dosyamz aalm. Sizin 2dosyanzdan nce Hatrlatma.xls dosyasnn aldn ve gn gelen hatrlatmalar mesaj olarak
L ya da ARP.BL.TOPLA gibi fonksiyonlar neden eklememiler sanki. Bilmem anlatabildim mi dostlar? Sayglar.
Selection.Cut
yazlmtr. Textbox1 "A1" hcresine deer atyor. Textbox2 ise "A1" hcresindeki deerin biimini deitiriyor. koddaki mid formllerini biim uzunluu kadar azaltn (OE iin iki,O iin bir mid kalsn). kinci kodun yazlan biim uzunluunu dikkate alacak ekilde dahada gelitirilmesi m
d(TextBox2.Value, 3, 1)
odlne kopyala.
n "TRUE-DORU" deerini alr, aksi takdirde "FALSE-YANLI" deerini alr ve 'ses almaz. Fonksiyonun 2 argman vardr:
Sub kirmizisil()
z.
Tamsay deiken.
lue - Range("F2").Value) - Range("A500").Value) > 0, IIf(Range("I2").Value = Range("E2").Value, Range("G2").Value - Range("F2"), (Range("G2").Value - Range("F2").
'
Sheets("canlsayfa").Select
ok iinizi grr gibi geldi bana. C stununu seip Biim>Koullu Biimlendirme>eit deil>=a1 deyip biim ayarndan da rengini deitirseniz hem eit olmayan hcreyi h
" & Sheets("EVRAK DEFTER").Cells(i, 3) & "-" & Sheets("EVRAK DEFTER").Cells(i, 4) & "-" & Sheets("EVRAK DEFTER").Cells(i, 5)
rinci koddan yana kullanyorum. Vermi olduunuz kodda baz deiiklikler yaparak tek satra kadar indirdim, belki bu ksaltmadan istifade eden arkadalar olur dncesi
ng) As Boolean
e")
bir yazc aktive edilmekte, kapanrken de baka bir yazc aktive edilmektedir.
rih) - Day(hsonuilk)) / 7, 0)
s 2.1 Library" ve "Microsoft ADO Ext. 2.1 for DDL ve Security" de dzenleme 'yapabilirsiniz.
e4 sayfalarn siler
arnda A1:E10 aralndaki tm hcreler 'toplanarak, kodun yazld kitapta yine A1:E10 aralndaki hcrelere yazlrlar.
Sub dene()
Button13_Click()
atr aa telenir.
atr aa telenir.
) - CDate("00:00:01")
Formun ad - Name zellii - UserForm1 olmas ve kullanlan Excel versiyonunun 2000 veya zerinde olmas durumunda alr.)
CTR + J yi, nerme veya tamamlama iin ise CTR + ARA UBUU'nu kullanabilirsiniz
may yapmyor. Kilitli ve gizli hcreleri seerek, Dier anlamda sayfa korumay bozmadan sralama ilemini nasl yapabilirim.
elde Fonksiyonlar; "Fonksiyonlar, bamsz deiken olarak adlandrlan zel 'deerleri belirli bir srada veya yapda kullanarak hesaplamalar gerekletiren nceden tanm
ksiyonlar iinden formlara ve sayfa nesnelerine atama yapamayz, zelliklerini 'deitiremeyiz. Exceldeki TOPLA, EER, YUVARLA... tm formller yerleik fonksiyonlardr.
ksiyon_ad=[atanan deer] satryla fonksiyon ilemlerinden sonra geriye dnen 'deer belirlenir, fonksiyona atanr. rnek olarak verilen 2 saynn arpmn alan basit bir f
,TextBox3 de gstermek
e halledilir. Buna karn listboxta alnacak veri araln tanmlamak yetmez,en azndan veri saysnnda belirtilmesi gerekir. Ayrca ekteki rneide inceleyiniz.
ki D5:D34 aralnda yerini bulur ve satr deerini a deikenine atar tunlarn taranmasn salar yerine tar kayt dosyasndaki yerine tar yt dosyasndaki yerine tar ayt dosyasndaki yerine tar aki yerine tar
mandButton varsa;
inde sa tklayp modlden auto_open ve auto_close makrolarndan bu kodlar sildim ama yinede ara ubuklarnda makrolar grnmyor.
vermiiniz. Bunun yerine mennn ID zelliini kullanrsanz ngilizce-Trke-... btn versiyonlarda kodlar alr. Ayrca, menlerini zelletiren birisinin bilgisayarnda m
(Visual Basic Editor)'n kendisi Excel'in eitli yerlerinden aktive edilebilir. rnein, sayfa sekmesi zerinde farenin sa tuuna basarak, Excel'in men ubuundaki Exce
diinizde, kullanc bahsettiiniz menler aktifken bile szkonusu moduldeki makrolar listelenmez. nk o modl tpk sayfa veya UserForm modulleri gibi "Private-zel"
s...'dan seerek Toolbox'a ekleyin) ve bir "Commandbutton" yerletir. Normal 'VBE modlne aadaki kodu yaz.
userform alarak sayfadaki "A2" hcresinde yolu ile birlikte belirtilen midi 'dosyasn alacaktr.
MS Outlook da bir Office program olduu iin, Excel VBA'de MS Outlook'a referans vererek baz iler daha kolay yaplabilir.
mail adresine bir e-mail, MS Outlook ile aadaki gibi bir kodla gnderilebilir.
r programn e-mail gndermeye altna dair kullancy uyarr. Bu yama kurulu deilse, byle bir problem olmaz
erin altna gnderin ve Image nesnesinin zemin rengini istediiniz renk yapn. Bylece MultiPage nesnesinin deimeyen zemin rengini rtm olursunuz.
gerekletirebildim. Yani formatlarn deitirilmesi iin userforma bir kere tklamak gerekiyor.
iine yazlabilir.
alnmas gereken para boyutlarn girmek. yukardaki kodu ekilde grlen butonun iine yaptrn.
df document name
df document name
ldnda bu fonkisyon Kullac Tanml foksiyon listesinden karlr. Kullanc 'tanml foknsiyonlarn tm excel uygulamarnda almas iin bu dosyann .xla uzantl olarak A
iler penceresinden kaydettiimiz dosyann ismini seelim. Artk yazdmz bu 'fonksiyonlar tm Excel uygulamalarmzda kullanabiliriz. Burada grld gibi AddIns klas
xcel her altrldnda otomatik olarak alr. XLSTART klasr rnek yolu '"C:\Program Files\Microsoft Office\OFFICE11\XLSTART". stenilirse yazlan fonksiyonlar dosya
lpSubKey As String, phkResult As Long) As Long yVal lpValueName As String) As Long SubKey As String, phkResult As Long) As Long g, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long Val lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
ry.", App.Title)
sayfann kod sayfasna yaznz. alma Kitabnda ColorIndex adnda bir sayfa 'bulunmaldr.
ww.excel-lex.de.vu"
nzahl eingeben")
) & Chr(n)
tabndaki sayfalar seen ve seilen sayfaya gitmeyi salayan bir men oluturur.
a ismini deitirebilir (sayfa2 ye geebilir) ifreyi bilemezse sayfa2 ye geilemez ve sayfa ismide deitirilemez.
ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long File As String) As Long Val n2 As Long, ByVal un2 As Long) As Long
options... Even the content will be the same." & Chr(13) & Chr(13) & _
Even the content will be the same." & Chr(13) & Chr(13) & _
End Sub
r. Fonksiyon; Microsoft Excel, Access, Visual Basic ve Quick Basic 'programlarnda alr.
Option Explicit
ksiniz.
terden itibaren 6 karakter sandakine kadar TextBox1 e aktarr. Aadakileri de bu ekilde yorumlayabilirsiniz.
;" ";"*";UZUNLUK(A1)-UZUNLUK(YERNEKOY(A1;" ";"")));1)-1) olmasna neden olan ise baz adlarn 2 isimden oluabilmesidir. A1 hcresine "Mehmet Ali Ceylan" yazdnzda B1 hcresinde "Mehmet Ali" yazldn grebilirsiniz.
exceldeki gibi nasl iki yana yaslayabilirim. yardmc olacak stadlara imdiden teekkr ederim .( Birinci sorunuz iin textboxa aadaki kodu yazn. Bu arada properties p
IT GNCELLEND"
N BU KART KODUNUN ALTINDA PERSONEL KARTLARI AINIZ, DEVAM ETMEK STEDNZDEN EMN MSNZ?", vbQuestion + vbYesNo
Sub Ekle_Nesne_IstedigimiSil()
z ve File Already Exists yani Dosya Zaten Var uyars gelir.True yazarsak,eski bilgiler silinir,yenileri yazlr.Bu rnekte bilgi yazma ksmna yer vermedik.Bilgi yazma ksm
a Unicode
True)
angle.Top, True)
Operation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
ger
t16)
Val y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer)
pRect32) As Long
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
mmandButton3) yapamazsnz.(*)
lmasn ve bu srada "Bip" sesiyle kullancy ikaz eden ufak bir alma. UserForm 'modlne yerletirilecek kodlar:
Application.GoTo Reference:="test"
adm yle bir koruma altna alabilirsiniz.Kodlar ThisWorkbooka yazn.Kayt ifresi:xxrt Kod:
buradan verilir.)
Delete Shift:=xlUp
Delete Shift:=xlUp
buradan verilir.)
'*************************
Sub yazdirmaalani()
mesaj verir..
unu deneyin :
mmmm_yyyy"))
anml yer ile birletir(&) evranz gelen-giden evrak defterine kayt edilmitir.
x'nzn propertiesinde columncount'da ka kolon olacaksa ona gre ayarlayn nce.. galiba 40..
ve listeden Kullanc Tanml Fonksiyonlar seeneini seelim. Fonksiyonlar listesinde CARPIM fonksiyonunu greceiz. Tamam tuuna 'basarak fonksiyonumuzu normal ex
MaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
AUSTOS";AUSTOS!A1;EER(A1="EYLL";EYLL!A1;EER(A1="EKM";EKM!A1;EER(A1="KASIM";KASIM!A1;EER(A1="ARALIK";ARALIK!A1))))))
abiliriz. Ama unutmaynz sfr deeri arpma 'ileminde sorun kartabilir. O halde boluk deeri atayalm. Yukardaki forml aadaki gibi deitiriniz.
sini (Aralar Makro altnda yada Alt+F11 ksayol) aalm. Insert mensnden bir Module ekleyelim, bu projemize yeni bir modl ekler.
ecek.
i Excel her aldnda belirlenen her eklenti Excel ile birlikte yklenir.
ek buldurabilirsiniz.
Sheets("canlsayfa").Select
eitirseniz hem eit olmayan hcreyi hem de toplamn eit olup olmadn grrsnz. stelik Tamam'a tklama olmadan hemen dzeltme yapabilirsiniz.
Resimleri de s
nmyor.
ni zelletiren birisinin bilgisayarnda men ubuunda 6nc men "Tools-Aralar" mens olmayabilir ve bu nedenle de yine hata verebilir. Bu yzden menlere her zama
asarak, Excel'in men ubuundaki Excel ikonunun zerinde farenin sa tuuna basarak, normal yollarlla menlerden, Visual Basic ara ubuundan, ....
as iin bu dosyann .xla uzantl olarak AddIns klasrne kaydetmek yeterlidir. Dosya -> Farkl Kaydet... mensne tklayalm ve Farkl 'Kaydet penceresindeki Kayt tr b
iriz. Burada grld gibi AddIns klasrne kaydedilen .xla dosyalarndaki fonksiyonlar Excel tarafndan Kullanc Tanml Fonksiyonlar 'olarak kabul edilmektedir.
T". stenilirse yazlan fonksiyonlar dosyas (.xls olmas daha uygun olur) bu klasre atlarak yine tm uygulamalarda kullanlabilmesi 'salanr. Bu konunun daha iyi alalma
a ksmna yer vermedik.Bilgi yazma ksm makalemizin ikinci ksmnda,Alt FSO blmnde bulunmaktadr.
***********************
Range("A1:B16).Sele
IK";ARALIK!A1))))))
ekler.
Sub bosdolurenklendir()
dzeltme yapabilirsiniz.
verebilir. Bu yzden menlere her zaman ID'leri ile referans vermekte fayda vardr. ara ubuundan, ....
arkl 'Kaydet penceresindeki Kayt tr blmnden "Microsoft Office Excel Eklentisi (*.xla)" seeneine tklayalm. Kayt yeri otomatik olarak "AddIns" klasr olarak dei
i 'salanr. Bu konunun daha iyi alalmas iin basit bir hatrlatma program yapalm. Hatrlatma dosyamz excel her altrldnda excel ile birlikte alacak ve gn gelen
Range("A1:B16).Select
For j = 1 To Shapes.Count