• DİKKAT

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

CommantButtonu Başka Sayfadan Çalıştırmak

Katılım
9 Ekim 2009
Mesajlar
1,626
Excel Vers. ve Dili
türkçe
2003
Ekteki örnek dosyada a4 sayfasında bulunan butonu a5 sayfasınataşıdığımda makroda hata veriyo bunu nasıl düzeltebiliriz ?.
 

Ekli dosyalar

Merhaba,
Kod:
[B][COLOR=Red]Sayfa1[/COLOR][/B]

yazan yerleri,
Kod:
Sayfa2
ile değiştiriniz. İyi akşamlar.
 
Sayın Dentex benim amacım a4 sayfasını a1 den yönetmek.Yani a5 sayfasında butona bastığımda a4 sayfasında işlem yapacak
 
Hem A4 hem A5'te mi işlem yapmalı?
 
a5 sayfasına bir button ekleyip kodları içine yapıştırıp denermisiniz.

Kod:
Private Sub CommandButton1_Click()
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
Application.ScreenUpdating = False
Sayfa1.Activate
Sayfa1.UsedRange.Rows.AutoFit
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
Sayfa2.Activate
Application.ScreenUpdating = True
End Sub
 
Teşekkürler Sayın Dentex ,butona basmadan a5 sayfasından veri girdiğim zaman a4 sayfasındaki satır otamatik olarak genişleyebilir mi?
 
a5 sayfasında nereye veri gireceksiniz?
 
a1 hücresine veri girilecek.birde anlamadığım nokta şu a4 sayfasında her satırmı genişliyo .yoksa belirli satırlar mı?
 
A5 sayfasının kod bölümüne yapıştırıp deneyiniz.

Kod:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("a1")) Is Nothing Then Exit Sub

Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
Application.ScreenUpdating = False
Sayfa1.Activate
Sayfa1.UsedRange.Rows.AutoFit
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
Sayfa2.Activate
Application.ScreenUpdating = True
End Sub
 
Sayın Dentex hocam muhteşemsiniz ya .Acaba bu genişlemeyi istenilen satıra siz mi ayarlıyonuz.birde fazla veri girdiğim zaman en alt satırın dip genişliği neden biraz daha açık acaba
 
Sayın Dentex birde a1 hücresinden verileri sildiğimde açılan satır eski halini almıyo ?
 
Sayın ormann ben kodun işlevini tam olarak incelemedim. Ancak istediğiniz sayfadan başka bir sayfa için çalışmasını sağladım. İlk halinde bu söyledğinizi yapıyor muydu kod. Zaten içeriğiyle oynamadım
 
en son yapmış olduğunuz kod çalıştı fakat bazen çalışmıyo
 
Geri
Üst