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.

3678 questions
56
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…
Jake
  • 2,029
  • 10
  • 32
  • 46
43
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++.
user365483
  • 431
  • 1
  • 5
  • 3
39
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…
Breakthrough
  • 34,227
  • 10
  • 105
  • 149
33
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…
32
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
  • 573
  • 2
  • 6
  • 11
28
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
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
  • 721
  • 2
  • 11
  • 22
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,297
  • 10
  • 57
  • 69
22
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…
Tess in Oz
  • 251
  • 1
  • 2
  • 7
22
votes
4 answers

Any Excel function that will reverse a string?

Are there any built-in Excel functions that will reverse a string?
mindless.panda
  • 7,262
  • 13
  • 47
  • 66
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
  • 875
  • 4
  • 13
  • 20
19
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.
  • 9,673
  • 26
  • 74
  • 115
18
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,377
  • 20
  • 54
  • 82
17
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,059
  • 2
  • 22
  • 34
16
votes
7 answers

Adding an element to the end of an array

I would like to add a value to the end of a VBA array. How can I do this? I was not able to find a simple example online. Here's some pseudocode showing what I would like to be able to do. Public Function toArray(range As range) Dim arr() As…
megloff
  • 409
  • 2
  • 5
  • 11
1
2 3
99 100