Copy Cell Value from Multiple sheets to single Column in another Workbook

Wolfgang17

Board Regular
Joined
Nov 8, 2010
Messages
60
HI,
I am trying to copy Range W3 from sheets "Pay10" to "Pay26" in one workbook to a sheet called "Data" Range C17:C33 in another workbook.
Any help would be appreciated.

Code:
Sub VacationPayTransfer()

     Dim wb1 As Workbook, wb2 As Workbook, i As Long

    Set wb1 = Workbooks.Open("C:\Desktop\\2017 Timecard.xlsm") 'validate path
    Set wb2 = Workbooks.Open("C:\Desktop\\2018 Timecard.xlsm") 'Validate path
    
    For i = 10 To 26
        wb1.Sheets("Pay" & i).Range("W3").Copy
        wb2.Activate
        wb2.Sheets("Data").Range("C17:C33").PasteSpecial xlPasteValues
    Next
    
End Sub
 
Last edited:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try:
Code:
Sub VacationPayTransfer()
    Application.ScreenUpdating = False
    Dim wb1 As Workbook, wb2 As Workbook, i As Long
    Dim DesktopAddress As String
    DesktopAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop")
    ChDir DesktopAddress
    Set wb1 = Workbooks.Open(DesktopAddress & "\" & "2017 Timecard.xlsm")
    Set wb2 = Workbooks.Open(DesktopAddress & "\" & "2018 Timecard.xlsm")
    For i = 10 To 26
        wb1.Sheets("Pay" & i).Range("W3").Copy
        wb2.Sheets("Data").Range("C17:C33").PasteSpecial xlPasteValues
    Next
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
For some reason the code copies the value of the cell V3 not W3. I've had this same thing happen in other coding attempts. Not sure why.
 
Upvote 0
The code definitely says
Code:
Range("W3").Copy
so I don't know why it would be copying V3 instead. Since you've had this problem before, it would be easier to check things out if I could see your actual file. Perhaps you could upload a copy of your file to a free site such as www.box.com. or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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