Hola! te mando un ejemplo, para probarlo en un form agrega un msflexgrid y dos textbox sin cambiarle los nombres por defecto, luego copia el codigo que te paso. Probalo y me decis.Saludos
Option Explicit
Private Sub Form_Load()
' Ocultar los textbox
Text1.Visible = False
Text1.BorderStyle = 0 'None
Text2.Visible = False
Text2.BorderStyle = 0 'None
'Configurar el Grid para el ejemplo
With MSFlexGrid1
.Cols = 4
.Rows = 11
.TextMatrix(0, 2) = "Valores 1"
.TextMatrix(0, 3) = "Valores 2"
End With
End Sub
Private Sub MSFlexGrid1_GotFocus()
Text1.Visible = False
Text2.Visible = False
End Sub
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
With MSFlexGrid1
Select Case .ColSel
Case 2
Text2.Visible = False
Text1.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth - 8, .CellHeight - 8
Text1.Visible = True
If .TextMatrix(.RowSel, .ColSel) <> "" Then
Text1.Text = .TextMatrix(.RowSel, .ColSel)
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Else
Text1.Text = Chr(KeyAscii)
Text1.SelStart = 1
End If
Text1.SetFocus
Case 3
Text1.Visible = False
Text2.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth - 8, .CellHeight - 8
Text2.Visible = True
If .TextMatrix(.RowSel, .ColSel) <> "" Then
Text2.Text = .TextMatrix(.RowSel, .ColSel)
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
Else
Text2.Text = Chr(KeyAscii)
Text2.SelStart = 1
End If
Text2.SetFocus
End Select
End With
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
With MSFlexGrid1
.TextMatrix(.RowSel, 2) = Text1.Text
.SetFocus
End With
KeyAscii = 0
End If
If KeyAscii = vbKeyEscape Then
MSFlexGrid1.SetFocus
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
With MSFlexGrid1
.TextMatrix(.RowSel, 3) = Text2.Text
.SetFocus
End With
KeyAscii = 0
End If
If KeyAscii = vbKeyEscape Then
MSFlexGrid1.SetFocus
KeyAscii = 0
End If
End Sub