mercredi 25 février 2015

Using VBS code and a macro button to copy, lookup and paste in excel 2013

I hope someone can help me, I need a button in Excel 2013 to carry out the following commands:


1) In "Sheet1" the range "A2:I2" is copied.


2) The value in A2 is looked up to determine an appropriate worksheet, which is activated and the copied range is pasted into the next available row in the range of B:J.


3) Once the data is pasted, the value of the cell in column A in the pasted row of the activated worksheet is returned to the user.


So for example:


When I input into Sheet1.A2 "technical report", and click on my button, it would copy Sheet1.A2:I2, then lookup the worksheet called "TEC", activate it, and paste the data into TEC.B2:I2.


In my "TEC" sheet, I have a pre-existing list of numbers in column A. When a data range is copied into TEC.B5:I5, the value of TEC.A5 is looked up and returned to the user (who is locked out of TEC and only has access to Sheet1).


Importantly, every time this happens, the data must be pasted into a new row, and therefore a new number is returned to the user.




I know this is a lot to ask but I have been trying to use bits of code with no results and I am not a very advanced user so any help provided here would be really appreciated!


Many thanks,


Chris


Aucun commentaire:

Enregistrer un commentaire