I'm creating a large amount of Excel test files with different values in many columns.
(Windows 7 - 64 bits system (if relevant)).
These files are going to be imported into a database later using other unknown tool, so I just have to prepare only these files filled with valid data.
Each file has different columns, so different ranges of valid characters are necessary per column.
What would I want to do?
Use a Formula witch receive a regex and generate/and fill the cell with a random string based on that regex and if possible specify how many characters the string should be.
Something like this site does: https://www.browserling.com/tools/text-from-regex
For example: For the next columns, I would like to populate cells with random text as follows:
>
> -------------------------------------------------------------------
> | Name | Email | Date | URL | Price |
> -------------------------------------------------------------------
> | AHygsyub | xyz@uygsh.hyu | 1956 | http://iadif.jyf | 245.75 |
> -------------------------------------------------------------------
Using something like this in the Formula bar:
> =fillCellWith('([a-z]{3,10} ){1,10}') //For Name column
> =fillCellWith('\d{4}') //For Date column
> =fillCellWith(RegexPattern) //Etc etc
Can someone guide me in the creation of a VBA Function to accomplish this purpose?
I don't have any experience in VB programming, but I can imagine something like:
Public Function fillCellWith(MyRegex As String) As String
Dim regEx As New RegExp
Dim Rand As String
'Analize the pattern and create random string satisfying the pattern needs to be valid
'Merge all parts and return as a result in Rand
End Function