• DİKKAT

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

Makro ile otamatik satır genişletme kod hatası

Katılım
9 Ekim 2009
Mesajlar
1,626
Excel Vers. ve Dili
türkçe
2003
Sayın arkadaşlar ekteki örnek dosyanın içerisinde bulunan aşağıdaki makroda sayfa1 a5 satırındaki hücreleri birleştirdiğimde sayda2 de a1 hücresine veri girdiğim zaman veya verileri sildiğim zaman hata mesajı alıyorum yardımcı olurmusunz?

Public Sub AutoFitMergedCellRowHeight()
Sheets("Sayfa1").Rows("5:5").EntireRow.AutoFit
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
For Each i In Sayfa1.UsedRange
If i.MergeCells Then
i.Select
With ActiveCell.MergeArea
If .Rows.Count = 1 And .WrapText = True Then
CurrentRowHeight = .RowHeight
ActiveCellWidth = ActiveCell.ColumnWidth
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth + MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = ActiveCellWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, CurrentRowHeight, PossNewRowHeight)
End If
End With
Exit For
End If
Next i

End Sub
 

Ekli dosyalar

Merhaba, kodlara aşağıdaki satırı ileve ediniz.

Kod:
Public Sub AutoFitMergedCellRowHeight()
[B]On Error Resume Next[/B]
Sheets("Sayfa1").Rows("5:5").EntireRow.AutoFit
kodların devamı...
 
Sayın Hüseyin dediğiniz şekilde yaptım hata vermedi fakat satır genişlemesi olmadı
 
başka bir yolu yok mu hocam
 
Geri
Üst