option explicit

  1. L

    Option Explicit causes names defined in a worksheet to give object needed error in VBA

    Here is my issue: Adding Option Explicit to my code module is causing an 'object needed' error when referencing named ranges within workbooks. Removing Option Explicit allows the code to run as expected. The line that errors out is Set Basewkst = [Criteria] where Criteria is the VBA name of a...
  2. M

    Running macro for another workbook - dosen't wrok

    Hi I have a macro that is to run three macros in another file Two of them run fine but the third I get an error on This is the code for running the macros Workbooks.Open Filename:=FileNameFolder & xlsmFile Application.Run "'" & xlsmFile &...
  3. W

    How to troubleshoot undefined variable when everything defined

    Hi, I just started VBA this year and am struggling to troubleshoot...hoping you can help. I have some code I upgraded today which filters a table and copies the first column to another sheet. It uses a dynamic named range as the header to find the right column to filter (new today). It uses...
  4. J

    "variable not defined" error with "sub" highlighted

    Hi all, I have a loop code as per below, which works fine in the original spreadsheet for which it was written. Although the row containing "Sub Matrix2DB()" is highlighted yellow. BUT when copying to a new spreadsheet, with all of the sheets, columns and rows set out as required in the macro...
  5. S

    Copy/paste without clipboard "Object required" ?

    Windows 7 excel 2007 Im real new at VBA (but do know some PHP if that helps lol) ANYWAY a website had a way to copy and past without using the clipboard link here: "Optimize Slow VBA Code. Speed Up Efficient VBA Code/Macros" Sub Testing() Sheet1.Range("A1").Copy Destination:=Sheet2.Range("B1")...
  6. E

    Conditional Formatting with VBA and xlExpression Formula1: with VBA Variables and Text

    Hello Mr. Excel! I want to start by saying a quick thank you! I love this site. I have tried to find answers in previous posts but I haven't found anything to find material that applies directly here, yet. I've been using VBA to new worksheets that compile information from a "Source"...
  7. T

    How to duplicate option explicit VBA code excel 2010

    I have used the information from another post but this is a new type of enquiry. Originally Posted by Ruddles Create the "timestamp info" worksheet by hand, make the top row bold and freeze it. Paste the following code into the code module for your main worksheet - the one where B321...
  8. J

    Option Explicit causes error with CopyFromRecordset?!? Excel 2007, SQL Server 2008 R2

    I've encountered an odd error in an Excel 2007 VBA sub. The code queries a SQL Server 2008 R2 database, then copies the recordset to a worksheet in the Excel workbook. If I don't specify Option Explicit, it works fine, but if I add Option Explicit I get the error "Class does not support...
  9. R

    variable not defined issue

    Morning, I'm getting a Variable Not Defined error and would be grateful of some help, or to be pointed in the right direction please. in my workbook_open I have the following code Dim workround As Integer workround = 0 in one of my sheets worksheet_change I have If workround = 0 then...
  10. V

    VBA error excel to website submission

    Hello all, What I am trying to do is to take several parts of data from an excel sheet and move them to a ticketing system we use to log tickets. So far i have: Sub Fill_Form() Set IE = CreateObject("InternetExplorer.Application") With IE .Visible = True ' im using facebook as an example...
  11. A

    Macro won't run with Option Explicit

    I have a macro that changes the font color and font size of a cell. It is located in a module that contains several other macros. If I declare Option Explicit in that module, the macro will not run. I get an "compile error" message stating that the variable "font_size" is is not defined. If I...
  12. D

    Option Explicit

    Hi there,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p> <o:p></o:p> I am working on a template for a report, and I got stuck with something.<o:p></o:p> <o:p> </o:p> I have the function "Option Explicit" activated, and the last of the macros must search...
  13. Colin Legg

    Who uses Option Explicit?

    Following on from the Personal.xls poll, I thought it would be interesting to gauge how many VBA'ers on this board use Option Explicit to enforce variable declaration. I thought there might be a trend relating to how long peeps have been coding in VBA so I've broken the poll into categories...

Some videos you may like

This Week's Hot Topics

Top