excel-vba-mac

Loop to last row while adding rows

我们两清 提交于 2019-12-12 04:31:50
问题 My loop is breaking a few thousand lines before the last row. Let's say last row is up to 12000, its looping until 9800. For i = 2 To lastrow If ws.Cells(i, 2).Value = "4" Then Rows(i).Insert Range("E" & i).Value = ws.Cells(i + 1, 5) i = i + 1 lastrow = lastrow + 1 End If Next i 回答1: @Nathan_Sav makes a good point. I'm not sure how the i = i + 1 and Next i interact with each other. I'd try it this way: i = 2 While i <= lastrow If ws.Cells(i, 2).Value = "4" Then Rows(i).Insert Range("E" & i)

Highlight Duplicate Rows - Entire Row vs Entire Row

被刻印的时光 ゝ 提交于 2019-12-12 02:46:24
问题 I cant believe how difficult this has been. I want to find all duplicate rows. Columns A:R, dynamic row count. I know how to delete the rows. But I just want to highlight them. My data is in a listobject (table) if that helps. NO! I do not want to use conditional formatting. I have already done that. It works. People always want examples, but I have re-written this so many times, here are the last two I have tried: Again, my range is x.Range("A4:R380"). Looking how to identify duplicate rows

Handling huge Excel file

懵懂的女人 提交于 2019-12-12 02:30:12
问题 Need your help badly. I am dealing with a workbook which has 7000 rows X 5000 columns data in one sheet. Each of this datapoint has to be manipulated and pasted in another sheet. The manipulations is relatively simple where each manipulation will take less than 10 lines of code (simple multiplications and divisions with a couple of Ifs). However, the file crashes every now and then and getting various types of errors. The problem is the filesize. To overcome this problem, I am trying a few

Open Print Dialog on Mac

让人想犯罪 __ 提交于 2019-12-12 01:59:49
问题 The VBA code below opens the print dialog on Windows but is not working on Mac Excel 2011, giving a runtime error 1004 on the line Application.Dialogs(xlDialogPrinterSetup).Show Private Sub cbPrint_Click() Dim Caption As String If formPrintOptions.Frame1.ActiveControl.Value Then Caption = formPrintOptions.Frame1.ActiveControl.Caption formPrintOptions.Hide Application.Dialogs(xlDialogPrinterSetup).Show Select Case Caption Case "Id1" ThisWorkbook.Sheets(Array("FrontPage", "Id1")).PrintOut

Inserting data from EXCEL into a DB

亡梦爱人 提交于 2019-12-11 20:15:54
问题 ' Create the Connection and Recordset objects. Set conn = New ADODB.Connection Set rs = New ADODB.Recordset Dim val As String val = Range("B5").Value ' Open the connection and execute. conn.Open sConnString Dim item As String item = "INSERT INTO [IndustrialComp].[dbo].[Header](" item = item & " [server_name] " item = item & " )Values(" item = item & " '" & val & "')" conn.Execute item The above code inserts whatever vale is in B5 into a sql server 08 databse (industcomp) a table called header

Excel VBA QueryTable Parameter Fails with Null Value

早过忘川 提交于 2019-12-11 18:28:00
问题 Is it possible to pass a NULL value to QueryTable.Parameters for use in a (My)SQL query? From this other answer, we can see that it's possible to do this with ADODB.Command , but unfortunately, ADODB is not available in Excel for Mac, and the application I'm developing should work on both Windows & Mac. The below is confirmed to error with Windows (and I'd assume Mac). The following VBA code works fine if you set param_value to anything but Null, but as soon as you try with a Null, it fails

Dir() in Excel for Mac 2016 causes crash

本秂侑毒 提交于 2019-12-11 17:18:40
问题 I am trying to iterate through files using Dir, and I understand that it works differently on Mac than windows. This question has been helpful, but I have been unable to implement the solution suggested. The first call to Dir successfully returns a desired filename, but the second call crashes excel. I would like to implement a pattern like this: Sub printFileNames() Dim path as String Dim fileName as String path = ThisWorkbook.Path & "/SUBFOLDER/" fileName = Dir(path, MacID("XLSX")) While

VBA Match Function & Nested For Loops Troubleshooting

点点圈 提交于 2019-12-11 16:24:41
问题 I have two sheets. One is a table and contains data that I want entered into the other. The other looks almost like a gantt chart, with names down the side and dates across the top (see here). I want the program to run in the manner specified below but run as is, it returns: Run-time error '438': Object doesn't support this property or method on For Each Row1 In Resource I have attempted various fixes but each time I adjust one error, I seem to cause another! Check the table column "Resource

Is there a Mac/PC variant of Application.GetOpenFilename?

时光毁灭记忆、已成空白 提交于 2019-12-11 13:39:44
问题 Is there a universal OS variant of this? I am looking to have this code work on a Mac and PC, but this seems only to work on a PC. strFile = Application.GetOpenFilename("Text Files (.csv),.csv", , "Please selec text file...") 回答1: It works in MAC (Excel 2011) As well. See screen shot FOLLOWUP Upon discussion in chat as I suspected the error was not with Application.GetSaveAsFilename but something else. In this case it was Application.GetOpenFilename Now Application.GetOpenFilename definitely

Mac Excel 2011 VBA UDF not working - SET or FIND command seems to be the issue

心不动则不痛 提交于 2019-12-11 10:46:35
问题 I am converting a spreadsheet from Excel 2007 to Mac Excel 2011. I have tried for hours to solve my problem, without success, so any help would be appreciated! This UDF finds a string in a range, then returns the value one cell below the found cell. The SET command returns nothing in the Mac version, but works in Excel 2007. Function FindRng(Fnd As String) Application.Volatile Dim Rng As Range If Fnd = "" Then FindRng = 0 GoTo 109 End If With Sheets("Matrix").Range("G2:FZ13") Set Rng = .Find