Solved

VBA - Transfer data range from 1 sheet to another by row

Posted on 2014-10-17
5
221 Views
Last Modified: 2014-10-18
Hi

I have this excel form where i have from column B to J some values.

What i would like to do it to be able to transfer the data from B to J from Sheet1 into Sheet2 in on row 2 from column A to I when i double click on a specific row in column A.

Ex:

If on Sheet1 Range A3, i double click in it, it will transfer copy the values from B3 to I3 and paste it on sheet2 from A2 to I2.

How can i do that?

Thanks again for your help.
Test-to-transfer.xlsx
0
Comment
Question by:Wilder1626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 250 total points
ID: 40387584
Attached is the requested ..
Test-to-transfer.xlsm
0
 
LVL 30

Expert Comment

by:gowflow
ID: 40388632
I have a question for you:
do you always want to paste the values in Sheet2 on Row2 ? what if there is data in row2 the new doubleclik items will go on row 2 or row3 ?

The proposed solution will find the available row and paste the new data at the last available row.

here is the code for that:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim WS2 As Worksheet
Dim WS As Worksheet
Dim MaxRow2 As Long

Set WS = ActiveSheet
Set WS2 = Sheets("Sheet2")
MaxRow2 = WS2.Range("A" & WS.Rows.Count).End(xlUp).Row + 1

If Not Intersect(Target, WS.Range("A:A")) Is Nothing Then
    WS.Range("B" & Target.Row & ":J" & Target.Row).Copy WS2.Range("A" & MaxRow2)
End If
End Sub

Open in new window


Please chk the file attached.
gowflow
Test-to-transfer-V01.xlsm
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 40388669
Hi gowflow

wow, this is very good.

To answer your question, yes, it should always be on row 2 only.
0
 
LVL 30

Assisted Solution

by:gowflow
gowflow earned 250 total points
ID: 40388729
The here it is:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim WS2 As Worksheet
Dim WS As Worksheet
Dim MaxRow2 As Long

Set WS = ActiveSheet
Set WS2 = Sheets("Sheet2")
'MaxRow2 = WS2.Range("A" & WS.Rows.Count).End(xlUp).Row + 1
MaxRow2 = 2

If Not Intersect(Target, WS.Range("A:A")) Is Nothing Then
    WS.Range("B" & Target.Row & ":J" & Target.Row).Copy WS2.Range("A" & MaxRow2)
End If
End Sub

Open in new window


and worksheet updated.
gowflow
Test-to-transfer-V01.xlsm
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 40388815
Hi samo4fun and gowflow.
this is perfect.

Thanks for your help
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question