excel-vba

Excel tables as the datasource in VBA

I want to query the table (Named range) from vba using SQL. name id Alpha 1 Beta 2 Gamma 3 I want to query like, "select Name from table1 where id =3" in VBA can someone help with the connection string that needs to be used. thanks! Srin ...

VSTO excel addin gets unloaded after button click event is handled

Hi, I have created a addin for excel, where there is a ribbon and a button on it. I have handled the event of button click with the following code Private Sub test_button_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles test_button.Click Dim activeWorksheet As Excel.Work...

How do I ignore certain events in Excel VBA for App_SheetChange?

I have an App_SheetChange() handler in an add-in that does some processing as modify their spreadsheets. I've already optimized the handler to only perform the processing if the user's update happens within the range that the processing is dependent on (only one column). But when users delete rows or insert rows, I don't need my routin...

Can't Kill xls files

I have been using every version of Kill routines to delete xls files in the current directory with no success. Here is my code. I want to delete every xls file except wbCntl. Stepping through this code shows that everything works with the exception of the Kill swb command. (swb is public defined as a string) 'Close all files exce...

how to execute a vba macro every 30 minutes automaticaly ?

I'm working on a project to send alert notifications to a mailing list. I've an excel file with a vba macro that permit its updating from a datatbase. I need to execute the macro in the file automaticaly every 30 minutes without having to open the file. i've been told to write this macro in a separate program, but i don't know how to do ...

Excel VBA Macro, Exclude/Include specific lines in HTML export macro.

Hi there, Backstory: I've been building a back-end CMS/database for a client to manage his bar's ever changing drink menu, however the CMS/database will no be ready for use for a while, and thus I also need a temporary solution to help update the website's menu. Situation: The client prints the bar's menus daily from a formated Excel...

Excel 2003 VBA: Move a sheet into a new workbook that is referenced by a variable

Hi I have a function that is meant to run the ShowPages() command of a PivotTable and then save each sheet to a separate file. Here's how I wish I could do it: Sub Split() ThisWorkbook.Sheets("Data").PivotTables("Data").ShowPages PageField:="Codename" Dim newWb As Workbook For Each s In ThisWorkbook.Sheets If s.Na...

Excel Confidence

Hi all, Just have a simple question. Does CR11 R2 has CONFIDENCE function from Excel? http://support.microsoft.com/kb/828124 If not how do I get confidential value? ...

Coloring a range of cells in Excel using VBA

I have a spreadsheet that I use at work to keep track of returned contracts. I've set up a color key so I can quickly glance at the sheet to see which contracts still need to be returned to us and which account manager the account belongs to. The account manager's initials are listed in column A; from there I would like to color the ...

Efficiently assign cell properties from an Excel Range to an array in VBA / VB.NET

In VBA / VB.NET you can assign Excel range values to an array for faster access / manipulation. Is there a way to efficiently assign other cell properties (e.g., top, left, width, height) to an array? I.e., I'd like to do something like: Dim cellTops As Variant : cellTops = Application.ActiveSheet.UsedRange.Top The code is part of a ...

Start empty Excel workbook without any worksheets

Creating a new Excel workbook as in: Dim xl As Excel.Application Dim wb As Excel.Workbook Set xl = New Excel.Application xl.Visible = False Set wb = xl.Workbooks.Add Is there an easy way to stop Excel automatically creating Sheet1, Sheet2, Sheet3? I can always delete these unwanted sheets afterwards but that feels like a clunky solut...

Connect Excel to Oracle

Hi Can we connect from excel (excel-VBA) to oracle(in a remote server) without installing oracle client in the client system... I tried all the options below but it is throwing error as oracle client should be installed. below is the connectionstring i have used 1)strConnection = "Provider=OraOLEDB.Oracle;Data Source=SourceName;User I...

Using a TableName instead of Named Range in Excel datasource SQL Query

In Excel VBA, I am using Excel as datasource for some queries. I am using the query as SQL = "Select * from [NameRange1]" - This works But, I want to use a table name instead of Namerange(Excel 2007 Tables). How do I use that? I tried "select * from [Table1]" and I also tried creating a Namerange for this table1 and it didn't wor...

Excel VBA Set Cell Formula Error

This one has me stumped. When I set the formula for a selected cell in a ListObject, if the ListColumn is empty, Excel fills the formula for the whole column, rather than just the Selection. I have duplicated this in a separate workbook. Create a Table Insert a five or so rows Click on (select) one of the cells in the column Execute ...

how to defalt current year in Drop Down excel

Hi all, How i using current year to default in drop down excel 2003 as I know i can using Sheet30.Shapes("Drop Down 3").ControlFormat.Value = 1 in code, but how to do for current year. Thanks for all ...

How to find smallest values in AutoFiltered range?

I have a column with two value ranges, specifically 0-30000 and 60000+ from which I need to extract the smallest two values in the 60000 range. The only way I have found so far to to use AutoFilter to produce the subset of the required data to extract. My problem is that the Autofilter function does not return a reference to a range. If...

Conditional selecting and pasting in excel

Hi guys, I am quite new to VBA coding so I was hoping you could help me with the following problem. I am looking for the best way to organize the following: From one set of data I am getting different sorts of documents (all have a certain document type) with their information (e.g. customer name, address, amount, VAT,...). From this...

How to create a object of java class in excel vba

Hi i have a java class..i have registered in my system(it has shown the message as registed successfully)..but when i try to create an object(the code is as below) It is throwing error as module not found..do i have set the path.if yes how.. Dim conn set conn = createObject("Main") Main is the java class which is in C:\windows\java\t...

VBA Collections driving me nuts!

Hi guys, I'm still learning VBA and I can't figure out wth I'm having so many problems with a Collections object. I have a function that adds custom objects (I created a very simple class to store some data) that does the typical "read data, create object representation, stick it into Collections" sort of stuff. If I try to add a "key...

VB open specific Excel Version when two are installed

I am looking at this piece of code that I got from here because I would like to use it. The issue is, I have used 2003 to create the "test.xls" file but when I run this code it opens in 2007. Is there any way to force this to open in a specific Excel version rather than the default? GoSub, GuiOpen pweb := COM_AtlAxCreateControl(WinExi...