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.

3741 questions
13
votes
2 answers

Change VBA Editor Color Scheme to something darker

Is there a way to change the color scheme in the VBA editor that comes with Microsoft Office? I have been spending several hours lately working with VBA in Excel, and the bright white background is making my eyes sad. I know I can change the…
3
votes
1 answer

How do I check if cmd.exe is disabled by administrator?

I am writing a VB script that checks if applications are available and accessible e.g. cmd.exe, powershell.exe and so forth. My script allows me to see if an application exists (it either works or does not and returns a Boolean) If cmd is disabled…
TheHidden
  • 131
  • 5
2
votes
2 answers

Not Inserting new records instead it updates the last record in Ms access vba

I have a form made in ms access and vba. I have this code in an insert with the default given upon creating the button DoCmd.GoToRecord , , acNewRec My form is bound to a table and linked tables to a SQL database. It successfully added if the table…
Androidz
  • 121
2
votes
1 answer

VBA - Dynamic range skipping rows

For X = 9 To 36 For Y = 8 To 22 Step 14 If WS1.Cells(X, 1) = "TOT" Then X = X + 2 Buy= WorksheetFunction.SumIfs(Calls, Hour, WS1.Cells(X, 1), Data, WS1.Cells(Y, 2), Service, Number) + WorksheetFunction.SumIfs(Calls, Hour, WS1.Cells(X, 1),…
Simone
  • 21
  • 2
2
votes
0 answers

Comparing one street address with a column of street addresses to find a match

I have two data sources with street address names, cities, and zips that I'm trying to find which addresses have the highest match percentages and return the maximum value. I have a VBA code that matches two cells strings "Address Compare" but need…
Iyin
  • 21
  • 2
2
votes
4 answers

Get file tags in VBA using variable file name

I'm using VBA in Excel to loop through a series of files and decide which ones to import. I'd like to decide which files to import using something like the file's tags, so that I don't need to open every single file. I'm trying to use the…
Werrf
  • 992
2
votes
2 answers

Extracting numbers with spaces from excel using VBA

Need to extract numbers from the following text with spaces between numbers using VBA, possibly. Units : 1.00, Code: '99213', M1: '25',Comments: 'Records do not include documentation of an evaluation and management service that is separately…
2
votes
1 answer

Limit vba to specified sheet

I have a bit of code that auto fills formulas down to the last row. I want this code to work on two sheets (with different ranges) and to have a button on a separate control sheet. The problem is, when i run the macro from the control sheet, it…
2
votes
1 answer

Loop through cells and concatenate when blank cells are present

I would like to loop through cells in column A and if a cell is blank perform the CONCATENATE function in column C from column B. I have this code but it is not working. Any help would be greatly appreciated. Sub ConcateBlank() For i = 3 To 400 …
1
vote
1 answer

Transpose data in columns to rows downwards

I am working on a Excel VBA Project. I have data in an excel file as such (each alphabet in each cell). I have many lines as such and each line will definitely have data in the first 6 cells, with variable number of 2 cells each thereafter. a b c d…
1
vote
2 answers

Registering OCX on 64-bit Windows 7

I want to use MSCOMM control in my MS Excel 2010 VBA. The control shall appear in Tools-> Additional Controls dialog box in VBE of MS Excel 2010. I am trying to register MSCOMM32.OCX on my 64-bit Windows 7 machine. However, as I try to register it…
Jay
1
vote
1 answer

How to fix vba type mismatch?

I have a compile error message byref argument type mismatch pointing to rg1 where the HTML is. Could you please help? Sub email_multi_ranges() Dim OutApp As Object Dim OutMail As Object Dim rgl As Range, rg2 As Range, rg3 As Range, rg4 As Range Dim…
tammy
  • 13
1
vote
2 answers

How to remove vbVerticalTab from Word Document

While we type in word a new line can be created by Shift + Enter which is called a line break. Recently, I copied some text from a web site into a word and found that there is large number of unwanted line breaks in the document. Removing each of…
1
vote
3 answers

Getting error "Block If without End If" despite having used End If statement

I have a combobox in Word that is supposed to populate the termShorthand text field based on the selection from the termWritten array. I am receiving the Block If without End If compile error even though I have it after my If statements. Private…
1
vote
0 answers

Want rows to hide/unhide automatically as cell changes without having to run the vba everytime

I don't want to have to press "Alt F8" to hide 0 value rows and unhind rows >0 I want it to Do it Automatically as the data changes. This is the VBA code that works to hide/unhide rows with a value of 0, but again, it does not work automatically…
1
2 3 4 5