racheltaylor
New Member
- Joined
- Aug 10, 2013
- Messages
- 7
Hi
I need to copy and paste the values of certain columns from one workbook to different columns in another workbook. See my code below..
I know this code is not efficient, I am new to VBA and would appreciate any help to make my macro more efficient..
I could start copying from row 2 instead of 1, however the end of the range is variable and includes blank cells and I am not sure how to reflect this in my code..
Sub CopyDataToCombinedRegister()
Dim Obook As Workbook
Dim DBook As Workbook
Set Obook = workbooks("General Checks.xlsm")
Set DBook = workbooks("Aged & General Checks V10.xlsx")
Dim wsd As Worksheet
Dim wsc As Worksheet
Set wsd = workbooks("Test.xlsm").Worksheets("sheet1")
Set wsc = workbooks("Aged & General Checks V10 25.01.11test (1).xlsx").Worksheets("sheet1")
wsd.Activate
Range("A:A").Select
Selection.Copy
wsc.Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues
wsd.Activate
Range("E:E,F:F,G:G").Select
Selection.Copy
wsc.Activate
Range("D1").Select
Selection.PasteSpecial Paste:=xlPasteValues
wsd.Activate
Range("L:L").Select
Selection.Copy
wsc.Activate
Range("K1").Select
Selection.PasteSpecial Paste:=xlPasteValues
wsd.Activate
Range("U:U,V:V,W:W").Select
Selection.Copy
wsc.Activate
Range("L1").Activate
Selection.PasteSpecial Paste:=xlPasteValues
End Sub
I need to copy and paste the values of certain columns from one workbook to different columns in another workbook. See my code below..
I know this code is not efficient, I am new to VBA and would appreciate any help to make my macro more efficient..
I could start copying from row 2 instead of 1, however the end of the range is variable and includes blank cells and I am not sure how to reflect this in my code..
Sub CopyDataToCombinedRegister()
Dim Obook As Workbook
Dim DBook As Workbook
Set Obook = workbooks("General Checks.xlsm")
Set DBook = workbooks("Aged & General Checks V10.xlsx")
Dim wsd As Worksheet
Dim wsc As Worksheet
Set wsd = workbooks("Test.xlsm").Worksheets("sheet1")
Set wsc = workbooks("Aged & General Checks V10 25.01.11test (1).xlsx").Worksheets("sheet1")
wsd.Activate
Range("A:A").Select
Selection.Copy
wsc.Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues
wsd.Activate
Range("E:E,F:F,G:G").Select
Selection.Copy
wsc.Activate
Range("D1").Select
Selection.PasteSpecial Paste:=xlPasteValues
wsd.Activate
Range("L:L").Select
Selection.Copy
wsc.Activate
Range("K1").Select
Selection.PasteSpecial Paste:=xlPasteValues
wsd.Activate
Range("U:U,V:V,W:W").Select
Selection.Copy
wsc.Activate
Range("L1").Activate
Selection.PasteSpecial Paste:=xlPasteValues
End Sub