worksheet-function

Round function in Excel, worksheet function vs VBA

◇◆丶佛笑我妖孽 提交于 2019-12-29 01:42:08
问题 I had an application for returning closest matches to certain values in a large cluster of values( as in my earlier question) and I chose a VBA solution. While in the course of using the said application, I observed that the results for the value of 0.5 were not correct. I had been using the VBA Round function which I found to be returning 0 for 0.5 rounded to integer whereas the worksheet round function returns 1. Strangely, the VBA round function returns 2 for 1.5. I had to substitute the

Extract the last substring from a cell

*爱你&永不变心* 提交于 2019-12-27 22:05:41
问题 I have names in a column. I need to split just the last names from that column into another column. The last name is delimited by a space from the right side. The contents in cell A2 = Alistair Stevens and I entered the formula in cell B2 (I need 'Stevens' in cell B2 ) I tried using the following formulas: =RIGHT(A2,FIND(" ",A2,1)-1) =RIGHT(A2,FIND(" ",A2)) Both these formulas work for this cell but when I fill it down / copy and paste it for the cells below it doesn't work. I get the wrong

How to match a string wildcard pattern in an excel macro

柔情痞子 提交于 2019-12-25 18:28:01
问题 I have a test like LEFT('F13',2)='F1' I want to change it from a left-side match to a test that supports wildcards 'F13'='F?3' Excel doesn't support regex except in VBA code but i'd prefer this was done in a macro. I should point out that the actual test isn't a simple string, but cell references (this may be important, I'm not sure): IF(LEFT($DATA.$A$2:$A$1501,LEN($B$3))=$B$3,... The range actually evaluates to a single cell based on where the macro is called from. $B$3 is the pattern input

How to extract address in excel?

本小妞迷上赌 提交于 2019-12-25 18:27:24
问题 I have addresses in one cell and I want to extract them in different cells on the same row. Some cells have four lines of address and some have three. I am able to easily split using text to column and various delimiters for the ones with three but not the ones with four. enter image description here In the first example I have four lines and second has three Anchorage Oncology Centre 3801 University Lake Drive Suite 300-B2 Anchorage, AK 99508 US I would like the above as split into 5 cells.

Excel WorksheetFunction.Trend function in VBA

空扰寡人 提交于 2019-12-25 07:08:01
问题 I have the formula =TREND({4000,20000},{0,32},B15) in an Excel cell. What is the correct way to use this in a VBA function? I keep getting Runtime Error 1004: Unable to get the Trend property of the WorksheetFunction class, whenever Itry variations along the lines of: WorksheetFunction.Trend("{4000,20000}", "{0,32}", "B15") Thanks. 回答1: I couldn't get your formula to work in an Excel cell (#REF error). Don't the known x's have to have the same number of values as the known y's? This worked

Excel WorksheetFunction.Trend function in VBA

假如想象 提交于 2019-12-25 07:07:08
问题 I have the formula =TREND({4000,20000},{0,32},B15) in an Excel cell. What is the correct way to use this in a VBA function? I keep getting Runtime Error 1004: Unable to get the Trend property of the WorksheetFunction class, whenever Itry variations along the lines of: WorksheetFunction.Trend("{4000,20000}", "{0,32}", "B15") Thanks. 回答1: I couldn't get your formula to work in an Excel cell (#REF error). Don't the known x's have to have the same number of values as the known y's? This worked

Change a value in a cell from a checkbox

江枫思渺然 提交于 2019-12-25 05:19:10
问题 I have a value in one table and a checkbox in another. I would like the value to go up by 1 when the box is checked. I want to do something like this: =IF(C23,B4=B4+1) but Excel throws an error. C23 is the checkbox and B4 is the number. 回答1: You'll have to create a linked cell to the checkbox if you have not done so already (in Design Mode right click on the checkbox and see "LinkedCell" in the Properties menu). Then, when your checkbox is checked, this linked cell will return TRUE if checked

Conditional Formatting of a value based on Yes or NO

旧城冷巷雨未停 提交于 2019-12-25 02:22:42
问题 I have two ROWS, one has values and the other Yes or NO . I want the values in ROW 1 to be colored according to whether Yes or NO in ROW 2 in the corresponding column. For example: ROW 1 XXXX|XXXX|XXX|XXXX ROW 2 YES | NO |YES| NO There are no conditions to why ROW 1 should be yes or no, it's just the way it is. Is it possible? 回答1: In conditional formatting, use this option: And write this formula: =If(B2="Yes",1,0) And assuming your data is like this: So, the highlight in Row1 changes

How to find a difference between previous and current values in Excel Cell?

浪子不回头ぞ 提交于 2019-12-25 01:38:07
问题 A1 = time start using cntrl+shift+ which shows 4:00 AM B1 = time end using cntrl+shift+ which shows 8:00 AM C1 = time between using =MOD(B1-A1,1) which shows 4:00:00 D1 = time from cell C1 converted into minutes using =C1*1440 which shows 240 minutes E1 = D1 new value - D1 old value (Example: if old value was 240, and new is 360, then 360-240 = 120.) The bold is what I want, and I can only hope you guys can understand what I am trying to accomplish. I'll try to be clearer if need be as you

Setting Excel Worksheet to a Variable, and calling the variable in a different sub

风格不统一 提交于 2019-12-24 17:48:30
问题 I've been working on another program where I am taking specific data from a worksheet, and paste it into a certain sheet on a workbook, depending on what the part type is that is found on the data in the first worksheet. To be able to decipher which sheet will be called up, I had to write If statements to determine, based on the "part type" cell value, which sheet would be called and could be pasted into. Since there is approximately 4 subs involved (copy and pasting the date, the time, part