Questions tagged [vba]

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.

Good questions on VBA generally contain some code and asks for solution of specific issues. Questions asking for entire solutions (please give me the code / how to do this and this with VBA) are off topic and will be closed as too broad.

Visual Basic for Applications (VBA) is the programming language for Microsoft Office and its associated applications, including Word, Excel, PowerPoint, Outlook, and Access. Users can write sub-routines that execute these actions and methods and interact with the application. Typically this is started by enabling developer tools in a Microsoft Office application. If you're a Pascal or C programmer, you'll find all the program structures you're used to.

Getting started with VBA

List of actions & methods

Note that you always can press F1 within any VBA editor to get a similar list.

3822 questions
58
votes
17 answers

Copy Excel worksheet and maintain relative cell reference in formulas

Another copy problem in Excel: How can I copy a Worksheet from WorkbookA.xlsx into WorkbookB.xlsx without the copied Worksheet still referencing WorkbookA.xlsx e.g. the formula =B!23 becomes =[WorkbookA.xlsx]!B!23 when copied over. I want to…
44
votes
1 answer

How to bypass the VBA project password from Excel

I need help with password retrieval or bypassing the password on a project that was done at work. The author has used MS Excel to do the project, and it's in the client's server. The server that we use has no access to Notepad++.
40
votes
9 answers

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 colour for the editor (I can only choose from the…
36
votes
5 answers

Can I make an Excel VBA macro available to all workbooks?

Is it possible to write a VBA script in one workbook, and use it in other workbooks in the machine? I guess I'm looking for a way to write a macro package. EDIT Following the instruction in the link given by Lance, I managed to create the addin, but…
bavaza
  • 623
34
votes
9 answers

Limit Excel CPU Usage

Is there a way to limit how much CPU usage excel has access to when running? I have a VBA script that calculates a bunch of giant array formulas. The entire calculation takes maybe 20 minutes using 100% of my CPU but I can't use my machine during…
31
votes
1 answer

Which Excel objects are zero-based and which are one-based?

Using VBA to access the first sheet in a worksheet is Worksheets(1). The first item in a ListBox is myListBox.List(0). I heard that Collections are 1-based but I don't know what they are. VBA arrays are 0-based. Excel string functions like MID are…
Noumenon
  • 813
30
votes
4 answers

Open Multiple Instances of Excel without PERSONAL.xlsb Lock Message

Whenever I open more than I instance of Excel, I get the following message: PERSONAL.xlsb is locked for editing Q: How can I disable or hide this message? Alternatively, if someone could suggest a way to improve Excel 2007's support for multiple…
26
votes
2 answers

How do I add VBA in MS Office?

I've seen posts showing answers which use VBA (Visual Basic for Applications) code/macros, however, I've also noted additional comments afterwards about how to use the VBA (how to implement and execute it). I'm hoping this will help just to get the…
Dave
  • 25,513
23
votes
3 answers

How to remove Document Inspector warning in Excel

I'm running VBA scripts on a series of files that are XLSM type. While I'm trying to automate my processes, I'm getting stopped by this warning about the Document Inspector, meaning I have to click OK for every file. Is there a script I can run on…
22
votes
4 answers

Any Excel function that will reverse a string?

Are there any built-in Excel functions that will reverse a string?
21
votes
1 answer

In Excel 2013, where are Visual Basic (VBA), Macros and AddIn tools?

In Excel 2013, where are options and tools such as Visual Basic (VBA), Macros and AddIn tools? Are they supported?
BSalita
  • 915
20
votes
3 answers

How to inspect / view an Excel macro before "enabling macros" for a sheet?

I'm receiving occasionally an xls file that contains a macro which I should use. If I don't have complete trust in the sender, I wish to look at the macro's source in order to verify that it indeed does only what it is supposed to. However, in Excel…
GJ.
  • 10,151
20
votes
6 answers

Delete ALL custom cell styles EXCEL

Is it possible to delete ALL the custom/created cell styles in a workbook ? Just leaving the default styles. Without having to delete them all one by one
PeterH
  • 7,595
19
votes
3 answers

How can I find out which parts of an Excel workbook are the biggest in size?

I have an Excel .xlsx that weights 47MB. I'd like to know which parts of the workbook are the heaviest and work them, since I haven't made much progress manually trying to identify and reduce the filesize. Is there any way of knowing findout out how…
s_a
  • 2,159
19
votes
8 answers

Why is my custom formula not updating?

I'm using Excel on the Mac and I've checked in settings and automatically calculate is turned on. I followed this guide to create the following custom function which counts the number of cells of a certain colour in my spreadsheet: Function…
1
2 3
99 100