Skip to main content

All Questions

Tagged with
0 votes
0 answers
46 views

Faster method to check if a string is found inside Word Files in a directory and subdirectories

I need to check if a string is found inside a Word File in a directory and subdirectories. I have tried to use Advanced Search of MS Windows 10, to search inside ...
Peace's user avatar
  • 113
6 votes
1 answer
448 views

Fastest function to `Remove Duplicate Lines` per each cell

The below function is used to Remove Duplicate Lines per each cell. It works without problem, but it is slow with a range of only one column and 17k rows. Actually, ...
Leedo's user avatar
  • 275
3 votes
1 answer
302 views

Create VBA string array fastest method

My VBA has become really rusty but I need it for now for some data downloading. This routine works but I'm certain that over the last 10 (at least) years something quicker/less code has surfaced to do ...
dinotom's user avatar
  • 131
4 votes
3 answers
474 views

Excel VBA code midStr() function using left and right position instead of length used with mid()

In the early days of Basic (1970's when i started coding) the midStr() function used left and right positions directly rather than left and length we now use with mid(). I always found it more ...
Mark Main's user avatar
  • 209
4 votes
2 answers
931 views

Excel VBA Code for Imperial Length Measure Conversion and Formatting Yards Feet and Inches for English and Spanish

STR2INCHES is an Excel VBA Function that will convert string text for Imperial length measurements to a decimal number of Inches. It handles both English and Spanish words, abbreviations and symbols ...
Mark Main's user avatar
  • 209
5 votes
1 answer
117 views

Similarity between words

I'm writing a method that writes the code for a loading routine. Given an object from the database, I want to put its properties in the right control on a userform. I have the list of the properties ...
DT1's user avatar
  • 354
1 vote
2 answers
51 views

Trimming strings in non-contiguous spreadsheet ranges

This code is tested and works, but I am needing some guidance on simplifying these loops with non-contiguous ranges. I was thinking an array might be better, but I ...
Zack E's user avatar
  • 593
4 votes
1 answer
329 views

VBA Text Class, sort of like .NET

This is my first attempt at writing some reusable OOP code. The problem I'm trying to simplify is the confusing (at least to me) structure of VBA string manipulation. Example ...
Ryan Wildry's user avatar
1 vote
3 answers
722 views

Excel VBA Retrieving a Specific Pattern from String

The following VBA code is in response to a SuperUser question which I found interesting. What I'm looking for in a response? Code cleanliness. Can I do more to make the code easier to read and ...
Nahuatl's user avatar
  • 131
3 votes
1 answer
234 views

Safely and efficiently parse and replace tokens in a string

I have written a VBA function that will do parsing / replacement according to tokens / placeholders. Example: Input string: Username %u, date is %d. The function ...
Alexander's user avatar
  • 257
1 vote
1 answer
87 views

Transforming the case of text using Excel VBA

I created a simple user form for my VBA course. I then created the following VBA code: ...
Nahuatl's user avatar
  • 131
6 votes
1 answer
505 views

Replace function in VBA

For reasons I'd rather like to not talk about, I am in a VBA environment that doesn't have the replace function (Access 97). I have wrote this to alleviate my frustrations. My question is, what is ...
Doug Coats's user avatar
1 vote
1 answer
56 views

Add spaces around variable with $ symbol bookends

I have some code in a particular coding language, and I am trying to clean it up by adding spaces around the variables. I wrote this code, and it works on small amounts of text and if I set a break ...
Jacob Bischoff's user avatar
3 votes
1 answer
117 views

Return a substring containing a certain pattern to VBA

I've written in a C++ dll the following function to return to VBA a substring containing a certain pattern, given an input string, which contains that substring: ...
Noldor130884's user avatar
6 votes
3 answers
204 views

Rubberduck Test Module Creation

I recently started learning C# and am taking the opportunity to try and accelerate my introduction by helping the RubberDuck team (Website and GitHub Repo). The full class code that I'm working on can ...
IvenBach's user avatar
  • 3,487
12 votes
2 answers
25k views

String Repeat function in VBA

VBA has built-in functions for repeating a single character: Function String$(Number As Long, Character) As String ...
ThunderFrame's user avatar
  • 1,959
12 votes
4 answers
2k views

Delete rows in spreadsheet where cells match some patterns

I have vba code that loops through a large number of records and deletes rows based on criteria. The issue at hand is that it takes far too long to run. I have never actually let it finish because it ...
PartyHatPanda's user avatar
7 votes
1 answer
230 views

A Moses's worthy string splitter

I am trying to perfect my string splitter's performance, to be more fast, more easy to maintain if someone else reads it and more readable code-wise. Context ,Scope and Objectives Where I work we ...
svacx's user avatar
  • 433
7 votes
4 answers
15k views

Hex encoding and decoding of ASCII strings in VBA

I needed to convert some Ascii text to binary in Hex format 0x00FF.... I've written an EncodeHex and a ...
ThunderFrame's user avatar
  • 1,959
2 votes
1 answer
688 views

Trimming whitespace in Excel cells

I often receive large Excel-sheets in which data has been inserted via copy and paste. Usually a lot of the cells contain whitespaces at the beginning and the end before / after the actual value. I ...
michael.zech's user avatar
  • 4,358
4 votes
1 answer
2k views

Hex to Double converter

I stumbled on this SO question which was asking about a way to convert larger hex values to a positive numeric value: ...
Mathieu Guindon's user avatar
6 votes
2 answers
1k views

Next revision letter

This is a fun one! I wrote some code to automatically get the next revision letter for a file by looking at the existing letter. It works, but I think there is room for improvement as far as ...
CBRF23's user avatar
  • 409
5 votes
2 answers
1k views

Text files: Copy, Rename, Append/Merge together

I wrote 3 subroutines related to batch data processing, they will be used together. A bit of background, I wrote this for my admin colleagues who do not write code. An application dumps daily ...
Phrancis's user avatar
  • 20.4k
8 votes
1 answer
11k views

Representing Objects as strings in VBA

I am working an a more meaningful way to print objects in VBA. The desired result should look something like this. ...
cheezsteak's user avatar
  • 2,401
43 votes
4 answers
14k views

A lightning-fast StringBuilder

In the process of trying to build a serializable data structure, I found myself building large strings, which gets very slow because VBA copies a string every time concatenation is performed. To ...
Blackhawk's user avatar
  • 1,134
9 votes
3 answers
1k views

Ugly workaround to get the vbext_ProcKind of a procedure is breaking encapsulation

This is a follow up to Extending the VBAExtensibility Library. It turns out that code had a really nasty bug. Anytime vbeProcedure.StartLine got called, I was ...
RubberDuck's user avatar
  • 30.8k
4 votes
2 answers
842 views

Extract a character at particular place in a string

I have a function: ...
Sujith Karivelil's user avatar
20 votes
3 answers
3k views

A CSharpish String.Format formatting helper

A while ago I implemented .net's string.Format() method in VB6; it works amazingly well, but I'm sure there has to be a way to make it more efficient. I'll start ...
Mathieu Guindon's user avatar
10 votes
3 answers
977 views

A more readable InStr: StringContains

Consider the following: If myString = "abc" Or myString = "def" [...] Or myString = "xyz" Then In C# when myString == "abc" ...
Mathieu Guindon's user avatar