excel-vba

Best way to distribute Excel spreadsheet with VBA

I am trying to find out how to distribute an excel file on the net in such a way that most users will be able to use it. I am aware of the Microsoft Excel Viewer (which can open Excel files without having Office installed), but it doesn't run VBA code, which is a necessity for this file. Moreover, there are some changes to the API in O...

(Excel 2002) Formatting Lost on Pivot Chart Update

I have a set of Pivot tables/charts automatically created from VBA code with custom formatting. When I change the selection of data to be displayed from the drop down list in the chart, the custom formatting reverts back to the chart type's default display. The underlying chart data is not changed, only what's displayed on the chart. W...

What does the Excel VBA range.Rows property really do?

OK, I am finishing up an add-on project for a legacy Excel-VBA application, and I have once again run up against the conundrum of the mysterious range.Rows(?) and worksheet.Rows properties. Does anyone know what these properties really do and what they are supposed to provide to me? (note: all of this probably applies to the correspond...

Appending html files in VBA

I have an Excel report with a bunch of sheets, each with a table of data. I need to make a button that will create one html page containing the tables, one after the other. I don't know much about html, so my first approach was to have a macro that creates another worksheet with the tables on it, and then saves that sheet as html using...

Programmatic positioning of VBA charts has stopped working

I was using this routine, triggered by the Worksheet_Change event, to display a selected chart and move all other charts to a holding position off screen. Sub shuffleCharts(chartName As String) Dim analysisChart As ChartObject For Each analysisChart In ActiveSheet.ChartObjects With analysisChart .Left = 1575...

Run a query from two data sets programmatically

I am trying to reconcile data from a website and a database programmatically. Right now my process is manual. I download data from the website, download data from my database, and reconcile using an Excel vlookup. Within Excel, I am only reconciling 1 date for many items. I'd like to programmatically reconcile the data for multiple date...

(Excel 2002) Pivot Chart Loses Data Selection option after Deselection

I have a Pivot Chart with data used as row labels. When an option is deselected, the option disappears from the filter list and has to be readded back, which is non ideal since it has been relabelled and the relabelling is lost when that data field is added back in. Before deselection: http://farm4.static.flickr.com/3364/3661401099_c76...

Excel VSTO sort dialog box C#

I'm trying to rewrite some VBA code in Excel VSTO. The VBA code is as follows: Application.Dialogs(xlDialogSort).Show When I try to do the same in VSTO I find that the same method needs 30 arguments! The signature is "Show(object Arg0,object Arg1, etc.)" Globals.RiskViewerWorkbook.ThisApplication.Dialogs[XlBuiltInDialog.xlDialogSort...

How can I count to 10 while summing the numbers in Excel VBA?

How can I count to 10 while summing the numbers in VBA? ...

c# excel: where is VBComponents...

hi i am working with c# and excel-2007... i wanted to add a macro to excel and run from c#, for which i think i need access to the VBComponents but unfortunately i cannot see it after i do the following wb.VBProject. should i add any com objects? or what should i do to see the VBComponents... i already have using Excel = Mi...

macro problem

I'm trying to run the below mentioned code in VB(Excel Macro) but i m stuck with an error which pops up on running saying "Automation Error". strComputer = "." Set objNetwork = CreateObject("Wscript.Network") Set fs = CreateObject("Scripting.FileSystemObject") Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2"...

How do I invoke the IE 'onblur' event from VBA code in Excel?

Situation: I am working to populate text entry boxes in a webpage with data from Excel. When the data is entered manually and the focus is moved to another text box, the 'onblur' event is fired to do input validation. Desire: I want to be able to cause the 'onblur' event to be fired when I populate the same text boxes from VBA code ...

excel formulaarray

hi why do i get the runtime error 13: type mismatch error while running the following code Application.Goto Reference:="R1C1:R232C221" Selection.FormulaArray = "=ROUND(a(),0)" Selection.Replace What:="a()", Replacement:="IF(IF(Sheet4!A1:HM232+Sheet5!A1:HM232=2,0," & _ "Sheet4!A1:HM232+Sheet5!A1:HM232)+IF(Sheet4!A1:HM232+Sheet5!A1:HM2...

Excel 2007 - Catch open command bar button event

Hello, Prior to Excel 2007, we used to catch the open file event in Excel using vba so that we could show our own open dialog that knew how to find client folders. In Excel 2007 this no longer works, does anyone have any ideas on how it works now> The basic premise before was create a class with a commandbar button and a related event ...

So my Excel-VBA project password can easily be cracked... What are other options?

Now that I know that there is an easy workaround to the standard way of locking and password-protecting VBA code, I'd like to move on to more effective ways of protecting code. I am to deliver an Excel-based tool to a client, but would like something more than simple annoyance-type protection that will only deter the very laziest of hack...

Setup an Excel template so calculations are not dependant on a specific number of columns / rows

Problem Statement: I'm creating a template for multi tiered complicated calculations in MS Excel that depend on a few input "n x 3" matrices. It is really difficult to redesign the 15 sheets or so (200 ~ 300 lines each) every time I have a different "n" where "n" ranges from 3 to 900. Goals: I'd like to input the number of "n" in ...

Elegant way to highlight chart data series in Excel

I want to outline the chart data range source(s) in a table, in much the same way that the GUI will outline a range in blue if the chart data series is clicked. The user can choose various chart views and the range highlight colours for each data series need to match those displayed in the chart. For the record, here are the methods I ...

A Macro to wrie a Private Macro in ThisWorkBook

I was wondering if there was a way I could write a macro that would write a macro to the ThisWorkBook Workbook Open module??? ...

Build a tree like representation of data in Excel?

I have a bunch of raw data in this fashion: Parent | Data --------------- Root | AAA AAA | BBB AAA | CCC AAA | DDD BBB | EEE BBB | FFF CCC | GGG DDD | HHH Which needs to be converted into a tree like fashion. This basically needs to end up in an excel spreadsheet. How can I convert the above data into ...

Error 1004 when inserting lookup formula in Excel 2000

I've got the following code to look up the date at which a value occurs in a separate sheet in Excel 2000: sSheet.Range(dateColumn & pRow) = _ "=lookup(" & valColumn & pRow & ";'" & _ iSheet.Name & "'!" & tColumn & firstRow & ":" & tColumn & lastRow & ";'" & _ iSheet.Name & "'!" & dateColumn & firstRow & ":" & dateColu...