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.

learn more… | top users | synonyms

2
votes
0answers
13 views

VBA - Cycles through a table to find the cheapest bearing that passes

I have written several VBA macros to run on an excel spreadsheet. Inputs are entered into a table and then the macro is run; it cycles through a table of Bearings (in price ascending order) and ...
2
votes
0answers
19 views

Managing a programmatically accessible stack trace

VBA has a call stack... but there's no programmatic way to tap into it, which means in order to get a stack trace for a runtime error, one has to manage it manually. Here's some example code that ...
5
votes
1answer
35 views

VBA to MS-Access SQL query set(s) and outputs

I am hoping I can get some guidance on some better "best practice" suggestions on how to handle this kind of code set. I understand that parameterized queries are a thing, but I am not quite there yet,...
1
vote
1answer
14 views

Generate SQL for translated resources from Excel Spreadsheet

I do some work that involves translating resources for a webpage. These are all stored in a SQL Server table that looks like this (plus a few irrelevant constraints). ...
2
votes
0answers
29 views

Multi-threaded web scraping VBA

I am working on a project on VBA where the objective is to have a "program" that fetches rates from a website called X-Rates, and outputs to excel the monthly averages of a chosen country. Initially ...
3
votes
0answers
22 views

Split cells vertically on comma MS Access 2010 VBA Module

This takes a field delimited by commas, and splits on the comma. The newly divided information is put in another field (created at the start of the program) called ...
-5
votes
0answers
32 views

Code Help for If Statement [closed]

I was looking for some help on writing some code for a nested if/and statement in a formula. Here is a portion of the formula ...
6
votes
2answers
58 views

VBA macro - searches through a filtered table, stops when entry passes criteria

I have written several subs which are then called from a main sub. Individual subs run very quickly, most are instantaneous (the DoFind sub takes a few seconds to run due to the large amounts of data ...
7
votes
2answers
198 views

Word VBA function to find a specified heading & return its text as a string

In this post, I asked for an overall review of a script to auto-generate table captions, because it was running relatively slowly. I've used Debug.Print to isolate the problem, and this function takes ...
5
votes
4answers
125 views

Trying to make more simple VBA

I have few models like this below for diferent tools i manage. I am trying to clean/improve the code... Could you help me? All the informations comes inside columns B to N, and the column P ...
4
votes
2answers
51 views

Simplifying manual data entry with a UserForm Excel 2010

I am an absolute beginner. This is the first thing I've ever coded in VBA. I don't know if I'm allowed to ask for just criticism in general without a question. But just in case I can't, this file is ...
5
votes
1answer
39 views

Word VBA Code to Automate Table Captioning

I have a Word VBA script that auto-generates a table caption based on user input & a previous heading. Its purpose is to speed up editing & formatting of massive software documents (like the ...
5
votes
3answers
55 views

CopyOf2DArray (Values Only)

Purpose: Given a 2-Dimensional Array, return a copy of the Array. In VBA, if I just Set newArray = oldArray then newArray is ...
5
votes
3answers
62 views

Filling a row with values

I started with VBA yesterday. Could this code be improved? ...
5
votes
4answers
193 views

Get Filtered Data Range in a Table

Purpose: Given a Worksheet Table (ListObject) that may, or may not, have a filter currently applied to it, return a range consisting only of the filtered data. ...
11
votes
1answer
137 views

Finding the cheapest hotel

I thought this question made a good excuse for some basic OOP code, so I whipped up a little bit of code to demonstrate it in VBA; the idea is to have tutorial-grade code, to show how interfaces and ...
3
votes
2answers
48 views

Accelerate the process of filling the quality control table

I'm working on a report of quality control. I've got a table, with all the points of control inside, and each time, when I get a new test result, Excel should fill this table. My code already works, ...
3
votes
3answers
79 views

Searching values of range X in range Y

This allows me to search each cell J4:J6525 in range K4:K6525. If it is found it will paste the values in Offset(0, 2) (column M). I run it for files with more than 60000 lines, and sometimes much ...
4
votes
2answers
31 views

Retrieve value from a formula in cells into different merged cells and retrieved value can be edited

I have created this macro and having a small issue. I am very new to this VBA and did this with experts’ guides by googling it. I am creating an excel form for a work purpose at work. The Excel form ...
1
vote
1answer
39 views

Finding and deleting a certain word

I have a working macro that finds a specific word and deletes the whole text. It finds the word "JOBSPECIALTYCODE" in the sheet, selects and deletes it, then moves to the next sheet. I just want to ...
3
votes
1answer
52 views

Copy sheet contents faster in Excel

I have code that opens a workbook and copies the sheet to the workbook running the code. I know activating is generally bad for speed but I can't figure out how to speed this up anymore. The data ...
2
votes
1answer
32 views

Converting values to Dates in column

I'm not happy about my code, but is the better way that I find, I'm not happy because I see that there are many code repetitions and when any change is easy to make mistakes. Do you think you can do ...
0
votes
0answers
17 views

Paste one array (single dimension) with >100K item into a excel range [migrated]

I posted the same question on StackOverflow thread but I think here is the correct place to ask (if is not right, admin please to remove it).Every day I need to format date imported from AS400 (data, ...
3
votes
1answer
96 views

Comparing two lists

I'm working on a report of quality control. I have a list L, which contains the names of files that I should open and import the data into EXCEL, then fill my quality control table by these data. And ...
8
votes
2answers
38 views

Reusable VBA macro to prevent Excel from destroying the data (+ backup capacity)

My goal is to prepare the Excel file (see the download link at the end) I would share with my non-technical colleagues, so that they enter some data into it and then I was able to automatically ...
5
votes
3answers
60 views

Loop through range, selecting grouped data?

I have some info. that looks like this: ...
7
votes
1answer
34 views

Audit Updating Macro

In my code, I'm trying to manipulate data for an audit between 3 sheets in a workbook.The first block of my code is to paste the data of items I need to find for the audit from the original sheet onto ...
3
votes
3answers
60 views

List(Of ) like operation in macro

NOTE: I previously asked this question in Stack Overflow and got pointed here. I have a macro that I am trying to get running a little more quickly. The intent of the macro is to merge multiple files ...
4
votes
3answers
85 views

Dealing Poker Hands

I thought I'd give a shot at creating my own version of dealing 5-card hands to n players in VBA, printing them to columns and coloring hearts and diamonds red. I felt I might have been a little ...
8
votes
4answers
93 views

Converting from .xlsx to .txt

I have code that converts each sheet of a spreadsheet into a .txt file. It works well, however, given the big number of exports (about 90 .txt files), I'd like to seek advice on how to speed it up. <...
3
votes
3answers
59 views

Error handling for cells.find

Revised and truncated version of my last question. I updated how I handle the error if a cost center is not found. I originally asked expecting improvements on the matching system so thoughts on that ...
0
votes
0answers
18 views

Automatically pull in data from one workbook into a template workbook and update the formulas [duplicate]

I have two workbooks: one being a template file with saved formulas that extend to the 30,000 row and the other workbook that contains the data that is input into the template file. Due to the fact ...
6
votes
3answers
78 views

Loop through a unique combinations driven by choices

I am trying to optimize my code and make it as fast as it can be, I have researched as much as I can and am now asking the community for any tips because there are definitely people more experienced ...
5
votes
3answers
241 views

Transferring data for a given month from one sheet to another

I have dollar amounts sorted by month that I want to transfer from sheet entry to sheet actuals. I only want to do it for a ...
10
votes
3answers
762 views

Macro that does some kind of duplicate check

This macro pulls in two workbooks, one being a template with saved formulas already, and the other containing data with thousands of rows...I need to increase the speed because the process takes more ...
4
votes
1answer
107 views

Clearing filters, copying a range, and then pasting a formula down a row

Novice coder here. I have the following code to perform a few actions like clearing filters, copying a range, and then pasting a formula down a row till the last line. It works perfectly, but it ...
10
votes
3answers
102 views

Userform for getting data from data sheet into a table

I am making a userform that grabs data from a data sheet and puts it into a table: Grabs the data based on what the user wants (Brand -> Items for brand) Allows multiple items to be added Displays ...
11
votes
4answers
591 views

Copying values from one sheet to another

I am trying to copy values from one sheet to another using loop with two conditions and it is very slow. Removing conditions from code doesn't have any effect on the speed of the execution. I already ...
7
votes
3answers
224 views

Summarize raw data in new sheet, 2.0

Thanks to zak for some great advice on this previous question. This is a follow up question: I have an Excel workbook with two sheets: "Raw data" and "Summary". In the raw data sheet there are ...
2
votes
1answer
42 views

Summarize raw data in new sheet

Note: This question has a follow up question here. I have an Excel workbook with two sheets: "Raw data" and "Summary". In the raw data sheet there are several blocks with data structured like the ...
9
votes
4answers
1k views

Create a list of random numbers with sum = n

I want to create a list of random integers in the range [0, 9], that sums up to 100 in Excel, using VBA. The list should be printed in a single column. The routine I've written is as follows: ...
3
votes
0answers
37 views

Mailmerge from Excel to premade template in Word

I've written the following code to take data from the Excel file "Data" and use it for a mailmerge in a prepare Word template named "Template." I'm new to using VBA in word or Access, so any feedback ...
10
votes
5answers
838 views

Macro code that removes excess rows

I'm a business student who just started to learn VBA. I am trying to write a macro for a project but only have minimal experience actually stepping into the code. The macro I have written is to ...
5
votes
1answer
55 views

Compare and find duplicates in 2 corresponding columns in 2 sheets

I want to compare (500) and find duplicate daily records within 2 sheets, and copy the unmatched row to another sheet, copy the match from another to 3rd sheet, and delete the matched records from ...
4
votes
2answers
48 views

Consolidate used student hours into master sheet for export

I've developed a spreadsheet that has evolved over several years to help keep track of the number of student contact hours that have been used to help flag up when students have run out / are running ...
6
votes
1answer
100 views

Excel VBA to parse JSON out of Google Maps API

Some code that I wrote and broke into 5 separate questions on stack overflow. Some guy wanted to query Google Maps receive some JSON and then for each result found within that JSON do another query. ...
2
votes
2answers
58 views

Importing data into Excel

Is there an easier way of importing data into an Excel array or other data structure? I've tried researching collections but I have found the documentation hard to comprehend. MSDN The code I have ...
6
votes
1answer
202 views

Print worksheets depending on checkbox. Slower than before

I have an userform that has check boxes where user can decide which worksheets to print. Code in userform: ...
4
votes
2answers
74 views

Importing JPG, JPEG, and PNG images from a folder to an Excel worksheet

As I am a novice, I was keen to solve the task, so now I want to optimize the code. ...
4
votes
1answer
39 views

Auto-upload tool

I created an automatic upload tool, which is working great (most of the time). As I want to improve the code I have several questions: Is it possible to make the iexplorer process smoother? I don't ...