excel-vba

Create dynamic named range in VBA that references ListObjects table

喜欢而已 提交于 2020-01-16 06:46:29
问题 I need to create a named range that refers to the last few rows of data in a ListObject table. While I can do it manually from the ribbon (Formulas > Define Name) I have to do this across 20 sheets with 3 ranges each. When I try this using VBA I get error 1004 and a warning that there's a problem with the formula and to remove the "=" if I'm not trying to enter a formula. Any ideas how to resolve this? Open a fresh Sheet1 to try my code. It'll create a ListObjects table and will try to create

Copy and paste formula result as value

旧城冷巷雨未停 提交于 2020-01-16 05:55:49
问题 I wanted to know if able to paste the result of the formula below into a value in VBA. I would like to copy the formula from my temporary workbook and paste it in another workbook. =LEFT(C32,SEARCH("invoice",C32,1)-1) 回答1: Yes. Here is an example Range("A32").Formula = "=LEFT(C32,SEARCH(""invoice"",C32,1)-1)" Range("A32").Value = Range("A32").Value '~~> This will convert the formula into value 来源: https://stackoverflow.com/questions/20119277/copy-and-paste-formula-result-as-value

Greyhound data import to excel macro formula

无人久伴 提交于 2020-01-16 05:47:06
问题 as part of a research project i need to extract as much data as possible from a webpage. The problem is to access each table i have to follow lots of links which I can't get to work automatically. Its from a greyhound-data.com. So an example would be I want to extract all the racing stats for every dog that raced in swindon between 1st Jan 2017- 28th Feb 2018. When i put it in the search engine I get 57236 races in a table. I have to follow the link on name of race for each race.. http://www

Multi conditional statistics (avg, std dev, z-scores) for large data sets in Excel/VBA

大憨熊 提交于 2020-01-16 05:20:22
问题 I'm looking to calculate statistics for a large data set on Excel and encountering some issues due to data set size. It seems VBA may be the way to go, as copying AVERAGEIF and STDDEV array functions across data this size is causing long calculation times. Appreciate possible solutions or code that could be used here. Goals: To calculate statistics (avg, std dev, z-scores) conditional on 2 identifiers (e.g. average of all heights at 01/01/10) Able to handle large data sets (100k+ data points)

Converting XLS/XLSX files in a folder to CSV

南楼画角 提交于 2020-01-16 05:17:06
问题 I have written the following code in VBA. When debugging, I am not able to find any problems. It is not creating nor converting any file into .CSV. Sub SaveToCSVs() Dim fDir As String Dim Wb As Workbook Dim wS As Worksheet Dim csvWs As String, csvWb As String Dim extFlag As Long '0 = .xls & 1 = .xlsx extension types Dim fPath As String Dim sPath As String, dd() As String fPath = "C:\Users\DA00358662\Documents\XLSCONV\*.*" sPath = "C:\Users\DA00358662\Documents\XLSCONV\" fDir = Dir(fPath)

Excel VBA Shell command with spaces in file path

你。 提交于 2020-01-16 05:15:08
问题 Public Sub openEntryFiles() Dim filePath, shellCommand, agingsEntry, invenEntry As String filePath = Range("CustomerPath").Value2 & "\files\" agingsEntry = "agings\entry_EP.bat" invenEntry = "inven\entry_EP.bat" shellCommand = """%ProgramFiles(x86)%\TextPad 5\TextPad.exe"" -r -q -u """ & filePath & agingsEntry & """ -u """ & filePath & invenEntry & """" Debug.Print shellCommand Shell shellCommand, 0 End Sub I am trying to write a subroutine that will run a shell command with spaces in the

Shell.namespace not accepting string variable, but accepting string itself

流过昼夜 提交于 2020-01-16 04:31:08
问题 I have a code, in which I want to loop through files in a folder, check their built-in or custom document properties (without opening them), and later open those, which are meant to be open. To do this, I'm using Shell and to set the folder I'm using Shell.Namespace . The problem is with the Namespace , I guess. When I use a variable strSuborCesta for the path it doesn't work . When I print the variable strSuborCesta into immediate window and use the printed string inside the Shell.Namespace(

Results depending if value found excel vba

纵然是瞬间 提交于 2020-01-16 04:15:06
问题 I have 4 columns with names list. All columns are from different excel files. I want the value from cells from column E to change in Y or N depending if the value from column D is found in other columns A,B,C: -Y: (if D is found in A) -N: (if D is found in A and B) or (if D is found in C) or (if D is not found in A and B and C) This is what i have until now : Sub find_if_in_a_and_b() Dim FindString As String Dim Rng As Range Findcell = Sheets("Sheet1").Range("D:D") If Trim(Findcell) <> ""

Excel VBA : WorkSheet_FollowHyperlink is not getting called for Shape Object ( msoPicture )

牧云@^-^@ 提交于 2020-01-16 02:24:08
问题 I need to have a macro executed when someone clicks on the shape in the worksheet which is a picture. The macro intention is to display more information regarding the shape on which the user clicked. EDIT: I also needed an information display during mouse-rollover, hence used hyperlink method. I followed the method outlined in the MSDN , but the macro just doesn't seem to run. My Macro is as follows: Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) MsgBox "Source: Target.Range

Delete rows not equal to combobox value?

不羁的心 提交于 2020-01-16 02:03:06
问题 I am trying to delete rows that are not equal to a combobox value that is selected. I have the following code, but i get a run-time error 424 Object required. Can anyone assist? Dim wkss As Worksheet, wkJob As Worksheet Dim i As Long Set wkss = Sheets("TempWs6") Set wsJob = Sheets("Job") wkss.Select For i = Cells(Rows.Count, 10).End(xlUp).Row To 1 Step -1 If Cells(i, 10) <> wsJob.ComboBox1.Value Then wkss.Rows(i).Row.Delete End If Next i Thanks much! 回答1: To delete a row, you'd use EntireRow