0

I've two sheets one of which I'm writing a code, the problem comes when executing line (16 and up) where I'm trying to copy a cell content to text box in the other sheet.

The first sheet name is "Master Card"
The second sheet name is "تسجيل"

Private Sub CommandButton1_Click()

    LR1 = Range("T" & Rows.Count).End(xlUp).Row - 5
    Dim I As Integer
    If Range("T6").Value = "" Then
        MsgBox "Pls insert employees ID Starting from cell T6", vbOKOnly
    Else
        Range("T6").Select
        For I = 1 To LR1
            ActiveCell.Copy
            Range("B3").Select
            Selection.PasteSpecial xlPasteValues
            ActiveSheet.PrintOut copies:=1
            Range("B3").Select
            selection.copy
            Sheets("تسجيل").Select
            TextBox1.paste
            ActiveSheet.PrintOut copies:=1
            Sheets("Master Card").Select
            Range("T6").Select
            ActiveCell.Offset(I, 0).Select
        Next I
    End If

End Sub
GSerg
  • 76,472
  • 17
  • 159
  • 346
  • 5
    The issue may be due to a combination of **unqualified objects** & the use of `.Select` & `.Active` that are present in your code. Please see [this on `Select`](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) and [this on `unqualified ranges`](https://stackoverflow.com/questions/18962890/2-ways-for-clearcontents-on-vba-excel-but-1-work-fine-why) – urdearboy Mar 16 '21 at 18:51
  • `the problem` - which problem? – GSerg Mar 16 '21 at 19:16
  • You should do `Sheets("تسجيل").Shapes("TextBox 1").TextFrame.Characters.Text = Sheets("Master Card").Range("B3").Text` This is assuming you're using this kind of text box and not one of the other kinds of text box. (Excel has so many kinds of text boxes LOL) – Toddleson Mar 16 '21 at 21:03

0 Answers0