How to quickly copy a whole Excel spread-sheet to another Excel spread-sheet by value? And how to quickly copy some sheets of an Excel spread-sheet to another Excel spread-sheet by value? Without using VBA (Visual Basic for Applications).
For example: suppose I have a spread-sheet called Excel_A with several sheets and with lots of formulas. I want to quickly copy all of Excel_A's values. I want to avoid copying sheet by sheet into another spread-sheet because it will be too slow and there are a lot of sheets in Excel_A.
A simple, dirty workaround, not involving code (which you don't seem inclined to write) is the following:
Save Excel_A As Excel_B
Right-click on one of the sheet handles at the bottom, and click Select All Sheets.
Ctrl-A to Select All, Ctrl-C to copy, Alt E-S-V and Enter to paste values.
Alternatively, it's definitely doable with VBA too. Something similar to the below ought to work. (It assumes both workbooks are open, otherwise replace the names with addresses.)
Sub CopyValuesToNewBook()
Dim wbA As Workbook
Set wbA = Workbooks("Excel_A")
Dim wbB As Workbook
Set wbTest = Workbooks("Excel_B")
For Each Sheet In wbA.Sheets
Sheet.Copy
Dim IndexNo As Integer
IndexNo = Sheets(Sheet).Index
wbB.Sheets(IndexNo).PasteSpecial Paste:=xlValues
Next
End Sub
There is a simple approach that you could follow,
Copy the ranges that you want to copy-paste. Open a new text document and paste it in the txt document. CTRL+A (select all) in the txt file, copy everything and then paste it in the required excel sheet. This would eliminate all the formulas in the cells and would copy just the values in the cell.
If you want to copy the entire sheet, select all (CTRL+A) in that sheet and do the same. You will not be able to copy-paste sheet using the normal way. This can be done sheet by sheet only unless you develop a macro or something else. Hope this helps
Related
I have a VBA enabled excel workbook which has more than 20 sheets. Now the code in the VBA is using Worksheets numbers to call the worksheets.
Now I will have to delete one sheet which makes all the code unusable because if I delete one sheet the worksheet number changes.
Example Worksheets(10).Activate will point to another worksheet since I will be deleting the third worksheet
I am fairly new to this, so what would be the fastest way instead of manually changing the worksheet number in the code.
Note that there are 3 ways to access a sheet …
by its position in the tab bar:
Worksheets(10) gives the 10ᵗʰ worksheet in the tab bar.
Note that if you also have eg chart sheets the numbering is different from Sheets(10) which then might be a completely different sheet.
by its visible tab bar name:
Worksheets("Sheet10")
by its VBA name:
Sheet10
Note that the VBA name can only be changed in the Project window of the VBA-Editor.
Note that Worksheets(10), Worksheets("Sheet10") and Sheet10 can be completely different sheets, because they use 3 completey independ naming systems.
Which one to use highly depends on what you are actually trying to do. There is no best option in general each of them has their advantages and disadvantages.
Additionally I highly recommend not to use .Activate and .Select at all. Therefore read How to avoid using Select in Excel VBA.
This is the same question as this post. However, the solutions in the post don't answer the question.
How can I copy all of a worksheet, including charts & pictures, to a new worksheet in another workbook?
And copy the formulas across too.
I need to do this in my AddIn - C# and using the COM (note VSTO) API to Excel.
thanks - dave
Move a worksheet within a workbook
Select the worksheet tab, and drag it to where you want it.
Note: Be aware that calculations or charts that are based on worksheet data might become inaccurate if you move the worksheet.
Copy a worksheet in the same workbook
Press CTRL and drag the worksheet tab to the tab location you want.
OR
1)Right click on the worksheet tab and select Move or Copy.
2)Select the Create a copy checkbox.
3)Under Before sheet, select where you want to place the copy.
4)Select OK.
Can anyone help me out with this VBA Macros query? I want to compare a worksheet with another worksheet in a different workbook. However, I don't want to open that workbook when comparing. I just want to changes to be shown in the current worksheet that I am using.
Is there something like a temporary data storage using Macros which stores the data temporarily from another workbook, compares it without ever physically opening the workbook?
You don't need VBA for this. You can use regular worksheets formulas, even if the other file isn't open.
For example, if we want to compare cell A1 of the current worksheet to cell A1 on worksheet Sheet1 of an (open or closed) Excel workbook saved as c:\myPath\myFile.xlsm, we could use:
=IF(A1='C:\myPath\[myFile.xlsm]Sheet1'!A1,"It's a Match!","Not a Match")
More Information:
Office.com : Create an external reference (link) to a cell range in another workbook
Microsoft Press : How to Combine Data from Multiple Sources in Microsoft Excel 2016 (book excerpt)
I am trying to write an add-in for Powerpoint, the user should be able to select cells in an Excel worksheet and then go to the Powerpoint slide he would like to paste that table in, after starting the Add-in, a macro should create a table and copy cell by cell. Afterwards the macro will format the PowerPoint table according to our formatting guidelines. I am running into some issues now:
1) How can I go through the cells within a selected range in Excel, I tried to loop through the cells within the selected range, but neither this nor counting the rows/columns with in the selected range works (I am rather unfamiliar with Excel VBA)
2) What is the best way to copy data from Excel to Powerpoint? I have seen some suggestions that use a string array, that reads in all the data first; some users re-use one variable to copy the data and some do it directly from a XL to a PPT reference, what are the advantages of the different approaches?
Thanks a lot
s
For your first question, here is a snippet of code that works (yet, it depends on what you intend to do):
Dim C As Range
For Each C In Range("A1:A100")
'do stuff
Next C
For your second point, it depends on the results you expect :
a PowerPoint formatted array
an Excel Object embedded into PowerPoint
copy-paste the values inside the slide content
Once you have chosen, it's easy to find ressources on the web to do what you want.
I have a workbook with two sheets. The first is full of data and calculations, the second is mostly cells with references to the first sheet. The second sheet also concatenates strings, and references to cells in the sheet, to form SQL commands used elsewhere.
There is also a second workbook (soon to be more). It has a sheet identical to the first sheet of the other workbook, except with different data. The problem I'm having is that the new workbook needs a sheet similar to the second of the original workbook (sorry if this is sounding confusing). I would like to simply duplicate the sheet and its formulas, which I tried using the 'move or copy...' option. Unfortunately, the formulas in the cells reference the first sheet from the old workbook, like this: =[foobar.xlsx]data!A1. Way too much data to remove them by hand. I can't just redo the formulas because I had to remove a lot of specific lines from the second sheet, so dragging the formula would not match up correctly. I'm currently trying to hack this together with REPLACE but if anyone can offer help it would be greatly appreciated.
CLARIFICATION:
When I copy the sheet, a formula will appear as =[foobar.xlsx]data!A1. I want it to just be data!A1.
Thanks :)
I hope this answers your problem, but I am a little unclear on your need!!!
Highlight all cells in the worksheet.
Perform a replace to replace = with say '=
This stops the formulas "being formulas"
Copy the sheet.
Perform another replace on the new sheet to replace '= with =
This converts back to formulas, referring to cells in your new workbook.