CREATE PHP csv File with Umlauts for Excel

To create a csv file, where the umlauts are correctly coded, you have to be in your project, which is normally encoded UTF-8, encode the umlauts according to UTF-16LE. This encoding can be viewed from Windows and Mac.

$file = fopen('file.csv', 'w');
foreach ($rows as $row) {
 $row = array_map(function($cell){
 return mb_convert_encoding($cell, 'UTF-16LE', 'UTF-8');
 }, $row);
 fputcsv($file, $row, ';');

MS Excel: Error when compiling project or library not found

The error message “Error when compiling project or library not found” I had today, She was at one point, to the a variable not previously with Dim were been initialized. There stopped running when my Excel for MAC with the error message:

Fehler beim Kompilieren Projekt oder Bibliothek nicht gefunden

The cause was actually, that a Windows Library was not available, After the reference was removed, everything went back.

Visual Basic Editor-> Extras-> References

There, remove the tick with “DOES NOT EXIST”:

Bildschirmfoto 2017-09-18 um 14.47.13


VBA on dropdown change event

When you want to trigger an action on dropdowns or cell/range change , you can do this by using the Worksheet_Change event and named ranges:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim checkTarget As Range
    Set checkTarget = Application.Intersect(Target, Range("my_named_range"))
    If checkTarget Is Nothing Then
        Debug.Print "not active range, exit"
        MsgBox "success"
    End If

End Sub

VBA regex Lite with like

Regex not possible are native in VBA, but only via an ActiveX library available. If you ffor Mac want to program, It's out of question. Instead, you can the regex Lite command “Like” use, with the similar abegspeckte operations can be.


success = text Like "T-#########-#"

success = text Like "[0-9a-z][0-9a-z]"
'1a, 2b

VBA Excel key-value store cache with dictionary

To increase the performance of long-running calculations with MS Excel, I have installed a rudimentary key-value cache for a recurrent computation using a Dictionary object.

A dictionary is an object from the object in VBA Microsoft scripting library, that must included in the project on:

  1. Open Visual Basic Editor in Excel
  2. Extras-> References
  3. Microsoft scripting library Use Kreutzchen

A Dictionary object is like an associative array, What is already the greatest feeling for VBA :)

The following code is cached the result of a function call in a public (public, global scope) Variable named “cache”:

'this code does not run, it is pseudo code understand the cache behaviour

'public variable, global scope
Dim cache  As Scripting.Dictionary

sub mySub()
    'initialize cache
    Set cache = = New Scripting.Dictionary 
    For Each myRow In rows
        resultFromCache = myFunction(1 , 2, 3)
    Next myRow
end Sub

Function myFunction(input1, input2, input3)
    'chache this result
    cacheKey = input1 & " " & input2 & " " & input3
    If Not cache.Exists(cacheKey) Then
        result = cacheAbleFunction(input1, input2, input3)
        cache.Add cacheKey, result
        result = cache.Item(cacheKey)
    End If
    myFunction = result
end Function

Function cacheAbleFunction(input1, input2, input3)
    'do something here very slow or very often
    cacheAbleFunction = input1 * input2 * input3 * input1 * input2 * input3 * input1 * input2 * input3
end Function

I have more tips to optimize the performance of Excel macros in the article Excel Markos speed up Guide summarized.

VBA Excel: Mark mouse pointer over a cell as active

Unfortunately, there is an event to register no way via VBA, If the mouse pointer over a cell is.

The only way to get around this, must be a macro on an image/button in a cell, What is then executed. If a cell is associated with a macro, the mouse pointer automatically activates, alerts the user to, that is an active click option.

Link a macro on a cell

  1. Insert a durchsichttbaren .png files or a visible image/button in the cell
  2. right mouse button on the Insert object
  3. Assign macro
  4. Now the mouse is active, If you go over the image

The Excel Markos speed up Guide

If Excel macros to run slowly, because they must meet ever more complex requirements, can you use the following tricks, to enable a faster runtime:

VBA tips

Build a simple caching

See post VBA Excel key-value store cache with dictionary

Simple profiling to find bottlenecks in the application

The Term of certain calculations You can determine, by placing one time measurements in the VBA code on suitable place and spend on the debug console can be. This can be parsed, which parts of the application behave slowly.

Disable events during the Scriptlaufzeit

Are thus thrown no events such as:

Private Sub Worksheet_Change(ByVal Target As Range)

to prevent the event throwing and prevent unnecessary Excel events:

Application.EnableEvents = False
'your macro
Application.EnableEvents = True


VBA Excel Configurator: Calculation of all possible combinations

To build a Produktkonfigurators with Excel you need most of the time a matrix, they are defined in the, What configuration parameters with which other parameters together are possible and which are in the combination auschließen, e.g.. the color white is available for the iPhone 6, but not for the 16 GB version.

These rules are susceptible to error ser, Therefore you need an issue to testing all possible variants of the Configurator.

The many possible combinations are the biggest problem with larger configurators, for that it ever can take weeks to calculate all, If you're trying to go through all possible combinations, because I doubled the run-time with any other possible configuration option. more…