Copy Worksheets To New Workbook And Convert To Values
Mar 19, 2007I'm looking for a way that I could place a button on my workbook that would create a new document from the specified worksheets and convert the formulas to the values.
I'm looking for a way that I could place a button on my workbook that would create a new document from the specified worksheets and convert the formulas to the values.
Code:
Sub Select_All_Sheets_And_Export()
Dim wsWorksheet As Worksheet, wbNew As Workbook
Worksheets.Select
Cells.Select
Selection.Copy
[Code] ........
I have come up with the above code to select all sheets in my workbook and convert to values and then split and save each worksheet as its worksheet name in the same directory.
I have a workbook with 30 some sheets. I would like to have a macro that if i select multiple sheets, will paste the values and formats of those sheets into a new workbook. I would like this to keep the names of the worksheets when transfered to the new workbook.
Thus far, I have been using this code, which does nearly everything i want, but instead of pasting the values, it gives me #VALUE! for nearly all the cells. Most of the cells are using Vlookup and/or Indirect functions to reference other sheets- not sure if this is relevant. The few cells that do paste accurately are either text or simply reference another cell on a different worksheet without a function.
Here's my code.
Sub PasteShtVal()
Dim w As Worksheet
ActiveWindow.SelectedSheets.Copy
For Each w In ActiveWorkbook.Sheets
With w.UsedRange
.Value = .Value
End With
Next w
End Sub
I have a macro that changes user selection from formulas to values:
Dim vCol As Variant
vCol = Application.InputBox("Select Column", Type:=2)
If vCol = False Or vCol = "" Then Exit Sub
Set UserRange = Range(vCol & "9:" & vCol & "35")
UserRange.Value = UserRange.Value
End Sub
I have several workbooks that use this macro, and the workbooks can include several sheets.
Is there's an easy way to change the macro so the user selection is changed in all sheets in the workbook. E.g. if the user selection is column H, the formula is changed to values in all sheets in the workbook.
I am trying to be a good programmer and not do a whole bunch of activate workbooks and worksheets. So I am 99% complete with my subroutine and stuck on 3 lines. I need to copy my entire pivot table from PvtDest (which is Superdatabase.xls sheets f2 pivot)
Set PvtDest = Workbooks(SSRname).Worksheets(CarrPivot)
PvtDest. Cells.Copy
PvtDest.Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
PvtDest.cells.copy works fine
PvtDest.Cells.select Fails due to (select method.range class failed
finally Selection.Paste special is supposed to paste on PvtDest but I have not been able to accomplish this.
I think I have seen copy paste special in the same command line is that the solution
I would like to have a Macro, which could find Formulas on ALL sheets and replacing them with Values (Special Paste).
Example: I have multiple sheets and on every sheet there are functions (In my case, =MAX). I would like that my Macro would simply find that function and automaticly replace it with a Value (I do not have time to Copy -> Special Paste 300 Functions)
I am trying to code a Macro so that i can take all the worsheets and save them as individual Workbooks. I wrote a macro that appeared to work, but, after it saves the first sheet as a workbook, i get a debug error.
MS VB Script error:
Runtime error '9':
Subscript out of range
Any advise would be greatly appreciated.
Thank you
Code is below..
Sub saveall()
'
'
For Each ws In ActiveWorkbook.Worksheets
ThisFN = "C:Documents and SettingsUserDesktop" & ws.Name & ".xls"
I = I + 1
Sheets(I).Select
Sheets(I).Move
ActiveWorkbook.SaveAs Filename:= _
ThisFN, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Next ws
End Sub
I have a workbook containing several worksheets I want to copy to a workbook of their own and save under a specific name/password through a macro.
However, I have five difficulties:
1) I want to new workbook to contain only 1 worksheet. So, only the worksheet copied from the original workbook, and no other worksheets.
2) I want to be able to manually select the destination file for the copied workbook, however. This should be the same file for all workbooks.
3) I want the data copied from original worksheet to be ‘pasted as value’ only, so no formulas in the new workbook.
4) I want the new workbook to be read-only. Therefore I want the workbook to be /locked and password protected. So, the password should be only for altering cells, not for opening the workbook. See also point below.
5) Regarding the naming and passwording part I have made a matrix table in a worksheet named: “Rekeningen” (this worksheet is in the original workbook). This table contains three columns:
Column A, cells 40:65, contains the names of the worksheets I want to copy
Column B, cells 40:65, contains the names of the new workbooks
Column C, cells 40:65, contains the passwords of the new workbooks
So for example ....
Assume 2 Workbooks - the Active one and "Book2".
I mannaged to copy ALL the sheets from the ActiveWorkBook to "Book2" with the following code - but as you can see the code copies each of them AFTER the last sheet in "Book2".
Sub Copy_Sheets()
' Copy All sheets from ActiveWorkbook to "Book2.xls"
For Each SH In ActiveWorkbook.Sheets
SH.Copy After:=Workbooks("Book2").Sheets(Workbooks("Book2").Sheets.Count)
Next
End Sub
How can I copy them to "BEFORE", lets say Sheet(1) in "Book2" ?
I tried to change the SH.Copy command to somthing that sounds logic to me, such as:
SH.Copy Before:=Workbooks("Book2.xls").Sheets(1)
but got the: "Run-time error '9' - Subscript out of range".
I have 16 proposals that are either hidden or visible in a proposal generator. I need to be able to copy only the visible worksheets over to a new workbook that uses a name from a cell inside the proposal generator. Then a save as prompt to force the user to save the file wherever they choose.
View 14 Replies View RelatedUsing a Command button into my Master file, I'm looking for a code that give me an option to select an existing file that will have a variable name & path, open it and then copy all worksheets contained within it, into my Master workbook. Then close the selected file on completion.
Not sure if it's important but some of the copied worksheet names will contain copies. e.g. Apples, Apples (2), Pears, Pears (2). etc.
I have developed a macro, run by a button click, in my workbook.
I have about 5 other workbooks to process, what I want to do is to have my workbook with my macro open, then either copy or import these other 5 workbooks, one at a time, into my current workbook so I can run my macro on their data. Not sure if I need to copy them in or not, but thats all I can think of. I'm not even sure how to do this manually, I tried having my workbook open and doing a file - import on the .xls file, but it seems to be translating my data and I'm ending up with a value of 'f1' in one of my columns, no idea what that is. All I really want to accomplish is to run my macro on each of the 5 workbooks, one at a time.
I am trying to optimize my code below. It works but it is soo slow, it seems to slow down on the array copy and paste special areas. I believe this is because its doing a cell to cell paste method. These sheets have data as well as graphs that i want to retain on the new sheet, but i could select ranges for each each if that would speed up this procedure.
Code:
Sub CreateDataSheet()
Dim ws As Worksheet
Dim sDataOutputName As String
With Application
.Cursor = xlWait
.StatusBar = "Saving DataSheet..."
.ScreenUpdating = False
[Code]....
All i need to do is copy all worksheets in lots of workbooks into one workbook with multiple sheets, easy right!!
View 2 Replies View RelatedI have different excel files in a specific folder. All the files have only two sheets with same kind of data, formatting etc. Now I want to merge selective files on need basis (only the first sheet data) into a new different worksheet in which I will be running the code. Provide me a macro which will ask me to select the files I want to merge. Also the data range of the files ( needs to be merged) will vary time to time, so the macro needs to take care of that as well.
View 2 Replies View RelatedI need to copy a range of values (actually two ranges). The ranges are of fixed size. Le't say A2:D20 and E2:H20.
Both workbooks have the exact same layout, and they both have the same named worksheet (in this case it's called Entry). However the actual filename of the source workbook is unknown. I know numerous users have changed the filename of the xls file.
I want to instruct them to open the old and new workbook, and open a third workbook containing the copy macro, they run the macro and it copies the data.
How can I reference a known worksheet name but of an unknown workbook name esp when the source and destination share the worksheet name?
I have a workbook that has five worksheets listing warehouse inventory items. One worksheet for 2013, 2012, 2011, 2010 and 2009. In column b of each worksheet is a column B with a heading of "Item Number". There are hundreds of item numbers on each worksheet.
I would like to be able to find and highlight item numbers that appear in multiple years. Preferably color coded showing appears in five, four and three years. If that's too difficult than just items that appear in all five years. I tried conditional formatting, but have been unsuccessful.
Lastly, is there a way to list any duplicate item numbers on a new worksheet.
I have a report(Input report) with multiple sheets with different worksheet names.
Now I have to select 2nd worksheet of input report and copy a certain range values and paste in the other workbook(output) . From the same sheet 3 diffrent values I will copy and paste in other work book.
Now, I have to come back to the input report and go to next sheet and copy the same range data and append to the out put report below the first sheet.
This I need to do for all worksheets for the input report worksheets (there are more than 100 worksheets)
[code here]
VB:
Sub testtest()
'
'
Dim ws As Worksheet
[Code].....
I have a userform which loads the data into a worksheet named "Data" which is being used as a database for an event scheduler. I also load a calendar from a worksheet named "Month" so I need the information from the userform "UForm01" added to 2 worksheets.
The userform adds a series of textboxes to worksheet "Data" in the first open row. I also need certain textboxes from the Userform to be added to another worksheet to populate the calendar.
See the code below.
[Code] .....
I have a workbook with many (25) worksheets which all have the same structure, column headings, etc. but vary as to the number of rows. I would like to search all worksheets in workbook and copy to worksheet "120" only those rows where column C is "120" and column E is "1-00053-".
Ideally, input boxes would be used to enter these criteria so that it can be used for different scenarios in which these values will vary.
My problem is as such; each month I receive an application for payment. This will contain around 20-30 worksheets. However I only need to interrogate around 3-4 specific ones. The worksheets I require contain data describing the plant/equipment a company has purchased, or materials purchased over a period of time. Each month the worksheets are updated with the previous months data appended to the bottom. I am required to established if the equipments have been purchased at the correct rate.
The worksheets are all protected thus in order to interrogate them I am required to copy an paste their contents into a new work book in order to format them and insert my new "assessment" columns. I need to keep the work sheets separate in the new work book as they have different layouts however they have the same layout and work sheet names each month.
I needs a macro which would allow me to open up a new book them copy the specific worksheets from a specific file into the new work book. I then have a separate macro which re-formats them into the layout I require.
I found some useful code for copying specific worksheets into a new workbook based on the sheet name, which I have not been able to alter to suit my needs.
I have a workbook that has a Master Sheet that contains a summary of each claim (Name, type of claim, dates, dollar amounts, etc.) and a sheet for each specific claim.
I know I can use the filter feature on the master sheet to view all of the physical damage claims (and one column has a hyperlink to the worksheet for that specific claim). But every month I have to create a report that shows each type of claim, dates, and so on.
I would like to create a macro that can copy the worksheets to a new workbook based on the type of claim it is. I'm thinking something like for each ws in wb if range ("F15") = 1 & .range ("B4") < 30 days from today copy that sheet into a new wb.
Below is a generic and far smaller version of my workbook. The name column contains my hyperlinks to the specific sheet. Each sheet is also named based on the text in the name column (so John Doe's sheet would be named 'John Doe') and so forth.
Date of Loss
Name
Cargo
BI
PD
Paid
Reserves
[Code] ........
Assistance w/ this line of
If Not isempty sheets("PCCombined_FF"). cells("I4:I"&lrow) Then sheets("Discounts").cells("I4:I"&Lrow).value_
=sheets("PCCombined_FF").cells("I4:I"&lrow).value
Function for code is to look at cells in col. I on the sheet "PCCombined_FF", If the value is not blank then that value will populate the next open cell on sheet "Discounts" in col. B beginning in row 2.
I need to copy the Selected Sheet (Sheet name will be different each month) on a spreadsheet and paste the copy to the left of the selected Sheet. Then I need to copy and paste values the entire sheet of the sheet that the copy was made from (the one on the right). I am very new to macros, and I tried recording and manually editing the macro with no success. The number of sheets will be different always as I will be adding this to different workbooks and also because new sheets may be added to any workbook at any time. I attached my code that I came up with, as I am not familiar with code enought to "[code]" my code.
View 3 Replies View RelatedI have a workbook that has a lot of formulas in it that reference material stored on my local computer.
I need a macro that will copy all 42 tabs in to a new workbook book without all formulas, but saving all the formats have made. This would save me from every other day coping and pasting manually each of the pages.
I want to write a macro that will copy data from all worksheets of a specified workbook and copy them into a new workbook.
To give some detail, I receive a report each morning containing failed deliveries. I also export a list of failed deliveries from a system (SAP). These reports rarely match so I must compare the two daily. I do this using INDEX and MATCH functions but now my boss wants all the data in a single report so I would like to harness the might of vba to consolodate all the data in one workbook.
The lists of failed deliveries are contained in worksheets marked mon, tue, wed... so I need to search all worksheets for all delivery numbers and copy all of the data into a new book. This becomes complicated because on Monday there is only one tab marked mon, on tuesday there are two (mon & tue), one wednesday there are three and so on.
I have started on some code but I am getting nowhere fast. I have managed to muster an input box which asks for a date (this will be used to search the file path for a file named "failed deliveries & "mm/mm/yyy")
I have one sheet for each day of the month with a table that has Employee Name, Reason, and Expected Return. I need to copy each line into the monthly sheet, but each day may have varying number of rows. Needless to say I would like to do this without copying lots of blank lines into my consolidated sheet.
View 10 Replies View RelatedI need to copy all sheets from a workbook to a another workbook (create a copy of the one I am using) and this is the cod I have:
Sub NewReport()
Dim Workbook1 As Workbook
Dim Workbook2 As Workbook
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
End With
[code].....
The problem I have is that the output only have the sheet1!
I am using Excel 2010
I get 'x' number of workbooks(with one sheet only) everyweek from which I need to copy data and paste to a master worksheet. (SCREEN CAPTURE BELOW)
I am unable to write the code myself as I have never worked on VBA and am only a beginner.
Part I:
The data I need to copy starts from the 19th row (A19:H19). The end point is determined by the row just before the row that has the words "Calibration Request" in it.
Part II:
Just below the data that was pasted from Part I, the data from 2 rows below the words "Calibration Request" needs to be pasted. The end point for this would be a blank row encounter.
Also some of the rows and columns are merged.
Basically, I have six worksheets where I have, on two different columns each,
the code, the quantity, the shelf
Where it is stored.
What I have been asked for is: given the shelf, to have got back all the codes and quantity that there are in this shelf.
My Idea is: in a sheet called <<initial>>, create a cell where I write the value of the shelf (this value in a text).
Then, with a VB procedure, start activating first worksheet, start reading the first column.
if the shelf value corresponds to the required shelf, then activate a sheets called "Results" and write there all the value corresponding to code and quantity.
Then, when ended the column, I would move to the second column. Once ended the second column I would activate the second worksheet.
But I am having some problems since the beginning, since I have problems in reading the value of the shelf column.
I am attaching how I have started to wrote the procedure : [Code] .....
Why I can read the value of the cell ?