Solved

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

Posted on 2014-10-17
5
216 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
  • 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 29

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 29

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I extract data from Excel worksheets? 5 39
Records from Access to Excel to specific cells 5 25
Strategy Mapping Excel WB/WS 2 26
V-Lookup 11 18
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

856 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