Copying specific cells

Closed
andrewrp1 Posts 1 Registration date Thursday September 20, 2018 Status Member Last seen September 20, 2018 - Updated on Sep 20, 2018 at 05:24 PM
 Blocked Profile - Sep 20, 2018 at 05:12 PM
Hello,

I am trying to use a command button to copy information from specific cells in sheet 1 to a excel form I made in sheet 2. The cells are not the same from sheet 1 to sheet 2. Is there a way to do that with a simple type of command that can be reused in succession for additional cell information that I would need to copy to the form?

Example "G2" on sheet 1 would be copied on "J9" on sheet 2. Then so on....

1 response

You are correct, you hard code the relationship in the placement of the entry.

Thecellvalue = ThisWorkbook.Worksheets(WSA).Range("G2").value
ThisWorkbook.Worksheets(WSB).Select
ThisWorkbook.Worksheets(WSB).Range("J9").value = ThecellValue



Or, you could build a multideminsional array like:

cellvalue(0)="G2,J9"
cellvalue(1)="G3,J8"
cellvalue(2)="G1,J12"



and loop through each element in the array, parsing the "to" and "from" cells from the array entries. Now just build a loop from 1 to how ever many numbers of entries there are, and loop it!



0