| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 150503 | 2022-02-26 04:05:00 | Excel expert wanted | Tony (4941) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 1484616 | 2022-02-27 23:12:00 | What version of excel are you using? You may have better luck over at mrexcel.com on the boards there. |
the_bogan (9949) | ||
| 1484617 | 2022-02-27 23:21:00 | What version of excel are you using? You may have better luck over at mrexcel.com on the boards there. Excel 365. I was just thinking I should find an excel-specific forum. I'll try there. Thanks. |
Tony (4941) | ||
| 1484618 | 2022-02-27 23:34:00 | I hate Excel VBA! I have created a test function called birthday: Function BIRTHDAY() Dim answer As String Dim Startdate, Enddate As Date Startdate = "3/3/1970" Enddate = "5/6/1970" answer = Application.WorksheetFunction.Days360(Startdate, Enddate) Debug.Print answer BIRTHDAY = answer End Function If I run that in the VBA environment it works and displays 92 in the immediate window. In the spreadsheet I enter =BIRTHDAY() in a cell. This gives me a #NAME? error, and I don't know why. If I understand you correctly, you don't want defined dates in your VBA. You'd want them to refer to dates in specific cells wouldn't you? It's been too long since I've used VBA, but I didn't bother with the dim aswer as string. You know the basic formula of what you want to do and repeat? Start recording a macro, select your chosen cell for output, put your formula in. stop recording the macro. Take a look at your macro to see if it needs changing, or you can just run that as needed |
the_bogan (9949) | ||
| 1484619 | 2022-02-27 23:37:00 | Recording a macro is definitely worth a try. The code I supplied was purely a bit of test stuff to see why I was getting the #NAME? error. | Tony (4941) | ||
| 1484620 | 2022-03-02 08:12:00 | OK, I solved it using the function wizard. Selected the cell where I wanted the function. On the "formulas" tab, clicked "insert function". Selected the category "user defined" Selected "PERSONAL.XLSB!BIRTHDAY()" and that was inserted as the formula and returned the correct result, Nothing I had read anywhere suggested I needed to code the formula that way. Thanks for the help and suggestions. |
Tony (4941) | ||
| 1 2 | |||||