PDA

View Full Version : Solved: Select line and send to specific fields to another worksheet



marreco
08-23-2012, 04:27 PM
Hi.
I need to select one of the rows in spreadsheet 1, to Sheet2
But the fields will always Sheet2 cells
G5
F11
I5
I14
I tried to use it but is not working....http://www.sendspace.com/file/6w9mu3http://www.sendspace.com/file/6w9mu3
Sub CopySelectedRows()
Dim rCopy As Range
Dim lAreas As Long

On Error Resume Next
Set rCopy = Application.InputBox("Select Rows to copy. " _
& "Use Ctrl for non-contiguous rows", "COPY ROWS", Selection.Address, , , , , 8)
On Error GoTo 0
If rCopy Is Nothing Then Exit Sub 'Hit Cancel

If rCopy.Columns.Count <> Columns.Count Then
MsgBox "Please select entire row(s)"
Run "CopySelectedRows"
Else
For lAreas = 1 To rCopy.Areas.Count
rCopy.Areas(lAreas).Copy Sheet2.Cells(Rows.Count, 1).End(xlUp)(2, 1)
Next lAreas
End If

End Sub

Cross-Post
http://www.mrexcel.com/forum/excel-questions/654765-select-line-send-specific-fields-another-worksheet.html

patel
08-24-2012, 01:16 AM
try attached file

marreco
08-24-2012, 03:52 AM
Hi.

Msgbox appears when I press the 'ok', then the code does nothing but.

patel
08-24-2012, 04:58 AM
check macro assigned to button "Enviar", must be CopySelectedRows

marreco
08-24-2012, 05:07 AM
Hi.

When running, the InputBox appears, I select the line.
Then appears a TextBox, I press OK, nothing else happens there!!

Thank you!!

patel
08-25-2012, 05:10 AM
Hi.
When running, the InputBox appears, I select the line.
Then appears a TextBox...... textbox ? attach again your file

marreco
08-25-2012, 07:29 AM
Hi.

See my file

jolivanes
08-25-2012, 11:37 AM
Select a name only and then click on a button.

Sub MaybeSometingLikeThis()
With Sheets("Plan2")
.Range("G5").Value = ActiveCell.Value
.Range("F11").Value = ActiveCell.Offset(, 1).Value
.Range("I5").Value = ActiveCell.Offset(, 2).Value
.Range("I14").Value = ActiveCell.Offset(, 3).Value
End With
End Sub

patel
08-25-2012, 11:54 AM
You have to assign macro to button "Enviar", must be CopySelectedRows.
After that your file works

marreco
08-25-2012, 12:30 PM
Hi.
I did the assignment happens but as mentioned in my post #5

Thank you!!

patel
08-26-2012, 12:10 AM
I can't help you, that code works perfect on my Excel 2010, on my Win7, on my PC

marreco
08-26-2012, 07:09 AM
Hi.
I use Excel 2007, Windows XP, is it therefore that is not working?

jolivanes
08-26-2012, 08:57 PM
I tried your code from the attachment in #7 and it works for me in XP/2007.
Did you select the whole row (click on the row number)?

marreco
08-27-2012, 04:09 AM
Hi.

I was not knowing how to use the code.
the code is working.:rotlaugh:

thanks to all