Adding Tabs (Worksheets)

HLS811

New Member
Joined
Oct 27, 2002
Messages
40
I have ~ 20 seperate .txt files i want to bring into excel as a single workbook - If I open them, its creating a seperate workbook for each - Is there a way to do a mass add of seperate files into 1 workbook and simply have them on seperate tabs (worksheets?)

Thanks in advance~

(I'm working in Excel 2000)
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Sure, but a couple of questions for you first:

1) With what frequency are you doing this?
2) Are your .txt files in the same location?
3) Couldn't you open each .txt file, copy the contents and paste to your target workbook?
4) Do you want to do this via VBA?

Smitty
 
Upvote 0
1) This should be a 1 time thing...
2) Yes - they are all in one folder (differnt file names obviously)
3) Yes- but thats what I was trying to avoid... (Copyng and pasting ~20 files into one sheet, if i can just open them into there.. they formatting will all be the same, so I can then do a mass change on them)
4) I don't know VBA.. :( I'm an intermediate excel user.. i haven't gotten that far yet..

Thanks!!!!!!!!!!!!!!
 
Upvote 0
Well,

As you're only doing it one time and don't know VBA, I'd probably just bite the bullet and go with quick and dirty keystrokes.

Set up your Master workbook with 20 blank worksheets., Then open each .txt file, CTRL+A-->CTRL+C-->ALT+TAB-->CTRL+V-->ALT+TAB-->ALT+FX & repeat.

It really shouldn't take more than a fwe minutes.

Iridium's post is worth a look and is a good introduction to VBA. (How he remembers where all this stuff is I'll never know!)

Smitty
 
Upvote 0
pennysaver said:
Well,
Iridium's post is worth a look and is a good introduction to VBA. (How he remembers where all this stuff is I'll never know!)

Smitty

For info I've accumulated a **** load of info over the years but the majority of the resources I use (which are linked in the sticky Mr Excel recommended links ) are:

MS Knowledge Base
John WalkenBach's Spreadsheet page
Chip Pearson
Jon Peltier's Excel Page
Tushar Mehta
Stephen Bullen


There's loads more out there so no disrespect to anyone who's not on this list! ;)
HTH
 
Upvote 0
This might work for you. It will put all the files you open on one sheet in the same book.It even has an input box asking you what file to open. You can probably play with it to make it work for your specific needs.

Sub Consolidate()
Dim NextFile As String
Dim Merged As Object
Dim Data As Object
Dim ws As Worksheet
Set Data = ActiveWorkbook
OpenNext:
Do
On Error GoTo ErrorHdlr
NewwbkName = Application.GetOpenFilename
Workbooks.Open (NewwbkName)
Set Merged = ActiveWorkbook
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
EndRow = Range("A65536").End(xlUp).Row
Range("A1:E" & EndRow).Select
Selection.Copy
Data.Activate
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Next ws
Application.DisplayAlerts = False
Merged.Close
Application.DisplayAlerts = True
Loop
Exit Sub

ErrorHdlr:
NextEntry = MsgBox("No File Selected!" & vbCr & _
vbCr & "Click Retry to open a file or Cancel.", _
vbRetryCancel, "NO FILE SELECTED")
If NextEntry = vbRetry Then
Resume OpenNext
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,194
Members
449,072
Latest member
DW Draft

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