excel-2013

How to script Excel 2013's Spreadsheet Compare?

帅比萌擦擦* 提交于 2019-11-28 21:33:00
I'm trying to incorporate the fancy new Spreadsheet Compare function from Excel 2013's Inquire Add-in, into a VBA script. The plan is to have a macro to automate comparison between two spreadsheets with predefined names, and to export all the differences as a new spreadsheet. Without success, to date. Here's what I've tried so far: Normally, to learn how to automate some Excel functionality, I use Record Macro. If that fails, I look down the list of addable references, to see if I'm missing something obvious. Both of those have failed in this case. No code appeared relevant to the Spreadsheet

Number format in excel: Showing % value without multiplying with 100

风流意气都作罢 提交于 2019-11-28 16:46:14
问题 When I set format of a cell as %, it automatically multiply the value with 100 & show the value. So 5.66 becomes 566 % . I want to apply % format on a column but want to keep the values same as before. I just want % sign to be shown along with the value. To achieve this, I used following format 0.00##\% Now I want to show negavtive values in RED color without '-' sign(negative) and the values should be wrapped in brackets. so -5.66 should be shown as (5.66%) in red color. Please help 回答1: You

why i use Worksheet.UsedRange.Rows.Count got wrong result

烂漫一生 提交于 2019-11-28 13:11:54
In VB.NET I want to get the used rows so I wrote that: Dim objWorksheet As Excel.Worksheet = workbook.Sheets(2) Dim lastRow = objWorksheet.UsedRange.Rows.Count But I don't know why the lastRow is number little than actual used rows, I searched the stackoverflow and someone suggest write like this: Dim range As Excel.Range = objWorkSheet.UsedRange Dim lastRow = range.Rows.Count I tried and also didn't work, the num returns little than actual used rows is no rules, so I don't know how to deal with it, any idea is helpful, thanks very much EDIT 1 the final answer is image: With the help of

What does the number in the AddChart2 VBA macro represent?

廉价感情. 提交于 2019-11-28 10:59:02
I've use my Excel 2013 to record a macro in inserting a chart, a column-clustered chart in my case. In the view code option, it shows me a line of code as below: ActiveSheet.Shapes.Addchart2(286,xl3DColumnClustered).Select Please help me as I cannot understand what does the number 286 represent. I know the syntax of Addchart2 is: expression.AddChart2(Style,XlChartType,Left,Top,Width,Height,NewLayout) If I change the "286" to "285", the chart appears with a blue background. An error comes out if the number is 100. Can anyone kindly tell me what does the number represent? One can also provide

How to find max and min date in a range of another sheet?

安稳与你 提交于 2019-11-28 04:54:37
问题 I am writing VBA code to find the minimum and maximum dates in a Range. When I execute it, I get an error: Run-time error '1004': Application-defined or object-oriented error. Below is my code: Sub GenerateSheet() Dim i, r, numAssignments As Integer Dim ssrRng, DestRange As Range Dim StartDate, EndDate, d As Date numAssignments = Sheets("Data").Range("A1048576").End(xlUp).Row - 1 Sheets("Schedule").Select EndDate = WorksheetFunction.Max(Sheets("Data").Range(Cells(2, 8), Cells(numAssignments,

How to type currency symbols in Visual Basic Editor

你离开我真会死。 提交于 2019-11-28 02:28:54
There is a project requirement where we need to check a cell for its currency type. I came across a similar question in this forum ( How to check if cell is formatted as Currency? ). It explains how to do that for the $ symbol. But I couldn't replace the $ symbol with other currency symbols (for example Indian Rupee, Euro etc.) in Visual Basic Editor. To have other symbols in VBE I have tried the following: Inserted the symbol in Excel using Insert->Symbol option. Copy pasted the symbol in VBE. But it is pasted as ? in VBE. Please help me to have currency symbols in VBE. If the above is not

Excel.Application.Cells.SpecialCells(xlCellTypeLastCell) returning bottom of worksheet, not last data cell

人盡茶涼 提交于 2019-11-28 00:34:37
I'm writing a method in VBA in Excel 2013 to loop through the rows in two worksheets and compare the text in a column from each. However, when I loop through, I'm finding that the code is looping through the entire worksheet, not just the rows with data. Excel.Sheets("Sheet1").Cells.SpecialCells(xlCellTypeLastCell) returns a cell in the correct column, but the row is the last row in the sheet (1048576) rather than the last row with data (1951). I've written a check for empty cells into the code (since I can't be sure that every row is used), so it doesn't cause a problem, it just means that

CustomTaskPane in Excel doesn't appear in new Workbooks

夙愿已清 提交于 2019-11-27 21:31:57
I've added a CustomTaskPane to Excel 2013 that lets users quickly search for photos. It works well and fine if the user only opens/creates one workbook. Problem is if they open another workbook or create a new one, the task pane doesn't appear in the new window that appears. It simply stays put in the original window. I know this behavior is caused by the fact I was only initializing the panel upon opening Excel. I added an event handler to the ActiveWindow event to initialize a new panel when they open another workbook. Problem is I cannot figure out how to tell if the CustomTaskPane is

Is Excel VBA's Rnd() really this bad?

亡梦爱人 提交于 2019-11-27 17:44:03
问题 I need a pseudo random number generator for 2D Monte Carlo simulation that doesn't have the characteristic hyperplanes that you get with simple LCGs. I tested the random number generator Rnd() in Excel 2013 using the following code (takes about 5 secs to run): Sub ZoomRNG() Randomize For i = 1 To 1000 Found = False Do x = Rnd() ' 2 random numbers between 0.0 and 1.0 y = Rnd() If ((x > 0.5) And (x < 0.51)) Then If ((y > 0.5) And (y < 0.51)) Then ' Write if both x & y in a narrow range Cells(i,

Generate 5000 records in 2 columns of random number that being unique

删除回忆录丶 提交于 2019-11-27 16:31:24
How I can generate 5000 records in 2 columns of random numbers between 1 and 100 that being unique. For example: A B ---------------- 1 98 1 23 37 98 6 56 93 18 . . . . . . thanks Here is a simple-minded approach using formulae. Whether it would be appropriate would depend on context. First in the Formulas tab set calculation options to 'Manual'. Put the following formula in a2:- =RANDBETWEEN(1,100) B is going to be a helper column. Put the following in B2:- =RANDBETWEEN(1,99) Column C is the second result that you want. Put the following in C2:- =IF(B2<A2,B2,B2+1) Pull the formulae down as