belli Digit sayısıdından fazla ise alan kodu ekleme

Kemal Demir

Özel Üye
Katılım
29 Temmuz 2004
Mesajlar
2,108
Gunaydın arkadaslar.

elimde ki dodda
ile bağlı olarak b kolonundaki telefon numaralarına alan kodu ekliyor

yalnız
alan kodu eklemesi için bir şart koymam gerekiyor

1.)7 digitten fazla olmayacak azda olmayacak.
7 digitten fazla olanlara alan kodu eklemeyecel

**kod***
Sub alankoduekle()
For C = 2 To 13
If Cells(C, 1).Value = "İZMİR" Then
Cells(C, 2).Value = "232" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "ANKARA" Then
Cells(C, 2).Value = "312" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "BURSA" Then
Cells(C, 2).Value = "224" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "SAMSUN" Then
Cells(C, 2).Value = "362" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "ADANA" Then
Cells(C, 2).Value = "322" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "ANTALYA" Then
Cells(C, 2).Value = "242" & Cells(C, 2).Value
End If
Cells(C, 2).NumberFormat = "(###) ### ## ##"
Next
End Sub
****************************************
buraya nasıl bir ilave yapabiliriz.

Yardımcı olursanız sevinirim.

İyi Çalışmalar.
 

Kemal Demir

Özel Üye
Katılım
29 Temmuz 2004
Mesajlar
2,108
Digit Sayısını sorgulayacak bir koda ihtiyacım var 7 den fazla ıse yukarıdaki donuler gerçekleşmesin aşağı isede gerçekleşmesin
Sadece digit sayısı 7 ise gerçekleşssin.
 

Levent Menteşoğlu

Administrator
Yönetici
Admin
Katılım
13 Ekim 2004
Mesajlar
16,057
Excel Vers. ve Dili
Excel 2010-32 bit-Türkçe
Excel 365 -32 bit-Türkçe
Aşağıdaki gibi deneyin.

[vb:1:312d47b832]Sub alankoduekle()
For C = 2 To 13
if len(cells(C,1))=7 then
If Cells(C, 1).Value = "İZMİR" Then
Cells(C, 2).Value = "232" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "ANKARA" Then
Cells(C, 2).Value = "312" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "BURSA" Then
Cells(C, 2).Value = "224" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "SAMSUN" Then
Cells(C, 2).Value = "362" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "ADANA" Then
Cells(C, 2).Value = "322" & Cells(C, 2).Value
End If
If Cells(C, 1).Value = "ANTALYA" Then
Cells(C, 2).Value = "242" & Cells(C, 2).Value
End If
Cells(C, 2).NumberFormat = "(###) ### ## ##"
Next
end if
End Sub
[/vb:1:312d47b832]
 

Kemal Demir

Özel Üye
Katılım
29 Temmuz 2004
Mesajlar
2,108
Sn leventm Çok Teşekkur Ederim.
 
Üst