Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to Copy Text in a cell using the Command Button?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 06-01-2010
Member
 
Join Date: Aug 2006
Posts: 155
How to Copy Text in a cell using the Command Button?
  

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
Reply With Quote
  #2  
Old 06-01-2010
Member
 
Join Date: May 2008
Posts: 2,290
Re: How to Copy Text in a cell using the Command Button?

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
Reply With Quote
  #3  
Old 06-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How to Copy Text in a cell using the Command Button?

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.
Reply With Quote
  #4  
Old 06-01-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: How to Copy Text in a cell using the Command Button?

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
Reply With Quote
  #5  
Old 06-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
Re: How to Copy Text in a cell using the Command Button?

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.
Reply With Quote
  #6  
Old 06-01-2010
Member
 
Join Date: Apr 2008
Posts: 2,000
Re: How to Copy Text in a cell using the Command Button?

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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Copy Text in a cell using the Command Button?"
Thread Thread Starter Forum Replies Last Post
How to use VLOOKUP IF in cell that contains Text RYAN$ MS Office Support 2 11-01-2012 03:06 PM
copy a hyperlink to another cell aya2002 Windows Software 2 21-03-2010 03:37 AM
Auto-populate a MS Word table cell with text from a diff cell? dreamrthts Windows Software 5 23-03-2009 10:39 PM
Copy Text from One Cell to Another in Microsoft Excel without copy & paste Computer_Freak Tips & Tweaks 0 18-03-2009 10:00 PM
Command prompt "COPY" command not working in brand new Windows Vis CMD COPY command not working in Vista Vista Help 7 06-02-2008 01:50 AM


All times are GMT +5.5. The time now is 07:46 AM.