Top "Vba" questions

Visual Basic for Applications (VBA) is an event-driven, object-oriented programming language for writing macros, used for the entire Office suite as well as other applications.

Refreshing all the pivot tables in my excel workbook with a macro

I have a workbook with 20 different pivot tables. Is there any easy way to find all the pivot tables and …

excel vba refresh
Removing the password from a VBA project

How can I programmatically remove a (known) password from an Excel VBA project? To be clear: I want to remove …

vba security excel password-protection
How to create and write to a txt file using VBA

I have a file which is manually added or modified based on the inputs. Since most of the contents are …

vba text-files
Test or check if sheet exists

Dim wkbkdestination As Workbook Dim destsheet As Worksheet For Each ThisWorkSheet In wkbkorigin.Worksheets 'this throws subscript out of range …

excel vba scripting
automatically execute an Excel macro on a cell change

How can I automatically execute an Excel macro each time a value in a particular cell changes? Right now, my …

excel vba automation
Deleting a file in VBA

Using VBA, how can I: test whether a file exists, and if so, delete it?

vba file-io delete-file file-exists
How do I put double quotes in a string in vba?

I want to insert an if statement in a cell through vba which includes double quotes. Here is my code: …

excel vba double-quotes
Check if the file exists using VBA

Sub test() thesentence = InputBox("Type the filename with full extension", "Raw Data File") Range("A1").Value = thesentence If Dir("thesentence") &…

excel vba
Get values from other sheet using VBA

I want to get values from other sheets. I have some values in Excel (sheet2) for example: A B C …

excel vba worksheet-function
How can I use a for each loop on an array?

I have an array of Strings: Dim sArray(4) as String I am going through each String in the array: for …

excel vba