• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Formatlama

Katılım
4 Nisan 2011
Mesajlar
6
Excel Vers. ve Dili
VBA
Merhaba bana yardımcı olabilir misiniz?
VBAde kod yazdım.Excelde de istediğim şekilde çıkmasını istiyorum $569 yazısının.VBAde ThisWorkbook sayfasının içine sadece aşağıdaki kodu yazmam yeterli değil mi?Sürekli ilk satırla ilgili sorun veriyor.

With ActiveWorkbook.Worksheets(“Sayfa1”).Range("A1")

Font.Bold = True
Font.Size = 14
Font.Name = "Garamond"
Font.Italic = True
Font.ColorIndex = 5
Font.HorizontalAlignment = xlLeft
Interior.ColorIndex = 37
InsertIndent 1
NumberFormat = "$569"

End With
 
With ActiveWorkbook.Worksheets(“Sayfa1”).Range("A1")

Font.Bold = True
Font.Size = 14
Font.Name = "Garamond"
Font.Italic = True
Font.ColorIndex = 5
Font.HorizontalAlignment = xlLeft
Font.Interior.ColorIndex = 37
Font.InsertIndent 1
Font.NumberFormat = "$569"

End With
 
Selamlar,

Font kelimesinden önce bir nokta yazmanız gerekiyor.

Kod:
.Font.Bold = True
 
With ActiveWorkbook.Worksheets(“Sayfa1”).Range("A1")

Font.Bold = True
Font.Size = 14
Font.Name = "Garamond"
Font.Italic = True
Font.ColorIndex = 5
Font.HorizontalAlignment = xlLeft
Font.Interior.ColorIndex = 37
Font.InsertIndent 1
Font.NumberFormat = "$569"

End With

Şöyle denediniz mi?

Kod:
   With ActiveWorkbook.Worksheets("Sayfa1").Range("A1")

.Font.Bold = True
.Font.Size = 14
.Font.Name = "Garamond"
.Font.Italic = True
.Font.ColorIndex = 5
.HorizontalAlignment = xlLeft
.Interior.ColorIndex = 37
.InsertIndent 1
.NumberFormat = "$569"

End With

İlk satır; hata nedeni: “Sayfa1” şöyle olmalı: "Sayfa1"
 
Son düzenleme:
Korhan Ayhan ve Husgvarna çok teşekkür ederim.Dediğiniz gibi denedim ama run ettiğimde hata veriyor hala. With olan satırı göstererek compile error:Invalid Outside Procedure diyor.Hala neden olduğunu anlayamadım
 
Selamlar,

Bu durumda uyguladığınız dosyanızın bir örneğini eklerseniz kontrol etme şansımız olabilir.
 
Merhaba,
Excel olarak yollayamıyorum kabul etmiyor.Ama rar olarak yollamayı denedim.Yüklendi dedi ama yine gözükmüyor galiba.
Daha yeni VBA öğreniyorum.Yaptığım tek sey Excel'de VBA'i açtıktan sonra ThisWorkbook'un içine aşağıdaki kodu yazıp çalıştırmaktı.Bunu yapınca da dediğim gibi hata veriyor.Başka birşeyler daha mı yapmam gerekiyor acaba?

With ActiveWorkbook.Worksheets("Sayfa1").Range("A1")

.Font.Bold = True
.Font.Size = 14
.Font.Name = "Garamond"
.Font.Italic = True
.Font.ColorIndex = 5
.HorizontalAlignment = xlLeft
.Interior.ColorIndex = 37
.InsertIndent 1
.NumberFormat = "$569"

End With
 
Selamlar,

Kodu bu haliyle ThisWorkbook bölümüne uygularsanız çalışmaz. Bir olayın (event) altına uygulamanız gerekiyor.

Örnek 1 ; (Dosyanın açılışında çalışması için)

Kod:
Option Explicit
 
Private Sub Workbook_Open()
    With ActiveWorkbook.Worksheets("Sayfa1").Range("A1")
 
    .Font.Bold = True
    .Font.Size = 14
    .Font.Name = "Garamond"
    .Font.Italic = True
    .Font.ColorIndex = 5
    .HorizontalAlignment = xlLeft
    .Interior.ColorIndex = 37
    .InsertIndent 1
    .NumberFormat = "$569"
 
    End With
End Sub


Örnek 2 ; (Sayfada bir hücre seçinçe çalışması için)

Kod:
Option Explicit
 
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    With ActiveWorkbook.Worksheets("Sayfa1").Range("A1")
 
    .Font.Bold = True
    .Font.Size = 14
    .Font.Name = "Garamond"
    .Font.Italic = True
    .Font.ColorIndex = 5
    .HorizontalAlignment = xlLeft
    .Interior.ColorIndex = 37
    .InsertIndent 1
    .NumberFormat = "$569"
 
    End With
End Sub
 
Geri
Üst