vba

Downloading and Formatting Web Data with Excel VBA

Hi, I need help creating a VBA macro that downloads closing price data directly from Yahoo Finance's Historic Quotes website and imports the data into an Excel spreadsheet column. Background information: This is the link to Yahoo Finance's Historical Quote database - To download as a TXT file: http://ichart.finance.yahoo.com/table...

How do I programatically add a reference to a VBA project?

I'm deploying an early bound styled VBA module that needs Scripting.Dictionary and RegExp. The script, predictably, fails when it runs on another computer. The user has to go to Tools->Reference in the VBA IDE and add a reference to those two libraries manually to make it work. Hence lies the problem. Asking the non-technical end user...

How to copy cell range as table from excel to powerpoint - VBA

I cant find any way to do this. What I have now is that it copy the range as an image: Dim XLApp As Excel.Application Dim PPSlide As Slide Set XLApp = GetObject(, "Excel.Application") XLApp.Range("A1:B17").Select XLApp.Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture PPSlide.Shapes.Paste.Select this works like a charm, b...

How to copy cell range as table from excel to powerpoint - VBA

I cant find any way to do this. What I have now is that it copy the range as an image: Dim XLApp As Excel.Application Dim PPSlide As Slide Set XLApp = GetObject(, "Excel.Application") XLApp.Range("A1:B17").Select XLApp.Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture PPSlide.Shapes.Paste.Select this works like a char...

Creating and Naming Worksheet in Excel VBA

I have some very simple code that adds a new Worksheet, after the current worksheets, to an Excel document, and then changes its name to one entered in a text box on a userform. Works fine on a new workbook, however in a workbook that has a number of existing worksheets it creates the new worksheet, but does not rename it. This only hap...

Using InStr instead of And in If statement?

Instead of using AND in a long If statement, I'm using InStr to match a dynamic value to a known list. Like this: If InStr("John, George, Harry", personName) Then... Is this okay? Should I be using AND instead? Is there a better way? Thanks. ...

Access 2003/2007 : Query to find average of one text field grouped by another in table

So lets say I have a table that looks something like this: ItemName ProductType ---------------------------------------------------------- Name1 Type1 Name2 Type1 Name3 Type1 Name4 Type2 Name5 Type3 and so on for thousands of recor...

Enabling field visibility from combo box selection in Access 2007

I have a form in Microsoft Access 2007 called System, and a combo box called Utility within this form. Below this is yet another combo box called Utility_FOO, and I have disabled its visibility by default. One of the options in Utilities is a checkbox labeled 'FOO.' I want Utility_FOO to become visible whenever FOO is selected. I hav...

VBA language reference for Office 2004

Office 2003 has such things as the Office 2003 Editions: Word VBA Language Reference. Is there such documentation for Office 2004 or is it assumed that the Office 2003 documentation covers Office 2004 adequately? ...

Excel/VBA: How to paste SQL query with proper string formatting

Hi folks, I've been writing some pretty long SQL queries in notepad and then pasting them into my VBA code as-is and then formatting the multi-line string correctly each line at a time. For example... In my text editor, the query looks like this. SELECT a, b, c, ..., n FROM table1, table2, ...

VBA: How to change the value of another cell via a function?

I'm an Excel VBA newbie. How to change the value of the specified cell via a user-defined function? What's wrong with this code: Function Test(ByVal ACell As Range) As String ACell.Value = "This text is set by a function" Test := "Result" End Function My wish is ... when I type =Test(E6) in cell E1, Excel will display the specifi...

Text Format in Excel using VBA

Hi, When I use WinSQL to run a SQL statement, the result is 20100803000001812. However, when I incorporate the SQL as a macro, the result is 2.01008E+16. What should I do in the macro in order to maintain the result as 20100803000001812 ? Thanks, Bob ...

Excel VBA Maniplating a CSV with SQL

This line of VBA code downloads a CSV file from the web and dumps the data into a spreadsheet. Can someone please help me figure out how to tweak the SQL in this code in order to select the "Close" column in the CSV table and insert that column into the spreadsheet? Thank you! Sub test() Dim sqldata As QueryTable Set sqldata = Active...

Outlook 2007 - How do I deploy custom toolbar and macro code?

Just wondering, do I really have to use Visual Studio to create a simple add-in/toolbar in Outlook 2007? I created a simple toolbar with a button that opens a form. Then I created some macro code in there and run it clicking the button. But now I want to save this thing and deploy it on other computers. How do I do such a thing? ...

Excel 2007 shadow copy ?!

Hello, my question is about Excel addins and vba code. This is the situation: There are 2 Excel files. One is just a normal Excel sheet, one is a .xla addin which is stored on a network drive. In the .xla file I have the Vba code. In the normal Excel sheet is a reference to the .xla file so that the sheet can use the macros from the...

How to replace every existing values of a column with formula?

My sheet currently has already data. Unfortunately, later I realize that all values in column E should be validated and changed as necessary by calling my own user-defined function and passing the values as the function parameter. For example, just says I have the following data in column E: E1: "This is a text in (E1)" E2: "This is a t...

Set Excel Range Formatting With Array

I have, in the past, used a variant array to populate a range of multiple Excel cells. I'm wondering, is there a way to do the same thing with cell formatting? I'd rather not go cell by cell, and it'd be nice to minimize the number of calls to get an Excel range... ...

Transposing tables in place in Word using VBA

I'm trying to write a method to transpose tables in Word using Visual Basic and the Excel object model. However, I'm having trouble using paste special with the copied Word object, since its not just plain text. Is it possible to force a plain text paste with transpose? Is there a better way to do this? My current code is as follows: ...

vba button - find which was clicked

Hi, I have assigned macro to few buttons. How can I find out inside macro which button was clicked? I am doing as user form, where he can input peoples from family: name1: surname1: name2: surname2: |add next member| I wish button to appear always in last row of the last added person. For simpli...

Is there a way to autofill Excel cells with data from an Access Database?

Basically I have a lot of historical data, consisting of IPs, Contacts, and various other fields. Originally we kept all this data in an Excel spreadsheet. I recently created an Access Database with this historical data. Now I am wondering if there is any way to use VBA or something else to autofill fields in the Excel spreadsheet using ...