PDA

View Full Version : Solved: Copy Selection Paste btw 2 sheets



Emoncada
03-19-2013, 09:50 AM
I am trying to make the following happen.
I have the user select a range then click a button.

That copies the selection and pastes it in another workbook.

What I need to do is then go back to where the user made the initial selection and to the left of the selection copy a cell value (all cells to the left of the selection should be same value) after copying that cell go back to 2nd workbook and paste in "F2".

I tried using SendKeys {Left}, but it doesn't seem to work, it keeps copying initial top cell.

Any Ideas?

Emoncada
03-19-2013, 10:04 AM
I was also thinking like using Offset, but don't know how to use it for this instance.

Here is my code
Selection.Copy
Windows("Serial Scan.xlsm").Activate
Range("B2").Select

ActiveSheet.Paste

Windows("Log.xlsm").Activate

SendKeys "{LEFT}"
'SendKeys "^{v}"

Application.Wait (Now() + TimeValue("00:00:01"))

Activecell.Copy

Windows("Serial Scan.xlsm").Activate
Range("F2").Select

ActiveSheet.Paste

snb
03-19-2013, 01:01 PM
This will suffice:


Sub M_snb()
Selection.Copy Workbooks("Serial Scan.xlsm").sheets(1).Range("B2")
Selection.offset(,-1).resize(1,1).copy Workbooks("Serial Scan.xlsm").sheets(1).Range("F2")
End Sub



NB. You didn't specify the name of the sheet in workbook 'Serial scan'.

Emoncada
03-20-2013, 10:44 AM
Thanks SNB that worked.

snb
03-20-2013, 02:18 PM
some improvement:



Sub M_snb()
Selection.Copy Workbooks("Serial Scan.xlsm").sheets(1).Range("B2")
Workbooks("Serial Scan.xlsm").sheets(1).Range("F2")=Selection.offset(,-1).resize(1,1).Value
End Sub