excel-vba

How do I use an ADO.NET managed provider in Excel?

I have an ADO.NET Managed Data Provider that is registered in machine.config in DbProviderFactory - It is available for use from, say, Analysis Services, so I know it is correctly registered. However, I need to be able to query the managed provider from Excel, but the managed provider doesn't appear as a choice from Data Link Properties...

Trying to get pop up pictures for phone list in Excel

I have a simple phone list with columns in the form of Name, Address, Phone#, etc. On the last column I'd like to have the equivalent of a comment rollover which would automatically pop up the persons photo (there are many who only come to this group occasionally, and this would be a help in recognizing them and remembering their names) ...

Excel export chart to wmf or emf?

I am trying to export a chart from Excel to either the wmf or emf format. The code works if you export to GIF but not with WMF as the filtername. This works: Chart.Export FileName:="current_sales.gif", FilterName:="GIF" But Chart.Export FileName:="current_sales.wmf", FilterName:="WMF" fails giving the error: Run-time error '1...

How to setup a unit test in VBA Excel Macro?

Hello, I am working on an Excel VBA macro that will take some excel file, scrub / clean it, and produce a workbook with 2 sheets - sheet 1 being the original 'dirty' file, sheet 2 being the cleanly scrubbed file. Since we have 10 different formats right now, and down the road 40+.. I would like to save this output for a given set of f...

Excel VBA INSERT INTO statement using variables

I am using an SQL query to insert data from an excel worksheet into an Access database. I put all the data that I want from the worksheet into variables: rwyNumber = Range("b13").Value & Range("c13").Value testDate = Range("b5").Value testTime = Range("b6").Value rwySide1 = Range("b14").Value firstThird1 = Range("b28").Value secondThir...

Add Chart Data from other Workbooks into one series with VBA - Excel 2007

Hi All, I need to create a Chart which will grab data from external sources when a macro is run. Setting up the UserForm and all that is fine, all done, however I cant find out how to add another piece of the series. Is it even possible to have a series that sources data from several different locations? Basically I need it to go in ch...

How do I determine if a variant is a whole number in VBA?

Hellow I am looking for an elegant solution to determine if a variant is a whole number in VBA. Unfortunately, if the variant was created from a string, I am stuck. Here's a little test script: dim v as variant v = "42" if v <> round(v) then msgBox("<>") end if Here, the msgBox pops up, probably because the variant was created fro...

Excel VBA - Stop running program that was started by Shell?

Excel 2002 VBA. I have a macro that launches an external script whenever a certain condition is met: Shell("c:\program\script.exe") How do I stop that running program when the condition is not met? ...

How do I reference to another (open or closed) workbook, and pull values back, in VBA? - Excel 2007

Hi all, Basically I need to gather a fair few figures from another workbook (Which is found and can be opened by a UserForm, therefore the location and names are variable). I need to use VBA for this as I also need to populate a chart with this data. I would prefer to not have to open the other workbook in order to do it, but if it is f...

Moving values from one sheet to another

I'm looking for an Excel 2003 macro to solve this problem. I have a sheet that holds financial information: A1 holds client names and AI1,AK1,AM1 etc, hold months April, May, June (all string values) etc; with the rows below that holding the amount due for the corresponding month. The last row is the total. What I need is to cre...

Excel VBA function returning an array

Can you create an Excel VBA function that returns an array in the same manner as LINEST does, for example? I would to create one that, given a supplier code, returns a list of products for that supplier from a product-supplier table. TIA Bob Irving ...

Problems with Mail Merge macro run from Excel

I have created a macro to automate a Word mail merge from excel. Below is my code. The macro is stopping at the highlighted section Sub RunMerge() Dim wd As Object Dim wdocSource As Object Dim strWorkbookName As String On Error Resume Next Set wd = GetObject(, "Word.Application") If wd Is Nothing Then Set wd = CreateObject("Word....

Macro too big to run, keeps 'not responding'.

Hi I have now managed to write my macro but the whole thing stops responding, just a guess but i presume it is because it is asking to check too much data? I have about 3000 rows (but have even tried it on 10). Does anyone know how I can cut this down or mend it to work? Another query on it I have gone to the heading 'sample187' but idea...

Perform HTTP Post from within Excel and Parse Results

I have access to an API. The API takes an XML post as input and then returns an XML response with the relevant data. I want to Send the HTTP Post to the Server (Authentication and Request will be sent together) Receive the response (One of the options to be returned is CSV or XML) Insert the data into the appropriate rows and column...

How do I create an excel macro that changes the rows spanned by a cell

I am pasting a table into Excel from SAS where the number of rows spanned by the cell in the first column is variable. That is to say sometimes the first column is 3 merged cells, sometimes it is 6, etc. I would like to run a macro that changes the height of the first cell to be 10 merged cells, and to insert rows at the bottom to make...

Looping through cells in Excel in two dimensions VBA

I'm trying to loop through a set of cells using VBA in a worksheet and check if they contain any data. My spreadsheet is like: __A_____B_____C_____D____E_____F____G 1| 3122 -1 -1 3243 2| -1 -1 -1 3243 1 1 1 3| -1 -1 -1 3255 1 5| 4232 2132 -1 3259 6| 7544 1333 324 3259 7| -1 -1...

Handling numbers larger than Long in VBA

I am Currently trying to write some code in VBA to solve a problem from Project Euler. I have been trying to answer a question that requires you to find primes that can be divided into a number that will not fit in a long. Any suggestions as how to handle this problem? I know I can split the number between two variables and I have ...

How can I copy only text of a specific colour in Excel?

I have a worksheet with a large number of cells containing large amounts of text. Within any particular cell there may be some text that is coloured red. I want to remove that text and copy it to a different column. I have a VBA function that does this by checking the cell contents character by character but the spreadsheet is quite lar...

Vba Summary Page

hello,I am new to vba and I would like to know if can search thru the worksheets, copy and then paste in a new worksheet on a column thank you Public Sub CopyandPaste() Dim ws As Worksheet ' Delete all data from Summary Page Worksheets("1a").UsedRange.Delete ' Copy each worksheet in file and paste to Summary Page For Each ws In Works...

[Excel] Populate list via a bi-Condition

Hello excel-world, im interested to implement something but im not sure if it would be possible and would like your intake on it. here is my scenario: i will have two validation cells which will be shown as List that I will pick from. those are my condition that i would like to meet and ommit my list from a database. I have a list of...