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.

114 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
13
votes
0answers
395 views

“String Interpolation in {language}”, “VBA”

"This is {0} cool!", "freaking" I've always wanted an easy and intuitive way to inject variables into a string. So after about 10 variations, I finally came up with this function. How it works The ...
12
votes
0answers
356 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 <...
10
votes
0answers
1k 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. ...
7
votes
0answers
2k 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 ...
7
votes
0answers
225 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 ...
7
votes
0answers
1k 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 ...
6
votes
0answers
53 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: ...
6
votes
0answers
99 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 ...
6
votes
0answers
106 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, ...
6
votes
0answers
412 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: ...
6
votes
0answers
474 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. ...
5
votes
0answers
113 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 ...
5
votes
0answers
136 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 ...
5
votes
0answers
61 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 ...
5
votes
0answers
910 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 ...
5
votes
0answers
341 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 ...
5
votes
0answers
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 ...
4
votes
0answers
66 views

Excel Chart - Crosshair cursor lines with VBA

Submitting for expert review. I am trying to create a Chart - Crosshair cursor in excel chart sheet. Chart - Crosshair cursor lines are two lines (one horizontal and other vertical) moving along with ...
4
votes
0answers
93 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 ...
4
votes
0answers
70 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 ...
4
votes
0answers
116 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 ...
4
votes
0answers
366 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 ...
4
votes
0answers
256 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 ...
4
votes
0answers
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 ...
4
votes
0answers
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, ...
4
votes
0answers
45 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 ...
4
votes
1answer
251 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 ...
3
votes
0answers
71 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 ...
3
votes
0answers
83 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 ...
3
votes
0answers
117 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 ...
3
votes
0answers
65 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 ...
3
votes
0answers
41 views

Network connection monitor

I was recently in need of a class that checks if a computer has a valid internet connection, so I wrote one; however, I feel that there is a better way to do so and I just don't have the knowledge ...
3
votes
0answers
98 views

Rich data types - boolean object

Context You can probably skim most of this, it's unlikely to be useful for a review and is just for background info. Also download the files I've tried to create a ...
3
votes
0answers
904 views

Alternative for VLOOKUP/Index-Match in VBA

I am sharing this function I wrote with the community to provide an alternative to slow VLOOKUP and/or Index-...
3
votes
0answers
59 views

Show File/Folder Hierachy as Grouped with Indentation

I was intrigued by this question on SO and was able to come up with a reasonably efficient answer, but I'm interested in learning about further optimizations. You can certainly look at my answer to ...
3
votes
0answers
332 views

Copying content from Excel into PowerPoint as a picture, with error handling

The code below works, but I want to ask if my solution is adequate or if there's something I should structure differently. If it's alright, I'll apply the same code in other subs. My code copies ...
3
votes
0answers
89 views

Comparing times of two worksheets

The below code works however it takes several minutes to run. Is there a way to optimise performance so that it can be completed in a shorter amount of time? My code is designed to look at the "...
3
votes
0answers
56 views

Code runs slower when executed from ribbon compared to directly in module

We use third party addin that downloads market data from the internet into a workbook. The addin works with custom functions that begin with CompanyAddin. For instance, a formula in a cell could look ...
3
votes
0answers
92 views

Retrieving data in multiple formats from Excel with Python

Scenario: I have an excel file that contains some data in the first sheet. That data can be simple strings on a cell or CheckBoxes (marked or not). Data example: ...
3
votes
0answers
341 views

Document “Search Engine” in Excel

I've created a somewhat "Brute-force search engine" based on a document's filename, as well as an additional keyword that describes the said document. I had to make one as my company's resources are a ...
3
votes
0answers
101 views

CheckedRange Class

This class is used to make Excel Cells behave like Checkboxes. Clicking the cell raises a CheckedRange_Clicked(Target as Range) event and toggles it's value ...
3
votes
0answers
168 views

Excel VBA to download from IE Database Stops Responding

first time using Code Review, although I have been active on StackOverflow, hope I'm in the right place. I am putting together Excel VBA code that using information from various columns on a ...
3
votes
0answers
90 views

Unit testing a custom collection

To enable unit testing in the VBA IDE I'm using https://github.com/rubberduck-vba/Rubberduck. I've created a class and a custom collection class to work with structural members I need to filter. The ...
3
votes
0answers
2k views

Await in… VBA?

Asynchronous programming is tricky enough already, and VBA doesn't make life any easier. I wanted to create some basic functionality to allow async processes to mark completion without having to ...
3
votes
0answers
5k 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 ...
3
votes
0answers
4k views

Fetching data from a website using “POST” request

I've written some code in vba for the purpose of making twofold "POST" requests to get to the destination page and harvest name and address from there. There are two types of structures within which ...
3
votes
0answers
1k views

Scraping table data from websites

I've written a script in vba to parse table from any website if the html elements are not encrypted in javascript. There is a table index in my script in which inputting the right number it is ...
3
votes
0answers
90 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 ...
2
votes
0answers
8 views

Sheet display in function of date and time on open and save

Here's a simple one for u guys, The code is called upon workbook_open and BeforeSave, it displays the right sheet in function of date and time (Day vs night shift vs date). The code run trough the ...
2
votes
0answers
84 views

Copying Data from multiple workbooks -> Into One Worksheet (continuous data)

I have a macro created by my predecessor that I run on a monthly basis. However, it does take a while to get through, and I would like to clean it up for efficiency please. It copies data from ...