vba

Need skeleton code to call Excel VBA from PythonWin

I need to invoke a VBA macro within an Excel workbook from a python script. Someone else has provided the Excel workbook with the macro. The macro grabs updated values from an external database, and performs some fairly complex massaging of the data. I need the results from this massaging, and I don't really want to duplicate this in ...

What is a good way to create a variably sized group to be looped over in Excel 2003?

I have a procedure that is run for a lot of items, skipping over certain items who don't meet a criterion. However, I then go back and run it for some of the individuals who were missed in the first pass. I currently do this by manually re-running the procedure for each individual person, but would ideally like a solution a little more...

Access VBa: to check end of excel file while reporting

Hi, I am writing the results of certain checks on access table to a excel file. Sometimes the results exceed 65k that is more than excel can handle( excel 2002). How do i check the end of the file and open a new sheet for the continuation Thanks ...

What does the keyword Set actually do in VBA?

Hopefully an easy question, but I'd quite like a technical answer to this! What's the difference between: i = 4 and set i = 4 in VBA? I know that the latter will throw an error, but I don't fully understand why. Many thanks! ...

Upgrade from Excel 2003 to 2007 results in "stack overflow error" on previously working vba

The following VBA code works great in Excel 2003, but results in a "stack overflow error" in Excel 2007. The code is required to either unlock or lock certain cells based on a drop-down menu selection. I need to be able to run the code in both Excel 2003 and 2007. Please help. Private Sub Worksheet_Change(ByVal Target As Range) If [E2...

How does the VBA immediate window differ from the application runtime?

I've encountered a very strange bug in VBA and wondered if anyone could shed some light? I'm calling a worksheet function like this: Dim lMyRow As Long lMyRow = WorksheetFunction.Match(vItemID, rngMyRange.Columns(1), 0) This is intended to get the row of the item I pass in. Under certain circumstances (although I can't pin down exa...

Importing/Exporting Relationships in MS Access

I have a couple of mdb files with the exact table structure. I have to change the primary key of the main table from autonumber to number in all of them, which means I have to: Drop the all the relationships the main table has Change the main table Create the relationships again,... for all the tables. Is there any way to export the...

Access VBA: Suppressed Runtime Errors

While I'm developing my MS Access application, I open it with shift click. When an Error occurs, that is not trapped (by ON ERROR ...), a message box pops up informing me about the error. This is a good thing. When a user open my application, he does't shift click, and an appropriate Start Form opens. However, now untrapped Errors don't...

Using a user defined parameter in vba

I have an access database that ouptuts a query to an excel file. The query uses a date parameter to run. This parameter is chosen by the user. I would like to use the parameter in the filename of the export. How can I accomplish that with the minimum amount of code. 01 01 09 Ok the new year has begun. sorry for the delay but I was...

How can I write an Excel macro to select a group of cells?

I'm looking for a macro which can be run to select a consistent range of cells so that I can easily copy them to another spreadsheet. The range would be F3:BJ3. Thanks for your help. nlh ...

MS-Access, VBA and error handling

This is more an observation than a real question: MS-Access (and VBA in general) is desperately missing a tool where error handling code can be generated automatically, and where the line number can be displayed when an error occurs. Did you find a solution? What is it? I just realized how many hundreds of hours I spared since I found th...

Linking Powerpoint and Access through VBA?

Hi, I have a Powerpoint slide that contains textboxes. I would like to link those textboxes with a filtered view of a data table in Access. For ex, if I had a TaskList application in Access that displayed tasks with different priorities and affectations; is there a way to open that file, select that view, and filter it according to a v...

Case sensitive validation in Excel from Named List

I'm using VBA in Excel 2003 to apply validation to apply validation to a given range of cells from a named list. The user can then select from a dropdown list of values. Edit: Here's how I'm setting the validation, given a named range called 'MyLookupList' With validatedRange.Validation .Delete .Add Type...

Excel 2002 Add-In not loading when the application opens

Good afternoon, I created an Excel .xla addin for Excel 2002. This weird behavior I am seeing from it happens only on my machine, but not on my coworkers. I would like to understand why. The add-in has a UDF function that gets called from many, many spreadsheets. My Add-in is set to open when Excel opens. When I open a blank sprea...

QueryInterface for interface VBA._Collection failed

Hi, we are randomly seeing this error during long executions of our system. The error is caught by our alarm system, and we successfully retry, and continue running the system. The only hits we found on Google seem to mention corrupt installations. We do not think this is the case here, since our systems is running, gets the error, and c...

How do I set the background color of Excel cells using VBA?

As part of a VBA program, I have to set the background colors of certain cells to green, yellow or red, based on their values (basically a health monitor where green is okay, yellow is borderline and red is dangerous). I know how to set the values of those cells, but how do I set the background color. ...

Loop through PivotItems: runtime error 91

I have a dataset in a worksheet that can be different every time. I am creating a pivottable from that data, but it is possible that one of the PivotItems is not there. For example: .PivotItems("Administratie").Visible = False If that specific value is not in my dataset, the VBA script fails, saying that it can't define the item in th...

Manipulate a file in code (VB.NET) without executing the file's macros

I have an Excel file that has a bunch of VBA and macro code in it. When I open the file in Excel I can choose not to 'enable' them - so the values in the fields all stay as they were during the last save. I need to manipulate the values as they were last saved - so I don't want the macros (which look at the current date and update valu...

Making Excel macro for fast data entering ::: VBA ::: Excel :::

I have a job to enter survey results (in paper form) to excel. I've never written any macro in Office :( Here I what I basically need: I have predefined columns (|A|B|...|AG|AH|) All surveys are grouped into groups. All surveys from same group have few (like predefined) same columns. It's always same columns that 'define' group All ot...

How to make subject field compulsory in Outlook 2007?

I always forget to write subject in email, so I want make the subject field compulsory. Can you help me please? ...