excel-2013

VBA To Add Formula To Cell

梦想的初衷 提交于 2021-02-10 04:56:13
问题 I am attempting to write some VBA which will add header text to 3 cells then fill a formula all the way down to the last row. I have written the below, which writes the headers no problems, but when it get's to my first .Formula it throws a Application Defined or Object Defined error What needs to be altered so that this macro will execute successfully? (The formulas were pulled directly from the formula in the cell, so I know they are valid formulas at least on the "front-end") Function Gre(

VBA find/replace using array for cell range

女生的网名这么多〃 提交于 2021-02-08 08:25:56
问题 I receive a quarterly data set where I need to make some general changes to the data. The changes are routinely the same and I want to use a macro to change them in one fell swoop rather than find/replace manually. I found a script that saves my data as an array and then searches the entire workbook. It works BUT I only want it to find/replace in a specific range. I've tried many times to alter the code, but I am unable to. I don't even know if this is the best way to accomplish it - very

Error in Hash Implementation in VBA - Runtime Error -2146232576 (80131700)

二次信任 提交于 2021-02-04 19:27:26
问题 I have implemented the hash method as suggested on the post: Does VBA has a Hash_HMAC This is my implementation: Public Function BASE64SHA1(ByVal sTextToHash As String) Dim asc As Object Dim enc As Object Dim TextToHash() As Byte Dim SharedSecretKey() As Byte Dim bytes() As Byte Set asc = CreateObject("System.Text.UTF8Encoding") Set enc = CreateObject("System.Security.Cryptography.HMACSHA1") TextToHash = asc.GetBytes_4(sTextToHash) SharedSecretKey = asc.GetBytes_4(sTextToHash) enc.Key =

C# - Excel - How to delete visible rows after AutoFilter?

十年热恋 提交于 2021-01-29 18:00:40
问题 I´m working on a little commandline tool to extract some data from an excel sheet. I want to delete all rows which are visible after applying an AutoFilter. Unfortunately, I just don´t know how to continue. After some searching, I did not find a working answer for me. Here is what I´ve got so far: oXL = new Excel.Application(); oXL.Visible = false; oWB = oXL.Workbooks.Open(source); oXS = (Excel.Worksheet)oWB.Sheets[1]; Excel.Range filter = oXS.UsedRange; filter.AutoFilter(8, "<>text to filter

Excel: Dynamic range within certain rows + data validation update

雨燕双飞 提交于 2021-01-29 04:41:51
问题 What I have here is small part of my big data set, with lot of drop downs and functions that are calculating everything around. I am just exceeding this table and trying to make it more automatically than it was before, but I stuck on that part that I put in green. Which function might be suitable when I wanna add some new cells on the right (right table) named Model Options > instead of Reserviert but some another name (will be populated later), but to automatically recognize it on left drop

Excel: Dynamic range within certain rows + data validation update

人走茶凉 提交于 2021-01-29 04:40:36
问题 What I have here is small part of my big data set, with lot of drop downs and functions that are calculating everything around. I am just exceeding this table and trying to make it more automatically than it was before, but I stuck on that part that I put in green. Which function might be suitable when I wanna add some new cells on the right (right table) named Model Options > instead of Reserviert but some another name (will be populated later), but to automatically recognize it on left drop

How to handle 'No' or 'Cancel' on Workbook.SaveAs overwrite confirmation?

僤鯓⒐⒋嵵緔 提交于 2020-08-05 08:03:22
问题 I'm want users to be prompted to save a workbook before the VBA script starts modifying content. When the SaveAs dialog box comes up, if the user clicks Cancel I raise a custom error and stop the script. If they click Save and the filename already exists I want them to be asked whether to overwrite. Here's my code: Function SaveCurrentWorkbook(wkbSource As Workbook, strNewFileName As String) As Variant If Not bolDebug Then On Error GoTo errHandler Dim varSaveName As Variant SaveAsDialog:

How to handle 'No' or 'Cancel' on Workbook.SaveAs overwrite confirmation?

匆匆过客 提交于 2020-08-05 08:02:49
问题 I'm want users to be prompted to save a workbook before the VBA script starts modifying content. When the SaveAs dialog box comes up, if the user clicks Cancel I raise a custom error and stop the script. If they click Save and the filename already exists I want them to be asked whether to overwrite. Here's my code: Function SaveCurrentWorkbook(wkbSource As Workbook, strNewFileName As String) As Variant If Not bolDebug Then On Error GoTo errHandler Dim varSaveName As Variant SaveAsDialog:

Case Statement Not Working - VBA

左心房为你撑大大i 提交于 2020-07-30 12:00:52
问题 In my project I have a list of clients that have unique commission calculations (ex. Client_1 has a 0.1% commission rate, whereas Client_2 has a 0.25% commission rate). In my VBA code I made special cases, that vary by the client_id. The problem I'm getting with this code is that even though I put in a special ID, it jumps over the case (ex. if klienta_nr = 100, it skips over the Case klienta_nr = 100 and returns the Case Else). How can I fix this issue? Private Sub CommandButton1_Click() Dim

Putting an Excel UDF into the Worksheet object (as opposed to in a module)

假装没事ソ 提交于 2020-07-16 02:41:04
问题 I suspect the answer is "not possible" - but there is no harm in asking this fine community! I have a Excel 2013 UDF (User Defined Function) that is unique to a certain worksheet. Currently, I have this UDF in a "Module" in the containing Workbook. But what I would like to do, is to place the UDF code in the "Worksheet Object" so it is only available to that particular Worksheet. I have tried, of course, but it is not visible, so I naturally get a #NAME? error. I've tried prefacing the