Excel Makro (VBA) Program Yazma – Excel’de rakamlara basıldığında

 

ÖRNEK KODLAR AŞAĞIDA

Public sat As Integer
Public sut As Integer
Public run As Boolean

Private Sub CommandButton1_Click()
End
End Sub

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Static x, y, SUTUNSAYISI
On Error Resume Next
TextBox2.Enabled = False
If run Then
x = sat
y = sut
SUTUNSAYISI = Val(TextBox2.Text)
run = False
End If

If IsEmpty(x) Then x = 2
If IsEmpty(y) Then y = 2

If KeyAscii < 48 Or KeyAscii > 57 Then
If KeyAscii = vbKeySpace Then
GoTo devam
End If
KeyAscii = 0
Exit Sub
End If
devam:
Cells(x, y).Value = Chr(KeyAscii)
y = y + 1
Cells(x, y).Activate

If y > SUTUNSAYISI Then
y = 2
y = y + 1
x = x + 1
End If
TextBox1.Text = “”
UserForm1.Caption = “Satır= ” & x & ” , ” & ” Sütun= ” & y
End Sub

Private Sub UserForm_Activate()
On Error Resume Next
run = True
sat = ActiveCell.Row
sut = ActiveCell.Column
TextBox2.Text = Range(“a1”).End(xlToRight).Column
‘sat = InputBox(“Başlangıç Satır Değerini girin”, “IDAkademi”, 2)
‘sut = InputBox(“Başlangıç SÜTUN Değerini girin”, “IDAkademi”, 2)
TextBox1.SetFocus
End Sub

 

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir