excel-vba

Excel VBA to list key bindings (OnKey ?)

你。 提交于 2020-01-11 05:11:35
问题 I am working with a large set of Excel vba scripts and some of them are bound to Ctrl-key combinations. I know how to set one at a time in the user interface for Excel: Pull up the list of vba scripts (Alt-F8), select a script, and click Options. Then you can bind/unbind the script to a Ctrl-key combo. However, you can bind more than one script to the same key, and Excel will pick one (probably the first one it finds in some manner) and ignore the other bindings. So, I want to assign Ctrl-e

Running VBA script causes excel to stop responding

ぃ、小莉子 提交于 2020-01-11 05:08:07
问题 I have a VBA script that adds sheets to around 500 excel files. I had no problems running the VBA script and adding simple sheets, but when I try to add a sheet with VBA script in it and graphs and buttons, it works for a while and than freezes. Here is the code. I know it does not have error handling - any suggestions how to tackle this problem or maybe what is causing excel to freeze? Sub FindOpenFiles() Const ForReading = 1 Set oFSO = New FileSystemObject Dim txtStream As TextStream Dim

Excel VBA efficient get file names function

荒凉一梦 提交于 2020-01-11 04:55:08
问题 I need to get a collection of file names from a folder on a remote server using VBA in excel 2010. I have a function that works and in the majority of cases it would do the job, however the remote server frequently has terrible, terrible network performance issues. This means that looping through say 300 files to put their names into a collection can take 10 minutes, the number of files in the folder is likely to grow to thousands so this is not workable, I need a way to get all of the file

Excel VBA: function to turn activecell to bold

巧了我就是萌 提交于 2020-01-11 04:32:28
问题 I have the following function inside my module. Function Colorize(myValue) ActiveCell.Select Selection.Font.Bold = True Colorize = myValue End Function The cell that will use this function should be turning bold - however, I get no error messages back and sad but true, its not turning bold. What am I missing? Thanks 回答1: A UDF will only return a value it won't allow you to change the properties of a cell/sheet/workbook. Move your code to a Worksheet_Change event or similar to change

Copying range including formatting when pasting in Outlook email body

こ雲淡風輕ζ 提交于 2020-01-11 04:09:13
问题 I had search all over of this question and still not get the exact codes for it. I need to copy the color of the pivot table from excel to outlook body. When running the code i got the format but the only problem is the color of the table is turning into black and grey. Please help me to figure it out how to put the exact color that i need. This is my codes: Sub AUTO_MAIL() Dim rng As Range, rng2 As Range, rng3 As Range, rng4 As Range, sub1 As Range, sub2 As Range, sub3 As Range, sub4 As

Excel 2010 VBA macro to change the content of a module in another file

六月ゝ 毕业季﹏ 提交于 2020-01-11 03:36:05
问题 I have developed a macro to mass update files in a file location. Im using the following code, which works perfectly, however the Edit part of the script requires changes in a VBA module in each of the files for the changes in the call edit macro to work. How can i also mass update the module contents when performing the mass file update. Sub Auto_open_change() Dim WrkBook As Workbook Dim StrFileName As String Dim FileLocnStr As String Dim LAARNmeWrkbk As String PERNmeWrkbk = ThisWorkbook

Excel VBA: Get Last Cell Containing Data within Selected Range

∥☆過路亽.° 提交于 2020-01-11 03:30:51
问题 How do I use Excel VBA to get the last cell that contains data within a specific range, such as in columns A and B Range("A:B") ? 回答1: using Find like below is useful as it can find the last (or first) cell in a 2D range immediately testing for Nothing identifies a blank range will work on a range that may not be contiguous (ie a SpecialCells range) change "YourSheet" to the name of the sheet you are searching Sub Method2() Dim ws As Worksheet Dim rng1 As Range Set ws = Sheets("YourSheet")

vba convert week number (and year) to date?

本秂侑毒 提交于 2020-01-11 02:35:40
问题 I have a week number in Cell C13 and a year in Cell C14. I am using the below formula to convert this into the Thursday of that week number's date: =DATE(C14,1,-6)-WEEKDAY(DATE(C14,1,3))+C13*7 How could i do the same thing using VBA? 回答1: For a specific year , you can do it like this : DateAdd("ww", WeekNumber - 1, DateSerial(2017, 1, 5)) And to test it : Debug.Print Format(DateAdd("ww", WeekNumber - 1, DateSerial(YearNumber, 1, 5)), "ddd d MMM yy") If others are looking into this and don't

How do I reference charts with the same name, but on different worksheets?

隐身守侯 提交于 2020-01-10 23:24:38
问题 I have two worksheets containing charts, and use a macro to run over all the sheets with charts in them and update the values charted. However, I run into a problem when attempting to reference the charts in the sheets after the first one - although the reference for the worksheet changes, the reference to the chart does not. The loop looks like this: For Each ws In ThisWorkbook.Worksheets Debug.Print ws.Name Debug.Print ws.ChartObjects("Kortsone").Chart.Name With ws.ChartObjects("Kortsone")

Text entered into Webpage Search Box via Excel VBA is not detected when clicking Search button

淺唱寂寞╮ 提交于 2020-01-10 20:12:32
问题 I'm having trouble when trying to click a search button on a webpage via Excel VBA. Actually, my real issue has to deal with the particular webpage not seeing that I entered something in the search box. After I click the search button on the webpage I get the message saying "Provide a number or company name to search" when there's already something in the search box. Before the Text is entered into the Search Box: After the Text is entered into the Search Box & the Search button is clicked: