ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying data to another workbook (https://www.excelbanter.com/excel-programming/424417-copying-data-another-workbook.html)

Steve[_22_]

Copying data to another workbook
 
I would like a user to enter data to a workbook without directly accessing
that workbook.

In another workbook I have created in cells a1:f1 I have a formulas that
result in a cell references (these are variable), but for example say A1 =
$BT$150, $BU$150 etc.

I would like the value from cells a2 through f2 to go to Target workbook
$BT$150, $BU$150 etc

Thank you


Per Jessen

Copying data to another workbook
 
Hi

Assuming that target cells will always be next to each other, this should do
it:

Sub CopyToOtherWB()
Dim TargetWb As Workbook
Dim TargetSh As Worksheet
Dim CopyFrom As Range
Dim DestCell As String
Dim InputSh As Worksheet

Set TargetWb = Workbooks("Book2.xls") ' Change to suit
Set TargetSh = TargetWb.Worksheets("Sheet1")
Set InputSh = ThisWorkbook.Sheets("Sheet1") ' Change to suit
Set CopyFrom = InputSh.Range("A2:F2")

DestCell = InputSh.Range("A1").Value
CopyFrom.Copy Destination:=TargetSh.Range(DestCell)

End Sub

Best regards,
Per

"Steve" skrev i meddelelsen
...
I would like a user to enter data to a workbook without directly accessing
that workbook.

In another workbook I have created in cells a1:f1 I have a formulas that
result in a cell references (these are variable), but for example say A1 =
$BT$150, $BU$150 etc.

I would like the value from cells a2 through f2 to go to Target workbook
$BT$150, $BU$150 etc

Thank you




All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com