I want the code for the command button that can copy the text in a cell of Sheet1 to the text box of Sheet2. Or the command button to move data from the cells in a Column of Sheet1 to the Row of Sheet2. Please help me if somebody knows the coding.!!
I want the code for the command button that can copy the text in a cell of Sheet1 to the text box of Sheet2. Or the command button to move data from the cells in a Column of Sheet1 to the Row of Sheet2. Please help me if somebody knows the coding.!!
Desktop * Athlon X2 4200 | 2048M RAM | 160G HD | 7600GT
MacMini * G4 1.33GHz | 512M RAM | 40G HD | Radeon 9200
Laptop * Sempron 2800 | 512M RAM | 60G HD
PDA * Dell Axim x51 | 128M Internal | 256M SD Card
I think that this code should work for you..
Sheet1 has the text box (let it be txtOut) and the Sheet2 has to the cell (let it be B4) that has to be copied. Also the command button be cmdCopy. The code should be like this :
Private Sub cmdCopy_Click()
Sheet1.txtOut.Text = ""
Sheet1.txtOut.Text = Sheet2.Range("B4").Value
End Sub
I think that code mentioned by the "Zecho" should work. I have not checked that code personally but the logic used seems to be correct. Just make sure that you are giving the Exact cell that has to copied in the coding. Otherwise you will get the unexpected answer. I think that you can use the same logic for copying the columns and rows to the other sheets.
You can also use the Macro for copying the Columns of Sheet1 to the Rows of Sheet2 by using the following code :
Sub Macro1()
Sheets("Sheet1").Select
Range("B34:B41").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True
Sheets("Sheet1").Select
Range("B34:B41").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub
I think that the following code will also help you to get the desired answer :
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= False, Transpose:=True
If the other code is not working you can try this. According to me it should work properly.
If you want to copy the duplicate text from one textbox on a form to another textbox using the Command Button, you can use the following code :
me.[ControlB] = me.[ControlA]
which assumes that names of the controls are ControlA and ControlB.
You have to place this event code on the OnClick event of your command button, so that it can copy the text from ControlA to ControlB.
Bookmarks