Opening multiple workbooks with a varying name

DJElk

New Member
Joined
Jul 6, 2011
Messages
2
So I am very new to VBA, and have been stuck on this one part for over 3 hours and can't find anything that helps online.

What I have already done is created a Userform that asked the person running the macro to input their lab series # then hit ok.

The macro automatically saves the file into a folder "N:\folder\data\" as TextBox.Value & ".xlsx".

Once it is saved as that, the macro opens another workbook of data and copies selected cells out of that.

I would like to take that copied data, open up the already created workbook and paste the data into that workbook.

The code I am trying to use is

<!-- BEGIN TEMPLATE: bbcode_code -->

Code:
<STYLE>.alt2 font {font: 11px monospace !important;color: #333 !important;}</STYLE>
Range("K1").Select Range(Selection, Selection.End(xlDown)).Select ActiveWindow.SmallScroll Down:=-30 Range("K1:K68,N1").Select Range("N1").Activate Range(Selection, Selection.End(xlDown)).Select Range("K1:K68,N1:P68").Select Range("N1").Activate Selection.Copy Workbooks.Open "N:\MATDEV\MasterCurve Data\" & TextBox.Value & ".xlsx" Sheet1.Activate Selection.Paste</PRE><!-- END TEMPLATE: bbcode_code -->And I keep getting a slurry of different errors, everytime I try something different. The main one being "Run-time error 424- Object Required"


Any help would be greatly appreciated. It doesn't seem like it should be that hard, but I can't figure it out and feel like I've tried everything.

Thanks in advance
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi, it seems your textbox name is wrong in your bolded code.

You should replace the Textbox with Textbox1 or the name of your textbox.
To check, you can click on the textbox in your userform and look at its name.
Moreover, you must ensure the file exists in the path.

Lastly, could you reply with your code that has some indentation
You should use
Code:
your code[/CODE}[/B] 
"replace } with ]" for proper indentation in this forum.

It makes things so much easier.
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,923
Latest member
JackiG

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