Skip to main content

Questions tagged [vba]

Visual Basic for Applications (VBA) is an event-driven programming language first introduced by Microsoft in 1993 to give Excel 5.0 a more robust object-oriented language for writing macros and automating the use of Excel. It is now used for the entire Office suite and over 200 non-Office hosts.

129 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
29 votes
0 answers
1k views

Pacman implemented in OOP VBA

What?, Why? I have been inspired by several other posts on the topic of OOP implementations in VBA to try and create a Pacman clone. I think this task is not all that hard in most languages; but, I ...
ArcherBird's user avatar
19 votes
0 answers
1k views

Progress Bar for Excel

Any future updates can be found at Excel-VBA-ProgressBar What I've been using so far For the last 6 years I've been using a progress form which I wrote in VBA using just Windows API calls. The code (...
Cristian Buse's user avatar
14 votes
0 answers
574 views

BattleShip - Ships & Players

I'm making a full-blown OOP Battleship game in VBA (previous post: Battleship Grid), and I want this code to be as good as it gets - and better, if I can. I've refactored a few things, introduced a <...
Mathieu Guindon's user avatar
11 votes
0 answers
354 views

Host-Agnostic Model-View-ViewModel Infrastructure

I've written an API that unlocks some serious MVVM capabilities with VBA's MSForms UI framework. This is the complete code-behind for an example ...
Mathieu Guindon's user avatar
11 votes
0 answers
2k views

Function to conect to Firebase Rest API via Access VBA

This is the application for small school, which will store students' info in Firebase and also retrieve data from Firebase. I am using JSON Parser to parse the data and save the same in Access tables. ...
Adarsh's user avatar
  • 259
10 votes
0 answers
1k views

Private VBA Class Initializer called from Factory #2

About This is a follow-up of a previous question Private VBA Class Initializer called from Factory. I've decided to create a new question instead of answering my old question because I would like the ...
Cristian Buse's user avatar
8 votes
0 answers
747 views

A VBA program to quantify the performance of code execution timers

Motivation I am interested in optimising the execution time of code with short (fast) execution times on the order of microseconds (µs), but that will be used with high frequency (e.g. like ...
vbAdder's user avatar
  • 181
8 votes
0 answers
4k views

Responding to Events of Dynamically added Controls

I was asked for an example of a class to wrap dynamically added controls as I suggested in this Answer. Although it is out of the context of a Code Review, I thought that it would make an interesting ...
TinMan's user avatar
  • 4,143
8 votes
0 answers
793 views

Battleship MVC Architecture

The entry point is the Macros module, which - for now - includes only a single procedure, at a very high abstraction level - I'm quite happy with this: ...
Mathieu Guindon's user avatar
8 votes
0 answers
1k views

IndexedArray Class: Uses a Dictionary Keys to Index a 2 Dimensional Array of Values

This class encapsulates a 2D Array and a Scripting Dictionary. Values are add or returned from to the Array using a Key and a ColumnIndex, e.g. ...
TinMan's user avatar
  • 4,143
8 votes
0 answers
3k views

Bringing The System.Text.StringBuilder Up To Lightning Speed In The VBA

After having to swap the feature rich System.Text.StringBuilder for the very fast but very vanilla A lightning-fast StringBuilder, I decided it was time create a ...
TinMan's user avatar
  • 4,143
7 votes
0 answers
348 views

Web Battleship -The Unofficial Battleship UI

I've written my own UI for Mathieu Guindon's VBA Battleship (Battleship UI: GameSheet) which uses a webpage in a WebBrowser control for the View. Webform: Userform ...
TinMan's user avatar
  • 4,143
6 votes
0 answers
105 views

Shape Text Formatter Class a Builder Pattern

The preeminence is to have every method of the formatter return the formatter as a reference. This allows it to add and format text in chain. Such as: ...
TinMan's user avatar
  • 4,143
6 votes
0 answers
129 views

An over-the-top approach to data entry

My goal: to make the already easy task of filling out an excel sheet 1% easier by putting in hours and hours of effort. On a more serious note, I'm currently developing a system to manage inventory at ...
Hayden Moss's user avatar
6 votes
0 answers
295 views

Chart Based Animations In Excel VBA

I've been working on re-writing comfortablydrei's answer to this PPCG Question regarding creating a illusion animation in pure Excel VBA. So far, I've been able to rewrite the code to function in VBA, ...
Taylor Raine's user avatar
6 votes
0 answers
623 views

Office CommandBarButton Icon Browser in the VBEditor

Frustrated with the solutions that I found online I decided to write my of Icon Browser. From the onset I decided that my Icon Browser should work from the VBEditor and not show any of the thousands ...
user avatar
6 votes
0 answers
2k views

Decode HTML Entities in VBA using regex and dictionary

I receive HTML-encoded text that includes named and numbered entities, and I need the decoded HTML. There were just too many bad solutions for this online. I use regex pattern ...
ThunderFrame's user avatar
  • 1,959
5 votes
0 answers
2k views

Extract data from API using VBA & XML (Performance)

EDIT: Added a block with the raw code at the bottom (suggested by a friendly user) First post here. I sincerely hope that I am doing everything by the book. Also, I want to thank you in advance for ...
Peder C's user avatar
  • 59
5 votes
0 answers
311 views

Extending VBA classes with Behavioral Patterns

I want to learn about Design Patterns and be able to apply them in Excel VBA. So to learn about patterns I bought a book that seems promising: Head First Design Patterns; it presents the material ...
SmileyFtW's user avatar
  • 181
5 votes
0 answers
257 views

Factory class that uses reflection to instantiate objects by class name

In this SO post Dynamically choose class from string Alexander Platonov creates a Function on the fly and then uses Application.Run() to instantiate an Object by ...
TinMan's user avatar
  • 4,143
5 votes
0 answers
2k views

Object-relational mapper for VBA / MS-Access

This is my attempt to create simple object-relational mappers (ORM) in VBA for DAO and ADODB recordsets to reduce boilerplate code when converting data between recordsets and objects. As far as I've ...
FolkCoder's user avatar
5 votes
0 answers
1k views

Multithreaded Excel + VBScript Timer: Snake Game Demo

Multithreaded Excel + VBScript Timer After reviewing these post: Snake in Excel in… VBA? and Drawing a snake using arrow keys in Excel using VBA, I decided to work on creating a VBA Timer. The ...
user avatar
5 votes
0 answers
453 views

Scraper for parsing, downloading, and setting images beside each link in an Excel file

I've written a script in VBA which is able to parse image links from a website, download and store them in a local folder and finally set those images beside each link in an Excel file. As the script ...
SIM's user avatar
  • 2,501
4 votes
0 answers
83 views

A new Dictionary for VBA

The latest version of the Dictionary class presented in this question is available in the VBA-FastDictionary repository under the latest release. Motivation I ...
Cristian Buse's user avatar
4 votes
0 answers
207 views

UDF to Generate Hyperlinks in Excel

Background I am trying to recreate the functionality of HYPERLINK() on my own terms, as a custom UDF called Hyper_Link(). My ...
Greg's user avatar
  • 403
4 votes
0 answers
248 views

Building VBA and VBE Menus

This is a follow up to VBEMenuButton Class. After much trial and error I abandoned the previous approach. I decided that it would be better to create a class to instantiate the menus. When the class ...
TinMan's user avatar
  • 4,143
4 votes
0 answers
137 views

Print apartment mailbox lists from excel

Update Due to the fact that the client's version of excel does not support VBA, I have moved on to a C# excel interop solution which has been reviewed. The test data has been added at the bottom. The ...
pacmaninbw's user avatar
  • 23.9k
4 votes
0 answers
595 views

VBA class managing loading DLL libraries

I am playing with a custom-built SQLite library intending to access it from VBA via the C-language API. I keep the library within the project folder, so I load it via the LoadLibrary API. To make the ...
PChemGuy's user avatar
  • 425
4 votes
0 answers
269 views

Export/Import Rubberduck VBA Virtual Folder Structure with Library References to/from Project Folder on Hard Drive

Rubberduck VBA permits creation of virtual project hierarchy within the IDE, but the project is imported/exported as a single folder with all files. Sometimes, direct access to the project folder is ...
PChemGuy's user avatar
  • 425
4 votes
0 answers
83 views

Scraping and filling out a time-off request

In my ongoing quest to automate everything I have to do at my job, I've decided to learn how to do webscraping with VBA. I wanted to start with something easy, so the following simply fills out a ...
Hayden Moss's user avatar
4 votes
0 answers
47 views

Sheet display in function of date and time on open and save (2)

Since I had to almost start all of the code again with first refactor and an eye opening advice on a random Overflow question, here it is again: This is a code that selects the right sheet according ...
Patates Pilées's user avatar
4 votes
0 answers
586 views

Looking for more efficient VBA to Move data from Teradata to Excel

I have a simple macro moving data from Teradata to Excel. The process normally takes me 10 minutes to perform manually, however the macro can run for hours sometimes. This is making the macro seems ...
Pumpkin's user avatar
  • 51
4 votes
0 answers
70 views

Edit Excel through MS Access

I have an Access macro that runs AfterUpdate of a form. It opens an Excel workbook and edits a few cells. I have It working the way I want, but the problem is that ...
Bread Doughlas's user avatar
4 votes
0 answers
100 views

Source Control and Unit Tests

Context This post will be related to the code request I asked for, some time ago. I would like to focus this time not strictly on the implementation of the ...
FlameHorizon's user avatar
4 votes
0 answers
335 views

C# Dictionary Wrapper for VBA

I am a technical reviewer/writer and I use VBA for Word a lot to manage issues in Word documents I receive. I have frequently come across niggles when using Collections, Scripting.Dictionaries or ...
Freeflow's user avatar
  • 645
4 votes
0 answers
188 views

Reusable Progress Indicator

As many have done on this site, I decided to create a progress indicator using a modeless Userform. However, my goal was to make said progress indicator as generic/reusable as possible. While doing ...
rickmanalexander's user avatar
4 votes
0 answers
78 views

Search for used Range.NumberFormats in Excel workbook

On an overly abused workbook we've hit the limit and NumberFormats can no longer be added. If we do want to add more we need to consolidate current formats. My code ...
IvenBach's user avatar
  • 3,487
4 votes
0 answers
919 views

So what if the "View" in an MVC isn't a Userform, but is the Worksheet?

So I've been following the discussions around VBA as an OOP language and the applicability of various design patterns, such as MVP or MVC. Excellent postings on these topics are extremely informative ...
PeterT's user avatar
  • 2,116
4 votes
0 answers
8k views

Function to return JSON-like objects using VBA collections and arrays

My goal is to create a compact function that can create a JSON Like object from JSON string. I want a function with a small footprint that I or anyone who wants to use it, can simply paste into a ...
TinMan's user avatar
  • 4,143
4 votes
0 answers
1k views

Using Excel Cell StyleElements to Style HTML Document

CellStyleCSS class creates css based of Excel Workbook CellStyles. This class is used in conjunction with TagBuilder class, ...
user avatar
4 votes
0 answers
54 views

Word - convert list of images to images

I don't work much in Word VBA so I approached this similar to how I'd approach it in excel, which may not have been optimal. I also didn't see any places for errors to be handled. This takes a Word ...
Raystafarian's user avatar
  • 7,159
4 votes
0 answers
112 views

Comb Sort Multi-dimensional Array on Key

Previously: Comb Sort in VBA I've been running two different comb sorts (on arrays) depending on whether I want to sort numbers or strings and I figured I would give using ...
Raystafarian's user avatar
  • 7,159
4 votes
1 answer
519 views

Creating / Uncompressing zip files in VBA revision

This is a followup code review request for a previous post: Creating / Uncompressing zip files in VBA I did most of the suggesttions presented in the last code post, but as I significantly improved ...
shadowofsilicon's user avatar
3 votes
0 answers
359 views

Iterate internal array for a VBA class

After spending a considerable amount of time poking at the internals of the Collection class, I have discovered 2 methods to iterate a private internal array within ...
Cristian Buse's user avatar
3 votes
0 answers
384 views

A vehicle database in Excel

I'm looking for some help. I'm new to coding and have started creating this Vehicle database program in Excel for a friend to use. He is wanting to be able to see all vehicles he owns, when ...
Kendall Briggs's user avatar
3 votes
0 answers
179 views

Fluent VBA: One Year Later

A little over a year ago, I asked for feedback on Code Review for a unit testing framework I created in VBA. Development of this project has been off and on for the past year. Sometimes I wouldn't ...
Brian Gonzalez's user avatar
3 votes
0 answers
201 views

Updating VBA code from a central repository in distributed Excel workbooks

I wrote this to help manage the code in a bunch of distributed workbooks. Maybe someday I will re-write this as an add-in, but for now, I just needed a way to manage the code without having to ...
CBRF23's user avatar
  • 409
3 votes
0 answers
403 views

Evaluate performance of DLL calls from VBA

While playing with a VBA project involving Windows APIs, I have noticed some odd behavior: API calls under Excel 2016/VBA7/x64 appeared to be much slower than under Excel 2002/VBA6/x32. Since I ...
PChemGuy's user avatar
  • 425
3 votes
0 answers
81 views

Setting a forecast for 2,5k workers intraday for a whole month

I'm working on a large project that requires a ton of data to be processed. I was thinking that using classes would be the best way, and it is, until it has to dump out the memory at the end of every ...
Damian's user avatar
  • 198
3 votes
0 answers
93 views

DataManager Class: Sorts Array by 1 or More Dynamically Added Columns in Ascending or Descending Order

I've been struggling to write a QuickSort algorithm to sort multiple columns of an Array for weeks. Finally, I decided to write a class that Implements mscorlib.IComparer and it has exceeded my ...
TinMan's user avatar
  • 4,143