Visual Basic for Applications; a subset of Visual Basic used in all Microsoft Office applications. Consider using this tag together with the tag for the specific application in question.

learn more… | top users | synonyms

3
votes
3answers
23k views

How to execute a stored SQL procedure in Microsoft Excel?

How can I execute a stored procedure in Microsoft Excel and get all the data it returns?
3
votes
3answers
1k views

Is there a way to set the name box of a cell programmatically in Excel

I would like to programmatically set the name box of a cell in a worksheet I'm working on, either through a formula or through a macro. The end point is that I don't want to set it by hand. In my ...
2
votes
2answers
5k views

VBA code to insert custom signature in Outlook 2007 email

I need to insert a specific signature into an email message. Our support team uses a variety of different signatures to respond to different types of support needs. Currently, I access them via the ...
2
votes
4answers
15k views

How can I create proportionally-sized pie charts side-by-side in Excel 2007?

I have a pivot table with two sets of data as follows: 2011 2012 Slice A 45 20 Slice B 33 28 Slice C 22 2 I am trying to present two pie charts ...
2
votes
4answers
5k views

How do increase row height in excel by X. ie. Add verticle cell padding

I have this report and I want to increase the vertical cell padding to make it easier to read. Now, typically you could just select multiple rows and change the row height until you're satisfied. ...
0
votes
1answer
279 views

How to run macro with parameter from windows command line?

I have a need for running a Macro from the Windows command line with parameter. For example, a macro should save, in A1 cell, the value of the parameter specified. Is it possible to accomplish this?
18
votes
5answers
8k views

How can I use custom colours in the Microsoft VBA editor?

I'm working on a few projects for work using Excel and VBA, so I have no choice but to use the Microsoft Visual Basic editor. I normally wouldn't mind, but I can't figure out how to set a custom ...
2
votes
1answer
196 views

Macro Help: Finding a replacement for Cut and Delete for Speed

I’m looking for a way around using the commands .delete .cut In my excel macros. I’m finding that these processes greatly slow down the procedure (by up to 20 min) for the more data it has to cut ...
0
votes
2answers
4k views

Insert rows into worksheet from another workbook?

I have two workbooks, say: workbook_a.xlsx and workbook_b.xlsx and both contain different worksheets. Two of those worksheets are already linked by a couple of VLOOKUP formulas using a unique key ...
8
votes
2answers
36k views

How do I use a Private Sub in Excel?

I'm want to use the Private Sub functions provided here. Usually a put VBA code in the Visual Basic Editor, I then close the editor and I run the code using "Run this Macro" on the Developer tab. But ...
2
votes
3answers
137 views

Finding the number of specific characters inside a formula

I'm trying to find the number of of +'s in a formula inside a single cell in excel. If it were a normal cell with text inside, this would be quite easy. But due to the restrictions of the file I'm ...
0
votes
1answer
1k views

Open an Access database with scripting disabled (macros and VBA)

Suppose you want to examine the contents of an untrusted Access database. It seems there should be a way to open it in Access with macros and VBA disabled. Searching around the web, I've found ...
3
votes
1answer
451 views

Macro Find: Is there a macro to Format a Word Document as if it were beign created in VBA?

I have a lots of code(for Excel) in Vba and would like to transfer a copy of it into a word document. Does anyone know of a macro that will format the word document to treat the code as if it were in ...
6
votes
5answers
10k views

How to return everything between two characters in Excel?

I'm a programmer with lots of languages, but somehow I've never learned Excel macro or formula language. I'm sure there must be a simple way to do this, but I'm stumped. I have a column of file names ...
0
votes
3answers
2k views

Selecting all data in Excel column regardless of size

I have a repetitive process that I must do in Excel for test data collected. I have to do this process for every data point I collect. I collect over 200 data points each test. My data is auto ...
1
vote
1answer
252 views

Excel userforms

I have developed a macro that does a whole bunch of things for me based on a few things. (Importing files). The file names are dated dd_mm_yyyy and right now I enter them into a sheet where the macro ...
1
vote
0answers
738 views

Excel 2010 AddPicture functionality changed?

Me again. In Excel 2003, we're using some VBA to automate adding a picture to a worksheet. The call, in a nutshell, is: Dim Pic as Object Dim filePath as String . . . Set Pic = ...
2
votes
1answer
2k views

In Excel, I pasted in a bunch of URLs, but they aren't live links — how do I bulk convert them to live links?

In Excel, I pasted in a bunch of URL's into a column. However, they aren't live links after pasting. How do I bulk convert them all to live links swiftly?
5
votes
4answers
14k views

Excel VBA Function runtime error 1004: Application-defined or object-defined error

I'm trying to learn functions for the purpose of simplifying and reusing code whenever necessary. I began by turning something I use pretty often into a function: Returning the integer value of the ...
2
votes
1answer
807 views

Macro for helping superscript last character of many rows in a single column

I'm adding footnotes (always adding footnotes) to a table and I would really like to be able to automate the repetitive nature of making my symbols superscript. Currently it’s: >enter cell>highlight ...
4
votes
3answers
2k views

Calculating the average of variably sized blocks of numbers within a column?

In column A I have a set of numbers (over 1,000), and I want to get an average of a block of them at a time, (e.g., 10, so A1:A10 then A11:A20 and so on) and write these averages into column B, such ...
2
votes
1answer
664 views

How do I create a macro that copies one row down based on the # of records in another sheet?

Using Access I export/create a daily Excel spreadsheet which has an increasing number of records/rows. I'd like to then open a master Excel sheet, which: Opens the exported sheet. Counts the number ...
2
votes
2answers
10k views

Pass a cell contents as a parameter to an excel query in Excel 2007

I have tried really hard to solve this issue but I think I am going to need a little help. I can program in different languages but I don't have any experience with Excel, VBA or the queries you can ...
1
vote
3answers
971 views

Java is not recognized as an internal or external command in vba inside shell in a batch

Every time I try to call the java function from the shell function in vba or from the batch file from the shell function in vba it says that Java is not a recognized command. Though I can do this ...
2
votes
1answer
314 views

Play DVD video from within PowerPoint 2003 (no ripping)

So I have to create a PowerPoint presentation for my company, which will be used at multiple locations. We want to use some video on a DVD. Problem: the license terms for the DVD specifically forbid ...
1
vote
3answers
6k views

mdb files opened in 2010 lose VBA code references

Disclaimer: I just got back from some sick time, haven't seen the error myself or investigated the full range of possible causes, just looking for hints on what may be a systemic issue or something ...
3
votes
2answers
1k views

Subscripts and superscripts in Excel

I have an XL sheet with chemical formulae - which is basically just letters with numeric subscripts and superscripts. I can save as an html page and get the <sub> and <sup> html elements, ...
7
votes
2answers
4k views

VBA Runtime error 1004: Method 'OpenText' of object 'Workbooks' failed

After an upgrade to Excel 2010 (from 2003), a script used for standardizing data from Access import has stopped working. It returns an error: "Run-time error '1004': Method 'OpenText' of object ...
1
vote
1answer
947 views

How to to fill a single column of cells with a number that increments when it finds a cell that spans multiple columns? (Screenshot)

I'm trying to organize some data that was dumped out of a proprietary system into something I can use. In column A, I want to put a 'group by' number. It dumps this long, spanning row out that ...
0
votes
1answer
4k views

macro to download selected messages attachments - Problem about downloaded files count

I changed some codes for getting selected messages attachments to my hard drive like below : Public Sub SaveAttachments() Dim objOL As Outlook.Application Dim objMsg As Outlook.MailItem 'Object Dim ...
0
votes
0answers
297 views

Automate Conditional Template used in Word MailMerge

I have four different Word 2003 documents set up, all using the same Excel data source, but the documents have different logos, text, terms and columnar content layouts. Currently remLetter1.doc ...
4
votes
1answer
2k views

Excel 2010 Macro “Command could not be completed by using the range specified”

Running a macro on an Excel spreadsheet, I get the Run-time error: 1004 Command could not be completed by using the range specified. Selected Debug and the highlighted code is: ...
4
votes
2answers
5k views

A thousand JPEG images in a Word document: how can I format them in the same way?

Please suppose you have a Microsoft Word 2007 document: you have just inserted in it about a thousand of JPEG images. With the first image, you do right-click, then FORMAT PICTURE, then option ...
1
vote
1answer
5k views

Run macro upon opening Excel 2007

I need help setting up macro that runs each time I load Excel 2007. I have tried following a few walkthroughs on the web but they end up not autolaunching the macro.
0
votes
1answer
733 views

VBA xlColumnDataType in Excel 2003

When importing a txt file into excel, I need to specify data types for the columns. I'm currently using Excel 2003 (upgrade to 2010 is for later in the summer). I have been able to find enumerations ...
1
vote
1answer
786 views

Check for trailing \ in string returned from msoFileDialogFolderPicker, Excel VBA

I am using the msoFileDialogFolderPicker to return a path when a user wants to deposit a report in a specific folder. A custom form (ufSelRepType) shows up in the macro in cases where the default ...
0
votes
1answer
2k views

Excel VBA MsgBox handling checking for existing file

I'm not sure how to handle the output from a MsgBox in order to allow my macro to continue processing given differing situations. This macro creates a daily report file with an output name of ...
0
votes
1answer
2k views

In Excel VBA Macro does ActiveWindow.Scroll change ActiveCell at all

I'm cleaning up and extending some excel VBA macros (written and currently running in Excel 2003), and I have a question about how far I can go in cleaning up without modifying the output. There are ...
2
votes
5answers
13k views

Subscript/Superscript Hotkey for Excel 2010 Macro?

Background In Excel 2010, for some ridiculous reason, there is no built-in hotkey (or even a button on the toolbar) for subscripting/superscripting text within a text cell. You can, however, ...
1
vote
3answers
15k views

Excel VBA Macro Sub or Function not defined

I used the macro recorder to generate a macro in Excel 2007. When I try to the run the macro, it tells me: When I click Ok the definition of the macro gets highlighted. I'm really confused ...
2
votes
1answer
4k views

Auto Forward Emails from Client in outlook to external email

HI all, autoforwarding at exchange level is disabled by the server admin, so i have got some VBA code that forwards emails to an external email(my blackberry email). I have it working fine, but was ...
0
votes
3answers
2k views

How to stop VBA code from within excel converting Text to Time?

I have tried formatting the input fields as text but to no avail. When I step through it in the debugger it shows a double number which I presume is date conversion. I just want it to treat it as text ...
1
vote
1answer
807 views

VBA Create Matrix from Multiple ListBox containing headers

I have a ListBox where are some columns names, and I'd like to build a matrix with only the selected columns in it. Is there a simple way to do that? I'm actually trying with : Dim Matrix_a() As ...
1
vote
1answer
1k views

Can Excel filter cells based on formula text rather than formula results?

I had a colleague ask me yesterday if it was possible to set an auto-filter to display columns based on the text of formulas in the cells instead of their calculated results. For example: if I had ...
3
votes
1answer
3k views

Macros in Excel 2010 hangs

I have a spreadsheet with several macros. Generally, when previously using Excel 2007, a user clicks a button and everything works as expected (calculations, some email sending & file I/O). ...
4
votes
5answers
13k views

Inserting a signature automatically into an Outlook Calendar meeting request

Is there a way to automatically have a signature inserted into a Microsoft Outlook Calendar request, as one can do with emails?
5
votes
3answers
9k views

Use a Trendline Formula to Get Values for Any Given X with Excel

Is there an easy way to apply the trend line formula from a chart to any given X value in Excel? For example, I want to get the Y value for a given X = $2,006.00. I've already taken the formula and ...
0
votes
1answer
137 views

How to copy a file to network folder under OS X and Word 2004/2011

I am using Mac OS X. I have Word 2004 / Word 2011 on my Macs. I need to know how to create a text file under Word 2004/2011 and copy that file to my network share folder. I have to write a macro ...
0
votes
1answer
4k views

Word Macro: Move Cursor Down a Row

I have a macro which I've been using to merge two cells together in a word table, but what I want to do is to get the cursor to move down by one cell, so that I can repeatedly press the shortcut key ...
0
votes
3answers
646 views

Macro is not Cooperating with Quotations in Excel VBA

I Have a macro containing a line that will change the formula of a cell using R1C1 formula type. The formula is: ActiveCell.FormulaR1C1 = _ "=IF(R[0]C[-2]=0,"",(R[0]C[-20]-R[0]C[-16]))" ...