VBA Code Error

thomas899

New Member
Joined
Jan 23, 2019
Messages
2
Hello,

Let me start by saying that I am very new to VBA coding, so I'm sure I am making a simple mistake. I found similar questions to this on the forum, but none had exactly what I'm looking for.

I have a document that is updated daily to track certain progress in my work team. I have created a separate spreadsheet (currently called "test") where the data will be analyzed. I am trying to create an easy VBA command button to allow other members to quickly copy the necessary data onto the new sheet, updating a table with each paste. For testing purposes, I currently have all data in a single workbook. Ideally, I'd like the data to be appended to my table on test workbook. Originally, I created named ranges for the workbooks, but I have since deleted the names in order to rule out spelling error. I have two tables, "Table2" (to be copied) and "Table4" on the test workbook. The VBA code is below:

Sub Macro3()
Range("Table2").Copy Destination:=Workbooks("test.xlsm").Worksheets("Sheet1!Table4").Range("A1")
End Sub


When I try to execute the command, I get "Run-time error '9': Subscript out of range".

Please let me know if any other information is needed. I'm stuck here.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try using

Code:
Worksheets("Sheet1").Range("A1")
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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