|
-
May 23rd, 2013, 06:02 PM
#1
Thread Starter
New Member
[RESOLVED] [Excel] Copying and pasting cells from a selected row
Hi there,
I am new to coding of all kinds and have run into problems when trying to write a script to do the following in Excel 2010. I have been googling for the last couple of days and have not been able to find an answer, so would appreciate your help!
I want to select a row in a master spreadsheet ("Master worksheet in progress v0.2"), then run a script which will then open another spreadsheet ("Handover Action Form") and copy a number of non-consecutive cells in the selected row and paste them into specific cells in the second spreadsheet.
So far, I have recorded a macro that opens the second worksheet, then copy and pastes from fixed cells:
Code:
Sub CopyPastetoHandover()
'
' CopyPastetoHandover Macro
'
'
Workbooks.Open Filename:="H:\My Documents\HL tools\Handover Action Form.xlsm" _
, UpdateLinks:=0
Windows("Master worksheet in progress v0.2.xlsm").Activate
Range("A2").Select
Selection.Copy
Windows("Handover Action Form.xlsm").Activate
Range("A8").Select
ActiveSheet.Paste
Windows("Master worksheet in progress v0.2.xlsm").Activate
Range("H2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Handover Action Form.xlsm").Activate
Range("F4").Select
ActiveSheet.Paste
Windows("Master worksheet in progress v0.2.xlsm").Activate
Range("J2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Handover Action Form.xlsm").Activate
Range("B8").Select
ActiveSheet.Paste
Windows("Master worksheet in progress v0.2.xlsm").Activate
Range("K2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Handover Action Form.xlsm").Activate
Range("C6:D6").Select
ActiveSheet.Paste
Windows("Master worksheet in progress v0.2.xlsm").Activate
Range("L2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Handover Action Form.xlsm").Activate
Range("E8").Select
ActiveSheet.Paste
Windows("Master worksheet in progress v0.2.xlsm").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
Range("Q2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Handover Action Form.xlsm").Activate
Range("E6:F6").Select
ActiveSheet.Paste
Windows("Master worksheet in progress v0.2.xlsm").Activate
Range("R2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Handover Action Form.xlsm").Activate
Range("E13").Select
ActiveSheet.Paste
Windows("Master worksheet in progress v0.2.xlsm").Activate
Range("S2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Handover Action Form.xlsm").Activate
Range("A18:D20").Select
ActiveSheet.Paste
Windows("Master worksheet in progress v0.2.xlsm").Activate
End Sub
As you can see though, with this script I can only copy from row 3. The cells that are being pasted into "Handover Action Form" will remain the same.
I am unable to attach the two spreadsheets or upload images (work computer) but am happy to provide more info as required.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|