I have 10 Excel files that each of them has 5 sheets. I want to have a One.xls file with 5 sheets contains all rows of that 10 excel files.
I found some softwares but none of them is free. I want to write it with Macro. how could I do it.
The best place to start is excelforum.com for specific answers but in short you need to lay it out into the following processes;
1) define the variable names for your one.xlsx workbook and sheet names so you can switch back
2) define the workbooks and associated file paths that you want to open
3) Open workbook 1
4) select the data
5) copy and paste into the master workbook
6) close workbook 1
7) repeat steps 3 - 6 for the other workbooks
that'll bring it into one consolidated list. Things to consider are whether you want to wipe what's in the spreadsheet already or add to the bottom so you may need a few error traps or cleansing tools to begin with.
Related
I'm uploading an excel file that contains sheets, to my server which encodes to base 64 so I decode it as required and process it by adding data in sheet 5 as column1 and column2 with certain number of rows. At the time of uploading, this sheet has some specific formulas on sheet 5 that makes changes in other sheets. So on opening the file which I send as response after editing from server, There comes this prompt that reads
"Excel Found unreadable content in 'MyDownloadedExcelData.xlsx'. Do you want to recover the contents of this workbook?If you trust the source of this workbook, click Yes', with Yes and no buttons
and when I click on yes and open the sheet, all the formulas are deleted.
I see something like
Excel was able to open the file by repairing ot removing the unreadable content.
Removed Records :Formula from /xl/calcChain.xml Part
Repaired Records : Cell Information from /xl/worksheets/sheet1.xml part etc
So, How do I make sure my formulas in the sheet are retained?
Using VBA you could have an on close event that pastes values and an on open event that recreates the formulas. Your file would essentially save with static data, but then be used with functions intact.
If this solution is of interest I can help provide some coding framework.
I'm working on automating a workbook in Excel, and I'm running into a few issues with my VBA code. I'd paste it here, but I've been through so many iterations, it's pretty unusable.
The goal is to have the active book 'grab' the data out of several workbooks containing raw data when it is opened, and put the copied data into a few tabs that can be used to populate various charts on a dashboard tab. Each workbook containing raw data should go into its own separate tab within the active workbook. Broken into steps, I am thinking I need the below process to occur:
Open Active Book
Open hidden tab 'Sheet1'
Open raw data book 1(e.g. c:\Raw Data.xls)
Copy data from specified location (e.g. [Raw Data.xls]Sheet1!$A$3:$AE$64) in the raw data book 1
Paste copied data into Active Book, into specific worksheet, into first empty row (e.g. [Active Book.xls]Sheet1!first empty row)
Hide tab 'Sheet1' in Active Book
Close raw data book 1
Repeat process using raw data book 2 and sheet2 of Active Book
Repeat process using raw data book 3 and sheet3 of Active Book
Only after data is populated into the destination tabs (Sheet1, Sheet2, Sheet3 in the Active Book), can the user interact (click into cells, change tabs, etc) with the workbook
I know this is simple - I'm getting frustrated, as I'm a newbie and the syntax (and multiple variations of syntax) is really throwing me for a loop. Any help would be greatly appreciated. Many thanks in advance!!
Where are you getting stuck? Briefly:
Open Active Book
If its active, it's already open? Reference with object 'ThisWorkbook'
Open hidden tab 'Sheet1'
You don't need to unhide sheets to "VBA" them... If you're going to be creating new sheets for each datafile I'd recommend creating new via:
Set wsDestination = thisworkbook.sheets.add
wsDestination.visible = xlSheetHidden ' Might as well hide it now
If you're wanting to match specific raw data files with specific worksheets, maybe use a "select"
Open raw data book 1(e.g. c:\Raw Data.xls)
Set wbSource = Application.Workbooks.Open("c:\Raw Data.xls")
Set wsSource = wbSource.sheets(1)
'If need Select (see above):
Select case wbSource.name
Case "Raw Data A.xls" ' If line above changes to .Open(Workbooks[i]) or something
set wsDestination = sheet1
Case "Raw Data B.xls"
set wsDestination = sheet2
'...
End Select
Copy data from specified location (e.g. [Raw
Data.xls]Sheet1!$A$3:$AE$64) in the raw data book 1 Paste copied data
into Active Book, into specific worksheet, into first empty row (e.g.
[Active Book.xls]Sheet1!first empty row)
intBlankRow = Application.WorksheetFunction.Counta(wsDestination.columns(1)) + 1 ' Note this only works if there are no blanks in column 1 otherwise you'll need another method: there are some good tricks if you google "find last cell vba"
wsSource.cells.copy wsDestination.cells(intBlankRow,1) ' No need to copy and paste in seperate lines: you can just pass destination to the copy function
Hide tab 'Sheet1' in Active Book
You don't need to
Close raw data book 1
wbSource.close
Repeat process using raw data book 2 and sheet2 of Active Book Repeat
process using raw data book 3 and sheet3 of Active Book Only after
data is populated into the destination tabs (Sheet1, Sheet2, Sheet3 in
the Active Book), can the user interact (click into cells, change
tabs, etc) with the workbook
Wrap the whole thing in a big loop... If you wanna do it the easy way, create an array with your workbook names and iterate through it. Otherwise present the user with a FileDialogue so they can select the workbooks they want to import... this ofcourse depends on what I was saying above: do you want to create new worksheets each time or import specific raw data in to specific sheets...
I am trying to create some VBA code that will do the following:
Take worksheets 2 and 3 from a number of different workbooks (all in the same folder) and put them into a new workbook.
Worksheet 2 has the same name in each of the different workbooks so I want the VBA to also change the name of the new worksheet to a cell reference from the original worksheet (in this case cell A6)
Worksheet 3 has the same name in each of the different workbooks so I want the VBA to also change the name of this new worksheet to the same cell reference (A6), combined with the text "ph"
Any help would be gratefully received
Rob
You'll be able to figure out all of the code you need with the help of the Macro Recorder. Turn that on and manually do your listed steps (make sure you stop recording when that's done), then look for pieces of code that move the worksheets and rename them. Once you see that code, you can figure out how to customize it to your needs.
I have an Excel spreadsheet that is updated daily in a Document Library. The spreadsheet contains 5 worksheets.
I want to create a number of Excel Services webparts that show only certain worksheets e.g.
webpart 1 to display only Worksheet 1 & 2
webpart 2 to display only Worksheet 1 & 3
and so on
I cannot seem to be able to define which worksheets to publish from the spreadsheet. Searching in various documentation it suggests this should be possible. Wondered if anyone can advise how/where this is configured? I have tried entering worksheet names, Names Ranges, Cell ranges etc. in the Named Item field of the webpart properties but this gives an error to say the Named Item is not available.
Many thanks
Open the file in Excel 2010. Click on FILE > Save & Send > Save to SHAREPOINT > Publish Options. From the drop down, select SHEETS.
Uncheck the sheets that you don't want in the web part.
Hope this help.
I have an Excel sheet that I created. For this sheet it pulls in a data feed on two of the sheets. The data feed has a parameter which I populate from a Drop Down that is fed off of another sheet. I'm trying to automate this process. I want to be able to have the file run through each one of the ID's (the parameter), run the data feed, save the excel sheet, run the next ID save and so on until it goes through the list. Can someone please please help me with this? I'm new to VBA.
1) you need a list of your IDs. I like Named Ranges, so mine is named ID_List
2) Loop thru your list
dim r as range
for each r in [ID_List]
'do yer stuff here
'what needs to be done with the value **r.value**???
'how do you want to save the file each time???
next
Need some specific answers!