excel

Using a class module variable in a userform (Error '424' object required)

血红的双手。 提交于 2021-02-08 05:58:40
问题 I have a class module which hosts a worksheet_change sub, and in that sub a Userform has to pop up. I want to use a number of variables from the class module in the Userform's code. Whatever I do, however, I can't get it to work. I have tried to apply the method from this very lenghty guide, but to no avail. Other threads on SO weren't able to help me. Private cell As Range Public WithEvents m_wb As Workbook Property Get cellr() As Range Set cellr = cell End Property Property Set cellr

Excel Macro VBA - How to insert copied cells instead of paste

僤鯓⒐⒋嵵緔 提交于 2021-02-08 05:47:36
问题 I have a macro running with the following code to copy data from one Excel file into another Excel file. Currently it is copying and pasting the data into the second Excel file. This means it overwrites any data that is in the second Excel file. I would like it to insert the copied cells rather than paste over the data already in the workbook. How should I edit line 27 to make this work? I think I need to use the following code but I'm not sure how to apply it to my original code.

Setting *both* Value & Formula in EPPlus

十年热恋 提交于 2021-02-08 05:42:09
问题 Is there any way to set both the Value & Formula properties of a cell so that they persist into the written XLSX file? Since EPPlus does not calculate the formulas (it relies on excel to do so), I am pre-calculating the result for the user. This is so that if they do not open the file, but then re-upload it, the 'value' is not null. The formulas are really simple. Note: sheet.SetValue() and .Value both reset the Formula property of the ExcelCell class, so .Value must be called first. See the

Why is freshly opened Workbook.Name different from Workbook title in Excel window?

眉间皱痕 提交于 2021-02-08 05:34:33
问题 I have created a file and referenced it as GlobalFile . Then I saved it as "Glo" and then as "Ume". Then I reopen the saved files to have two distinct workbooks open on two different names in two different Workbook objects: GlobalFile and NightMareFile . After opening, Excel windows has the correct headers as "Glo.xls" and "Ume.xls" respectively, but testing NightMareFile.Name results in "Glo.xlsx" !!! How is this possible at all? I'm on Win 10 64 bit, Excel 365 16 bit. Already tried:

Excel VBA - compare date in cell to current date

℡╲_俬逩灬. 提交于 2021-02-08 05:26:55
问题 (Excel 2010 VBA) I have a cell (A1) containing a date in the format of mmm-yy ("Custom" category). Foe example, if I enter 1/6/13 the cell shows June-13. That's fine. In my VB macro I need to check this date whether the month is the current month and whether the year is the current year. I don't care about the day. 回答1: Does this help you: Public Sub test() d = Sheet1.Range("A1") n = Now() If Year(d) = Year(n) And Month(d) = Month(n) Then MsgBox "It works" End If End Sub 回答2: Thanks to Dave

C#: State of a Checkbox in MS Excel

与世无争的帅哥 提交于 2021-02-08 05:16:30
问题 I am trying to acquire state of a checkbox existing in an XLS document via C#. Let me back up here. This is what I have: MS Office 2007 + Dev Tools and VC# 2010 Express Referenced MS Excel 12.0 Object Library An XLS document I successfully retrieve the Excel.Shape object. However, I am stuck when trying to determine whether it is checked or not. So far I have acquired its AutoShapeType, which says msoShapeMixed. Can someone point me to the right direction? Thanks! class Program { static void

check if a range is empty in vba module

拈花ヽ惹草 提交于 2021-02-08 05:16:28
问题 I wanted to check if an excel range in empty in a section of code in user module. I used the below code Worksheets(yearsheet).Range("N" & rownum & ":DI").Select If Application.WorksheetFunction.CountA(Selection) = 0 Then Exit Sub End If I'm getting runtime error 1004. Can anyone tell whats my mistake? Thanks in advance. PS: rownum is integer variable and yearsheet is string variable. both these variables were updated properly in code prior to the above section of the code 回答1: "N" & rownum &

C#: State of a Checkbox in MS Excel

时光怂恿深爱的人放手 提交于 2021-02-08 05:15:27
问题 I am trying to acquire state of a checkbox existing in an XLS document via C#. Let me back up here. This is what I have: MS Office 2007 + Dev Tools and VC# 2010 Express Referenced MS Excel 12.0 Object Library An XLS document I successfully retrieve the Excel.Shape object. However, I am stuck when trying to determine whether it is checked or not. So far I have acquired its AutoShapeType, which says msoShapeMixed. Can someone point me to the right direction? Thanks! class Program { static void

Is it possible to return error code to VBA from batch file?

一笑奈何 提交于 2021-02-08 04:58:47
问题 My batch file: SET username=%1 SET password=%2 net use "\\gessel\toys\name" %password% /user:shops\%username% ECHO.%ERRORLEVEL% :copy Xcopy "\\gessel\toys\name\babytoys" "%appdata%\shops" /S /E ECHO.%ERRORLEVEL% IF ERRORLEVEL 0 goto disconnect goto end :disconnect net use "\\gessel\toys\name\babytoys" /delete goto end :end EXIT /B %ERRORLEVEL% I have called above batch file from VBA and the code as follows: call Shell(Environ$("COMSPEC") & " /c " & path & username & password, vbHide) The

accessing individual array elements in VBA function

妖精的绣舞 提交于 2021-02-08 04:51:04
问题 VBA newbie here. I am trying to pass an array ( it is static, but please answer for dynamic range as well ) to a function. Then assign individual array elements to unique variables and use these variables in a custom formula. I just browsed around and wrote the code but keep getting #VALUE! error. The gist of the code is below: Public Function mytest(ByRef arr1 As Range) Dim A As Double Dim B As Double A = arr1(0) B = arr1(1) mytest = A + B 'The actual formula is a bit more complicated than