My VBA code does not work in Office 2007 - vba

I developed and tested some VBA code using Office 2013 and was working perfectly. BUT when I ran it on Office 2007, the code breaks at this line...
ActiveSheet.Range("D6").Value = "=" & Worksheets("Formula").Range("AlarmsStatusFormula").Value
the error msg I received was Run-time error 1004: Application-defined or object-defined error. D6 is part of the same table that contains a column called "Message".
AlarmStatusFormula contains this formula
IF(OR(ISNUMBER(SEARCH({"Recover"," NR"},[Message]))),"FOUND","")
Note the AlarmStatusFormula named range has the workbook scope.
Can it be something to do with the way Excel 2007 handles named ranges vs 2013?
Can you please help with this?

In Excel 2007 it should be TableName[Message] rather than just [Message]

Related

How to do If Error If Vlookup with validations in vba macros [duplicate]

as a continuation from another question, I'm trying to solve my problems inserting a formula via VBA on a macro.
Here's my code:
Range("F1").Select
ActiveCell.Formula = "=IF(C1=""LPPD"";""MIPRU"";IF(C1=""LPGR"";""DCT"";IF(OR(C1=""LPFL"";C1=""LPCR"");""LADOX"";IF(OR(C1=""LPPI"";C1=""LPSJ"";C1=""LPHR"");""NOTMA"";""ERRO""))))"
For some reason, and the code doesn't show any errors, when I try to run it I get:
Run-time error ("Application-defined or object-defined error")
Worth mentioning I'm using Excel 2003.
Hope I'll be able to find my answer with you guys! Thanks in advance.
VBA is US-EN centric, so using the .Formula the formulas must be with , instead of ;:
Range("F1").Formula = "=IF(C1=""LPPD"",""MIPRU"",IF(C1=""LPGR"",""DCT"",IF(OR(C1=""LPFL"",C1=""LPCR""),""LADOX"",IF(OR(C1=""LPPI"",C1=""LPSJ"",C1=""LPHR""),""NOTMA"",""ERRO""))))"
Or you can use .FormulaLocal
Range("F1").FormulaLocal = "=IF(C1=""LPPD"";""MIPRU"";IF(C1=""LPGR"";""DCT"";IF(OR(C1=""LPFL"";C1=""LPCR"");""LADOX"";IF(OR(C1=""LPPI"";C1=""LPSJ"";C1=""LPHR"");""NOTMA"";""ERRO""))))"

Excel Macro opens with run time error 32809

I have an Excel Macro Enabled workbook that I created on Excel 2013. The workbook's macros work well with my computer but does not work on some other computers even if they are using Excel 2013. Works on 7/10 computers I tried both on windows 7 and 8. When I send it to someone's computer that does not work this is what happens:
They open the workbook and once the user clicks "enable content" the workbook errors out "run time error '32809': Application-defined or object-defined error"
debug shows it getting stuck on 2nd line of code below:
private sub workbook open()
Worksheets(1).OLEObjects("ComboBox21").ListFillRange = "impacts"
**Worksheets(2).OLEObjects("ComboBox21").ListFillRange = "yesnoo"** This line errors
if I comment out these two lines, the workbook will open but the combobox21 on worksheet(2) gets renamed to combobox22 and does not work but the first combobox on worksheet(1) loads and functions fine.
I would like to add that if I comment out the lines
Worksheets(1).OLEObjects("ComboBox21").ListFillRange = "impacts"
Worksheets(2).OLEObjects("ComboBox21").ListFillRange = "yesnoo"
I get the error now that "Can't exit design mode because control ' dattimepicker21' cannot be created
I found and fixed the problem, the machines that were not working were missing MSCOMCT2.OCX
http://answers.microsoft.com/en-us/office/forum/office_2013_release-excel/date-picker-dropdown-in-excel-2013/71decdcd-6cc6-4a70-b1ab-20294a2a315a

Insert an advanced formula into a cell

Using Excel 2016 I am struggling to get a formula pasted into a cell with VBA (where the VBA does a data import). I have two sheets: Rapport SNN and Data.
Sheets("Rapport SNN").[E4].Formula = "=SUMIFS(Data!S2:Data!S2000;Data!V2:Data!V2000;""BankAxept"";Data!M2:Data!M2000;C4)/100"
Just throws me a:
Run-time error '1004': Application-defined or object-defined error.
What do I do wrong?
You have semicolons when they should be commas.
WorkSheets("Rapport SNN").[E4].Formula = "=SUMIFS(Data!S2:Data!S2000,Data!V2:Data!V2000,""BankAxept"",Data!M2:Data!M2000,C4)/100"

Run-time error '1004' on closing Excel vba 2013

I'm having a run-time error 1004 on closing the excel sheet. Through my research, most of error 1004 happen when the users are trying to copy the sheet by macro or closing the sheet by macro.
In my case, the error appears even when I close the developer tab and create a new excel file. Some resources I found online include the You may receive a "Run-time error 1004" error message when you programmatically set a large array string to a range in Excel 2003 and some other forum posts. However none of them is applicable in my case since I'm trying to close the file by the 'x' button. Please let me know if should describe the question more accurately. Thanks.

Runtime 9 error in VBA

I wrote the following line of code to find the last row in Column C in my workbook:
lastRow1 = Workbooks("ExcelBook").Worksheets("Prices").Range("C65536").End(xlUp).Row
When I run my macro on my own computer (Excel 2010, Windows 8) it works fine. However, I sent it to a client of mine (Excel 2007, Windows 7) and he gets a "runtime error 9 - subscript out of range"
The same thing also happens if I run the macro on Excel for Mac... Could someone help with this?
Thanks!
I've run into a similar issue, macros not working on certain computers - it could need the full workbook name with the extension. Try
lastRow1 = Workbooks("ExcelBook.xlsx").Worksheets("Prices").Range("C65536").End(xlUp).Row
I had a very similar issue with
dstring = Workbooks("name").Worksheets("name2").Range("name3")
and the issue was solved by adding the extension
dstring = Workbooks("name.xlsm").Worksheets("name2").Range("name3")