Vba to transfer specific data from one work book to another

Hardhat

New Member
Joined
Jul 28, 2017
Messages
23
I am struggling with a small pit of code. I am placing a button on a worksheet, that when used it will transfer specific data from the workbook it is in to a secondary workbook if a condition is met. I have done this before with no difficulty and I have compared my code to workbooks that work fine. The condition statement works fine, Opening the secondary workbook works fine,

But the data transfer give me Run time error '438' Object does not support this property or method. I need some fresh eyes on this. any and all help will be greatly appreciated!!!! I will be adding a loop to the if statement so looks for any empty cell in L and reports the corresponding row information to the secondary form.
Code:
'Sub CopyToViewingWB()

If Sheet1.Range("L3") = "" Then
Workbooks.Open Filename:="M:\HSS Shared Services\Shared Services Team\Chuck T HSS\Recruiting\Req_veiwing_Form.xlsx" 'Location of workbooK
    Application.Visible = True 'change to hide Workbook while data transfers
  
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("A2").Value = Sheet1.Range("A3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("B2").Value = Sheet1.Range("B3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("C2").Value = Sheet1.Range("C3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("D2").Value = Sheet1.Range("D3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("E2").Value = Sheet1.Range("E3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("F2").Value = Sheet1.Range("F3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("G2").Value = Sheet1.Range("G3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("H2").Value = Sheet1.Range("H3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("I2").Value = Sheet1.Range("I3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("J2").Value = Sheet1.Range("J3").Value
    Workbooks("Req_veiwing_Form.xlsx").Sheet1.Range("K2").Value = Sheet1.Range("K3").Value
    
End If




End Sub
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You cannot use sheet codenames in that manner on another workbook, you need to change it to use the sheet name, you can also do all the copying in one go
Code:
Workbooks.Open Filename:="M:\HSS Shared Services\Shared Services Team\Chuck T HSS\Recruiting\Req_veiwing_Form.xlsx" 'Location of workbooK
    Application.Visible = True 'change to hide Workbook while data transfers
  
    Workbooks("Req_veiwing_Form.xlsx").Sheets("sheet1").Range("A2:K2").Value = Sheet1.Range("A3:K3").Value
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,825
Messages
6,121,787
Members
449,049
Latest member
greyangel23

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