Workbook range to another workbook using cells

Calgary_Neil

Board Regular
Joined
Apr 5, 2014
Messages
79
Hi Again :(, Two questions:
1) I'm using .Formula but am getting the Value. Really want to transfer the true state (ie =1 not 1)
2) I can not get a range to transfer. If I reduce the receiving part I get the first cell only. I would like to keep this simple and cut/paste feels long, but not impossible.
In the end this will loop X times offsetting from the starting column by 7.

VBA Code:
Sub TransferData()
    Dim NewWB       As Workbook
    Dim NewWS       As Worksheet
    
    Dim Folder      As String
    Dim OldWB       As Workbook
    Dim OldWS       As Worksheet

    Dim LTurn       As Integer

'Pick New file
    Set NewWB = ActiveWorkbook
    Set NewWS = NewWB.Worksheets("Production")
'Pick Old File
    Folder = "D:\Users\Owner\Documents\0) OneDrive\OneDrive\9) Unused\My Games\Space Empires\Current\WorkArea\"
    Set OldWB = Workbooks.Open(Folder & "Gord9B_SE_4X_CE_V2.55.xlsm")
    Set OldWS = OldWB.Worksheets("Production")
'Transfer Card Data
    NewWB.Worksheets("Empire Cards").Range("B4:B36") = OldWB.Worksheets("Empire Cards").Range("B4:B36").Value
    NewWB.Worksheets("Alien Cards").Range("B5:C36") = OldWB.Worksheets("Alien Cards").Range("B5:C36").Value
    LTurn = 1
'Transfer K7
        NewWS.Cells(7, 4 + LTurn * 7) = OldWS.Cells(7, 4 + LTurn * 7).Formula
'Transfer M7: M10
        NewWS.Range(Cells(7, 6 + LTurn * 7), Cells(10, 6 + LTurn * 7)) = OldWS.Range(Cells(7, 6 + LTurn * 7), Cells(10, 6 + LTurn * 7)).Value
    
End Sub

Thanks for reading
Neil
Excel 365
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Got this to work by using
VBA Code:
        TRange = Range(Cells(7, 6 + LTurn * 7), Cells(10, 6 + LTurn * 7)).Address
        NewWS.Range(TRange) = OldWS.Range(TRange).Formula
The Formula part was caused by Application.ScreenUpdating = False, so it looked like it wasn't working in the debug step method (or break).
Neil
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top