excel-2010

Excel VBA Run-time error '13' Type mismatch

泄露秘密 提交于 2019-11-27 03:33:12
问题 I created a macro for a file and first it was working fine, but today I've been opening and restarting the file and macro hundreds of times and I'm always getting the following error: Excel VBA Run-time error '13' Type mismatch I didn't change anything in the macro and don't know why am I getting the error. Furthermore it takes ages to update the macro every time I put it running (the macro has to run about 9000 rows). The error is in the between ** **. VBA: Sub k() Dim x As Integer, i As

How to select clear table contents without destroying the table?

旧时模样 提交于 2019-11-27 03:22:36
问题 I have a vba function in excel 2010 that I built using help from people on here. This function copies the contents of a table/form, sorts them, and sends them to the appropriate tables. Now after running this function I want the original table to be cleared. I can achieve this with the following code, assuming ACell has been defined as the first cell in the table. ACell.ListObject.Range.ClearContents works fine, the only problem is it deletes the table as well as the data values. Is there any

Find the current user language

六月ゝ 毕业季﹏ 提交于 2019-11-27 03:15:05
问题 How can I tell the current user language in a vba program? I need this to show a form in an appropriate language. 回答1: My initial code (utilising this vbforum code) assumed that Windows and Excel share a common language - likely but not bulletproof. updated The revised code: Returns the Locale ID (LCID). Looks up the LCID from this msft link. Parses the LCID using a regexp to get the language. Sample output on my machine below The code will let the user know if there are any errors in

Insert picture into Excel cell [closed]

 ̄綄美尐妖づ 提交于 2019-11-27 03:04:39
I'm tying to generate a report with pictures, but I cannot get the pictures into a single cell. I can get the pictures to "float" around my worksheet, but I need to put them into a cell. How can I do this? Amber You can add the image into a comment. Right-click cell > Insert Comment > right-click on shaded (grey area) on outside of comment box > Format Comment > Colors and Lines > Fill > Color > Fill Effects > Picture > (Browse to picture) > Click OK Image will appear on hover over. Microsoft Office 365 (2019) introduced new things called comments and renamed the old comments as " notes ".

Excel formula to get week number in month (having Monday)

巧了我就是萌 提交于 2019-11-27 02:55:11
问题 Using excel formula I need to get week number in month from a given date. But, the condition is it should have Monday in it. Monday through Sunday is the work days. I have tried this: But, week number is given as 5, where as it should be 4 because 1st November 2013 was Friday, so it would be calculated in October's last week. 回答1: If week 1 always starts on the first Monday of the month try this formula for week number =INT((6+DAY(A1+1-WEEKDAY(A1-1)))/7) That gets the week number from the

When one should use Set [e.g for SpecialCells return value]?

浪子不回头ぞ 提交于 2019-11-27 02:16:44
I am afraid I misunderstand the documentation of VBA for excel, I have this line which seems to be an error: Range a = Selection.SpecialCells(xlCellTypeConstants, 23) But this one is just fine: Set a = Selection.SpecialCells(xlCellTypeConstants, 23) The documentation claims: Returns a Range object that represents all the cells that match the specified type and value. But it actually returns a byRef object and that is why I have to use Set . What do I miss here? Here is Range.SpecialCells method help in Excel: Range a = Selection.SpecialCells(xlCellTypeConstants, 23) This is not valid VBA,

Optimizing Excel formulas - SUMPRODUCT vs SUMIFS/COUNTIFS

为君一笑 提交于 2019-11-27 02:12:19
According to a couple of web sites, SUMIFS and COUNTIFS are faster than SUMPRODUCT (for example: http://exceluser.com/blog/483/excels-sumifs-or-sumproduct-which-is-faster.html ). I have a worksheet with an unknown number of rows (around 200 000) and I'm calculating performance reports with the numbers. I have over 6000 times almost identical SUMPRODUCT formulas with a couple of difference each times (only the conditions change). Here is an example of what I got: =IF(AFO4>0, (SUMPRODUCT((Sheet1!$N:$N=$A4) *(LEFT(Sheet1!$H:$H,2)="1A") *(Sheet1!$M:$M<>"service catalog") *(Sheet1!$J:$J="incident")

Sheet protection: UserInterFaceOnly gone

一个人想着一个人 提交于 2019-11-27 02:09:56
In VBA Excel if I protect sheets with UserInterFaceOnly:=True option after I close and open the file again the UserInterFaceOnly mode is not active, only Password protection. The code: ActiveSheet.Protect Password:="myPassword", UserInterfaceOnly:=True Why? carlossierra You can't do it without reapplying UserInterfaceOnly:=True after reopening the workbook. Taken from Excel's Vb protect method reference: If you apply this method with the UserInterfaceOnly argument set to true and then save the workbook, the entire worksheet (not just the interface) will be fully protected when you reopen the

Determine if cell contains data validation

坚强是说给别人听的谎言 提交于 2019-11-27 02:09:53
I am writing a VBA code that goes through a range of cells checking if each cell has data validation (drop down menu) and if not assign one to it from a list on another sheet. I currently have trouble with the line that checks if the current cell already has data validation. I get error 1004 "no cells were found". Sub datavalidation() Dim nlp As Range Dim lrds As Long Dim wp As Double Dim ddrange As Range Sheets("DataSheet").Select lrds = ActiveSheet.Range("A1").Offset(ActiveSheet.rows.Count - 1, 0).End(xlUp).Row Set nlp = Range("I3:I" & lrds) For Each cell In nlp 'error on following line If

macro - open all files in a folder

烈酒焚心 提交于 2019-11-27 01:23:14
问题 I want to open all files in a specified folder and have the following code Sub OpenFiles() Dim MyFolder As String Dim MyFile As String MyFolder = "\\ILAFILESERVER\Public\Documents\Renewable Energy\FiTs\1 Planning Department\Marks Tracker\Quality Control Reports" MyFile = Dir(MyFolder & "\*.xlsx") Do While MyFile <> "" Workbooks.Open Filename:=MyFolder & "\" & MyFile Loop End Sub The problem I have is that it just keeps trying to open the first file in the folder repeatedly and won't move on.