excel-2010

Excel 2010 VBA: How to store an array of worksheets as a variable?

眉间皱痕 提交于 2019-12-08 00:53:31
问题 I am trying to have several arrays of my worksheets that I can call up in my code using. ThisWorkbook.Sheets(Array("Sheet1", "Sheet3")) ThisWorkbook.Sheets(Array("Sheet2", "Sheet5")) I am wondering if there is anyway to set up a variable similar to the following: Dim ArrayOne As String Dim ArrayTwo As String ArrayOne = ThisWorkbook.Sheets(Array("Sheet1", "Sheet3")) ArrayTwo = ThisWorkbook.Sheets(Array("Sheet2", "Sheet5")) ArrayOne 'Call this Array then save Filename:="C:\Data\testfile.xls",

VBA Excel Finding and Combining Rows Based on Matching Column Cells

别来无恙 提交于 2019-12-07 23:38:40
问题 I'm trying to figure out a way to combine rows based on values in two specific columns in vba excel. For Example: Let's say I have the following sheet: Column A Column J Column Z 1 A ? 1 A ! 2 B ? 2 B ! And I need to convert it to this: Column A Column J Column Z 1 A ?, ! 2 B ?, ! 回答1: Here's another method using User Defined Types and collections to iterate through the list and develop the combined results. For large sets of data, it should be considerably faster than reading through each

Application.Calculation depending on workbook

泪湿孤枕 提交于 2019-12-07 22:57:54
问题 I'm managing a workbook with more than 200 000 formulas (some really complicated array formulas) which means that I can't let Excel automatically calculate all the cells every time I click somewhere (it takes around 8 hours to calculate everything). Instead of that, the calculation is set to manual and I have the following VBA code executed when Calculation.xlsm is opened: With Application .CalculateBeforeSave = False .Calculation = xlCalculationManual End With I use custom buttons to

Editing Hyperlinks Excel 2010 Macro

喜欢而已 提交于 2019-12-07 19:58:28
问题 Ok so I want to create a macro to replace a part of a hyperlink. I have tons of hyperlinks in the excel file. Is there a way to create a macro to do this. For example www.OldName.com/ www.Oldname.com/a/ www.Oldname.com/b/ to www.NewName.com/ www.NewName.com/a/ www.Newname.com/b/ 回答1: This will replace your hyperlink, just change the addresses and strings: Range("E1").Hyperlinks.Add Range("E1"),Replace(Range("E1").Hyperlinks(1).Address, "google", "msn"), , , "newtext" 来源: https://stackoverflow

Pasting an array of values over a ListObject (Excel table) destroys the Listobject

烈酒焚心 提交于 2019-12-07 19:12:29
问题 In one of my worksheets, I have a Private Sub BuggingVba() That should replace the data in a table with an array of values Dim MyTable As ListObject, myData() As Variant Set MyTable = Me.ListObjects(1) myData = collectMyData ' a function defined somewhere else in my workbook It is probably irrelevant, but before doing so, I resize the list object (I expand line by line because if I do it at once, I overwrite what is below my table instead of schifting it.) Dim current As Integer, required As

VBA to save a sheet to a password protected PDF

会有一股神秘感。 提交于 2019-12-07 17:00:41
问题 The following saves the activesheet as a PDF: ActiveSheet.ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:="C:\blahblah2.pdf", _ Quality:=xlQualityStandard, _ IgnorePrintAreas:=False, _ OpenAfterPublish:=False I need to be able to create a password protected PDF - is this possible using VBA without buying any additional software? 回答1: I used PDFsharp using VS - my project is in C# ... this free library works very well 来源: https://stackoverflow.com/questions/12373631/vba-to-save-a-sheet-to-a

Highlight Rows in Sheet1 that match values in Sheet2

青春壹個敷衍的年華 提交于 2019-12-07 16:10:27
问题 It's been a long time since I've done anything advanced in Excel. I have Excel 2010. I've watch many videos and tried some tutorials that do sort of what I'm looking for, but I'm just missing something. This is what I'm trying to accomplish... I have a list of about 50 SKUs in Sheet2. I have a complete list of 200 Products in Sheet1. SHEET1: ColA are SKUs ColB is Desc ColC is Price SHEET2: ColA are SKUs I need a formula or Macro that will look at all SKUs in Sheet2, then find any matches in

Range.Interior.Color Different Between Excel 2007 and Later

风流意气都作罢 提交于 2019-12-07 11:19:41
问题 I'm seeing that Range.Interior.Color returns different numbers for the same color in some cases, depending on whether it is running in Excel 2007, or Excel 2010 or 2013. Is that expected?? I'm surprised. Range.Interior.Color is the background color ("Fill Color") of the cell. In the Immediate pane, you can read it like this: ?ActiveCell.Interior.Color And set it like this: ActiveCell.Interior.Color = 10921638 Examples: Example 1: (these are the same color though their Range.Interior.Color are

How do you calculate the Quintile for every row in Excel?

寵の児 提交于 2019-12-07 06:27:02
问题 I'm trying to calculate the quintile for every row of a column in Excel. The resulting value for each row in Excel should be 1, 2, 3, 4, or 5. A value of one will be the top 20%, a value of 5 is the bottom 20%. This is my current formula which SEEMS to work, but I'm curious to see if anyone has a better way, a UDF, or sees an error in my formula... =ROUNDDOWN(RANK.AVG(A1,$A$1:$A$131,0)/((COUNT(A$1:A$131)+1)/5),0)+1 A1 through A131 has the values I'm placing in quintiles. Thanks 回答1: Your

Cannot execute macro in Break Mode

隐身守侯 提交于 2019-12-07 02:57:47
问题 I am trying to write a simple macro to add 1 to the cell's current value: Sub add() MsgBox Selection.Value Selection.Value = Selection.Value + 1 End Sub I receive the following error message when I click a (numeric) cell and try to run the macro: Cannot Execute in Break Mode What am I missing? 回答1: You are already executing a macro and somehow stopped its execution (e.g. due to an unhandled error or because you pressed Ctrl - Break during the execution). In this state, you cannot execute