Set the value of the current row and column to a cell

  • I am trying to set the value of the current row and column to cells(2,1)


    Code
    Private Sub CommandButton1_Click()
        Sheets("Enter").Cells(2, 1) = Sheets("Enter").Cells(Target.Row, Target.Column)
    End Sub


    Error Code:


    Code
    Object Required
  • Re: Set the value of the current row and column to a cell


    So this is a command button on the sheet Enter and you want it to take the value of the cell that is selected and copy that into cell A2. If not please explain further. Target is usually passed to a worksheet event like selection change or change.


    Try this code. If the button is on sheet Enter and the cell you want the value from is the active cell then it will give you the value from that cell.




    Code
    Private Sub CommandButton1_Click()
        Sheets("Enter").Cells(2, 1) = ActiveCell.Value
    End Sub

    Bruce :cool:

  • Re: Set the value of the current row and column to a cell


    Quote from Philosophaie;736916

    How do you know the ActiveCell row and column?


    I don't know what you are trying to do, I said that in my other post, I made a guess to try and help you.


    What are you trying to do?
    What sheet is the command button on?
    What do you hope to accomplish with the information you are trying to get by pushing the button?

    Bruce :cool:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!