<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>anweisung Archive - Robert Skibbe</title>
	<atom:link href="https://robbelroot.de/blog/tag/anweisung/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>alias RobbelRoot – Freelance Full Stack Developer .NET</description>
	<lastBuildDate>Wed, 25 Mar 2026 17:14:40 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://robbelroot.de/wp-content/uploads/2020/12/cropped-favicon-32x32.png</url>
	<title>anweisung Archive - Robert Skibbe</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Excel Makro Button</title>
		<link>https://robbelroot.de/blog/excel-makro-button/</link>
					<comments>https://robbelroot.de/blog/excel-makro-button/#comments</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Mon, 09 Aug 2021 16:01:21 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Visual Basic for Applications]]></category>
		<category><![CDATA[Visual Basic for Applications Problemlösungen]]></category>
		<category><![CDATA[anweisung]]></category>
		<category><![CDATA[anweisungen]]></category>
		<category><![CDATA[ausführen]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[calculation]]></category>
		<category><![CDATA[chain]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[execute]]></category>
		<category><![CDATA[kalkulation]]></category>
		<category><![CDATA[kalkulationen]]></category>
		<category><![CDATA[kette]]></category>
		<category><![CDATA[knopf]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[makro]]></category>
		<category><![CDATA[run]]></category>
		<category><![CDATA[starten]]></category>
		<category><![CDATA[tabelle]]></category>
		<category><![CDATA[tabellen]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vba]]></category>
		<category><![CDATA[visual basic]]></category>
		<guid isPermaLink="false">https://robbelroot.de/?p=5169</guid>

					<description><![CDATA[<p>Excel Makro Button Lasse mit einem Excel Makro Button eine vorgefertigte Kette von Anweisungen ausführen und deine Arbeit vereinfachen. Wie Du einen solchen Button erstellst, um ein definiertes Makro aufzurufen lernst Du in meinem heutigen Beitrag zum Thema Excel VBA. Vielleicht hast Du ja später noch Interesse an anderen Excel &#8230;</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/excel-makro-button/">Excel Makro Button</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><a href="https://robbelroot.de/wp-content/uploads/2021/08/Excel-Makro-Button.png"><img fetchpriority="high" decoding="async" width="1024" height="536" src="https://robbelroot.de/wp-content/uploads/2021/08/Excel-Makro-Button-1024x536.png" alt="Excel Makro Button" class="wp-image-5179" title="Excel Makro Button" srcset="https://robbelroot.de/wp-content/uploads/2021/08/Excel-Makro-Button-1024x536.png 1024w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-Makro-Button-300x157.png 300w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-Makro-Button-768x402.png 768w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-Makro-Button-700x366.png 700w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-Makro-Button-332x174.png 332w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-Makro-Button.png 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Excel Makro Button</figcaption></figure>






<h2 class="wp-block-heading">Excel Makro Button</h2>



<p>Lasse mit einem <strong>Excel Makro Button</strong> eine vorgefertigte <strong>Kette von Anweisungen</strong> <strong>ausführen </strong>und deine Arbeit vereinfachen.</p>



<p><strong>Wie </strong>Du einen <strong>solchen Button erstellst</strong>, um ein <strong>definiertes Makro aufzurufen </strong>lernst Du in meinem <strong>heutigen Beitrag </strong>zum Thema <strong>Excel VBA</strong>.</p>



<p><strong>Vielleicht </strong>hast Du ja <strong>später </strong>noch Interesse an <strong>anderen Excel VBA Beiträgen</strong>: <strong><a href="https://robbelroot.de/blog/vba-for-schleife/" target="_blank" rel="noreferrer noopener">VBA For Schleife</a></strong>, <strong><a href="https://robbelroot.de/blog/vba-msgbox/" target="_blank" rel="noreferrer noopener">MsgBox</a></strong>, <strong><a href="https://robbelroot.de/blog/vba-range/" target="_blank" rel="noreferrer noopener">Range</a></strong>.</p>



<pre class="wp-block-verse"><strong>Achtung</strong>! <strong>Bevor </strong>Du mit Makros <strong>durchstarten </strong>kannst, <strong>musst </strong>Du Sie vorher in Excel <strong>aktivieren</strong>!</pre>



<h2 class="wp-block-heading">Was sind Makros?</h2>



<p><strong>Nicht </strong>zu <strong>verwechseln mit </strong>dem slawischen, männlichen Vornamen &#8222;Marko&#8220;, <strong>ist </strong>ein <strong><a href="https://de.wikipedia.org/wiki/Makro" target="_blank" rel="noreferrer noopener">Makro</a></strong> eine <strong>Folge von Anweisungen</strong>.</p>



<p><strong>Besonders </strong>häufig, bzw. besonders <strong>beliebt </strong>sind <strong>Makros </strong>im <strong>Automatisierungsbereich </strong>in verschiedenen Kontexten.</p>



<p><strong>Speziell </strong>die <strong>Arbeit </strong>mit <strong>Tabellen </strong>aus z. B. <strong><a href="https://de.wikipedia.org/wiki/Microsoft_Excel" target="_blank" rel="noreferrer noopener">Microsoft Excel</a></strong> <strong>bietet </strong>die <strong>Erstellung </strong>und <strong>Verwendung </strong>solcher hilfreichen <strong>Makros </strong>an.</p>



<p><strong>Dabei </strong>wird dem Nutzer <strong>nicht nur </strong>vorhandene und zukünftige <strong>Arbeit abgenommen</strong>, die Arbeit kann dadurch auch wesentlich <strong>effizienter gestaltet</strong> werden!</p>



<h2 class="wp-block-heading">Makros ausführen</h2>



<p>Um bereits erstellte <strong>Makros auszuführen </strong>kannst Du <strong>verschiedene Methoden</strong> verwenden, darunter:</p>



<h3 class="wp-block-heading">Möglichkeiten</h3>



<ul class="wp-block-list">
<li>durch eine <strong>Tastenkombination</strong></li>



<li>beim <strong>Öffnen </strong>einer <strong>Projektmappe</strong></li>



<li><strong>aus </strong>dem Visual Basic Editor (<strong>VBE</strong>)</li>



<li>und <strong>mehr</strong>..</li>
</ul>



<p>In <strong>diesem</strong> <strong>Beitrag </strong>beschäftigen wir uns allerdings mit einem <strong>Button</strong>, <strong>also </strong>dem <strong>Ausführen </strong>eines <strong>Makros </strong>bei <strong>Klick auf </strong>einem Button.</p>



<h2 class="wp-block-heading">Methode 1: Button als Form einfügen</h2>



<p><strong>Damit </strong>wir einen <strong>Knopf verwenden </strong>können, um ein jeweiliges &#8222;auf Ihm&#8220; hinterlegtes <strong>Makro auszuführen</strong>, müssen wir diesen <strong>Knopf </strong>natürlich erst einmal <strong>hinzufügen</strong>.</p>



<pre class="wp-block-verse has-black-color has-text-color"><strong>Achtung!</strong> <strong>Je nach</strong> Excel <strong>Version kann </strong>sich die Menüführung <strong>unterschiedlich </strong>gestalten. Schaue auch ggf. in den <strong>Entwicklerwerkzeugen </strong>in Excel vorbei <strong>und prüfe </strong>vorher, <strong>ob </strong>du Diese <strong>aktiviert </strong>hast! Verwende für Excel-Sheets mit Makros auch die Dateiendung "<strong>.xlsm</strong>".</pre>



<h3 class="wp-block-heading">Einfügen Menü</h3>



<p>Gehe dazu in das <strong>obere Menü </strong>von Excel und <strong>suche </strong>den Punkt &#8222;<strong>Einfügen</strong>&#8222;:</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/08/Excel-Menue-Einfuegen.png"><img decoding="async" width="397" height="247" src="https://robbelroot.de/wp-content/uploads/2021/08/Excel-Menue-Einfuegen.png" alt="Excel Menü Einfügen" class="wp-image-5183" title="Excel Menü Einfügen" srcset="https://robbelroot.de/wp-content/uploads/2021/08/Excel-Menue-Einfuegen.png 397w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-Menue-Einfuegen-300x187.png 300w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-Menue-Einfuegen-332x207.png 332w" sizes="(max-width: 397px) 100vw, 397px" /></a><figcaption class="wp-element-caption">Excel Menü Einfügen</figcaption></figure>



<h3 class="wp-block-heading">Abgerundetes Rechteck</h3>



<p>Wähle <strong>anschließend </strong>aus, dass Du eine <strong>Form </strong>wie z. B. das <strong>abgerundete Rechteck einfügen </strong>möchtest:</p>



<pre class="wp-block-verse"><strong>Achtung! </strong>Auch hier nochmal der <strong>Hinweis </strong>auf <strong>unterschiedliche </strong>Excel-<strong>Versionen </strong>– Falls Du nicht fündig wirst, <strong>schaue </strong>doch mal <strong>ins Menü </strong>"<strong>Entwickler</strong>" (es muss erst aktiviert werden!)</pre>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-einfuegen.png"><img decoding="async" width="615" height="252" src="https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-einfuegen.png" alt="Excel abgerundetes Rechteck einfügen" class="wp-image-5185" title="Excel abgerundetes Rechteck einfügen" srcset="https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-einfuegen.png 615w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-einfuegen-300x123.png 300w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-einfuegen-332x136.png 332w" sizes="(max-width: 615px) 100vw, 615px" /></a><figcaption class="wp-element-caption">Excel abgerundetes Rechteck einfügen</figcaption></figure>



<h3 class="wp-block-heading">Button gestalten</h3>



<p><strong>Danach </strong>kannst Du deinen <strong>Button</strong>, bzw. dein abgerundetes Rechteck so <strong>gestalten </strong>wie Du magst:</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-Button.png"><img loading="lazy" decoding="async" width="418" height="229" src="https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-Button.png" alt="Excel abgerundetes Rechteck Button" class="wp-image-5188" title="Excel abgerundetes Rechteck Button" srcset="https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-Button.png 418w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-Button-300x164.png 300w, https://robbelroot.de/wp-content/uploads/2021/08/Excel-abgerundetes-Rechteck-Button-332x182.png 332w" sizes="auto, (max-width: 418px) 100vw, 418px" /></a><figcaption class="wp-element-caption">Excel abgerundetes Rechteck Button</figcaption></figure>



<h2 class="wp-block-heading">Makro an Button binden</h2>



<p>Nachdem wir im <strong>vorherigen </strong>Schritt den <strong>Button </strong>an sich mit <strong>Einfügen </strong>eines <strong>abgerundeten Rechtecks erledigt</strong> haben, können wir Diesem <strong>nun </strong>das <strong>Makro zuweisen</strong>.</p>



<p><strong>Klicke </strong>den <strong>Button </strong>dazu <strong>einfach </strong>mit der <strong>rechten Maustaste </strong>an und wähle &#8222;<strong>Makro zuweisen</strong>&#8220; – fertig!</p>



<p><strong>Nun </strong>kannst Du Dein <strong>definiertes</strong> <strong>Makro </strong>über den hinzugefügten und gestylten <strong>Button </strong>aufrufen!</p>



<h2 class="wp-block-heading">Methode 2: Schaltfläche über den Entwickler-Tab einfügen</h2>



<p>Die zweite &#8211; und oft bessere &#8211; Methode nutzt den Entwickler-Tab in Excel.<br>Damit erhältst Du eine echte Formular-Schaltfläche, bei der das Makro<br>direkt beim Erstellen zugewiesen wird.</p>



<h3 class="wp-block-heading">Schritt 1: Entwickler-Tab aktivieren</h3>



<p>Falls der Entwickler-Tab noch nicht sichtbar ist:<br>Datei → Optionen → Menüband anpassen → Entwicklertools aktivieren → OK.</p>



<h3 class="wp-block-heading">Schritt 2: Schaltfläche einfügen</h3>



<p>Wechsle in den Tab „Entwickler&#8220; und klicke auf „Einfügen&#8220;. Unter „Formularsteuerelemente&#8220; findest Du das Symbol für eine Schaltfläche (erstes Icon). Zeichne die Schaltfläche auf dem gewünschten Bereich im Sheet.</p>



<h3 class="wp-block-heading">Schritt 3: Makro direkt zuweisen</h3>



<p>Direkt nach dem Loslassen der Maus öffnet sich automatisch der Dialog &#8222;Makro zuweisen&#8220;. Wähle Dein Makro aus der Liste, oder erstelle ein neues direkt über &#8222;Neu&#8220;.</p>



<h2 class="wp-block-heading">Ein einfaches VBA-Makro als Beispiel</h2>



<p>Falls Du noch kein Makro hast, hier ein schnelles Beispiel zum Testen. Öffne den VBA-Editor mit Alt + F11, füge ein neues Modul ein und trage folgenden Code ein:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Sub MeinMakro()
    MsgBox "Makro wurde erfolgreich ausgeführt!", vbInformation, "Info"
End Sub</pre>



<p>Weise dieses Makro anschließend Deinem Button zu — fertig. Beim Klick auf den Button erscheint eine Meldung als Bestätigung.</p>



<h2 class="wp-block-heading">FAQ</h2>



<div class="schema-faq wp-block-yoast-faq-block"><div class="schema-faq-section" id="faq-question-1774458690215"><strong class="schema-faq-question"><strong>Wie erstelle ich einen Excel Makro Button?</strong></strong> <p class="schema-faq-answer">Füge über Einfügen → Formen ein abgerundetes Rechteck ein, gestalte es als Button und weise per Rechtsklick → „Makro zuweisen&#8220; ein VBA-Makro zu. Alternativ: Entwickler-Tab → Einfügen → Formular-Schaltfläche.</p> </div> <div class="schema-faq-section" id="faq-question-1774458703011"><strong class="schema-faq-question"><strong>Wo finde ich den Entwickler-Tab in Excel?</strong></strong> <p class="schema-faq-answer">Er ist standardmäßig ausgeblendet. Aktivieren über: Datei → Optionen → Menüband anpassen → Häkchen bei „Entwicklertools&#8220; setzen → OK.</p> </div> <div class="schema-faq-section" id="faq-question-1774458709735"><strong class="schema-faq-question"><strong>Was ist der Unterschied zwischen Form-Button und Formular-Schaltfläche?</strong></strong> <p class="schema-faq-answer">Der Form-Button (abgerundetes Rechteck) ist flexibler gestaltbar. Die Formular-Schaltfläche aus dem Entwickler-Tab ist schlichter, aber direkter — das Makro wird beim Erstellen sofort zugewiesen.</p> </div> </div>
<p>Der Beitrag <a href="https://robbelroot.de/blog/excel-makro-button/">Excel Makro Button</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/excel-makro-button/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>IFS VBA</title>
		<link>https://robbelroot.de/blog/ifs-vba/</link>
					<comments>https://robbelroot.de/blog/ifs-vba/#comments</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Sun, 08 Aug 2021 22:55:15 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Visual Basic for Applications]]></category>
		<category><![CDATA[Visual Basic for Applications lernen]]></category>
		<category><![CDATA[abfrage]]></category>
		<category><![CDATA[abfragen]]></category>
		<category><![CDATA[anweisung]]></category>
		<category><![CDATA[ausdruck]]></category>
		<category><![CDATA[bedingung]]></category>
		<category><![CDATA[bedingungen]]></category>
		<category><![CDATA[branch]]></category>
		<category><![CDATA[branching]]></category>
		<category><![CDATA[condition]]></category>
		<category><![CDATA[conditions]]></category>
		<category><![CDATA[different]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[ifs]]></category>
		<category><![CDATA[kalkulation]]></category>
		<category><![CDATA[konditionen]]></category>
		<category><![CDATA[makro]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[microsoft 365]]></category>
		<category><![CDATA[msft]]></category>
		<category><![CDATA[office 365]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[result]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[statement]]></category>
		<category><![CDATA[tabellen]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[verzweigung]]></category>
		<category><![CDATA[verzweigungen]]></category>
		<category><![CDATA[visual basic]]></category>
		<guid isPermaLink="false">https://robbelroot.de/?p=5138</guid>

					<description><![CDATA[<p>IFS VBA Möchtest Du mit der IFS VBA Funktion/Formel umzugehen wissen, bzw. verstehen was Diese überhaupt ist? Dann heiße ich Dich in meinem heutigen Beitrag zur Visual Basic for Applications Kategorie herzlich willkommen. Vielleicht steht Dir anschließend auch noch der Sinn nach anderweitigen VBA relevanten Beiträgen: VBA For Schleife, InStr, &#8230;</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/ifs-vba/">IFS VBA</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><a href="https://robbelroot.de/wp-content/uploads/2021/08/IFS-VBA-Funktion-Verzweigung.png"><img loading="lazy" decoding="async" width="1024" height="536" src="https://robbelroot.de/wp-content/uploads/2021/08/IFS-VBA-Funktion-Verzweigung-1024x536.png" alt="" class="wp-image-5140" srcset="https://robbelroot.de/wp-content/uploads/2021/08/IFS-VBA-Funktion-Verzweigung-1024x536.png 1024w, https://robbelroot.de/wp-content/uploads/2021/08/IFS-VBA-Funktion-Verzweigung-300x157.png 300w, https://robbelroot.de/wp-content/uploads/2021/08/IFS-VBA-Funktion-Verzweigung-768x402.png 768w, https://robbelroot.de/wp-content/uploads/2021/08/IFS-VBA-Funktion-Verzweigung-700x366.png 700w, https://robbelroot.de/wp-content/uploads/2021/08/IFS-VBA-Funktion-Verzweigung-332x174.png 332w, https://robbelroot.de/wp-content/uploads/2021/08/IFS-VBA-Funktion-Verzweigung.png 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption>IFS VBA</figcaption></figure>






<h2 class="wp-block-heading">IFS VBA</h2>



<p><strong>Möchtest </strong>Du mit der <strong>IFS VBA</strong> Funktion/Formel umzugehen wissen, bzw. <strong>verstehen was </strong>Diese überhaupt <strong>ist</strong>?</p>



<p>Dann <strong>heiße ich Dich </strong>in meinem heutigen Beitrag zur Visual Basic for Applications Kategorie <strong>herzlich willkommen</strong>.</p>



<p><strong>Vielleicht </strong>steht Dir <strong>anschließend </strong>auch <strong>noch </strong>der Sinn nach anderweitigen <strong>VBA relevanten Beiträgen</strong>: <strong><a href="https://robbelroot.de/blog/vba-for-schleife/" target="_blank" rel="noreferrer noopener">VBA For Schleife</a></strong>, <strong><a href="https://robbelroot.de/blog/vba-instr/" target="_blank" rel="noreferrer noopener">InStr</a></strong>, <strong><a href="https://robbelroot.de/blog/vba-range/" target="_blank" rel="noreferrer noopener">Range</a></strong>.</p>



<pre class="wp-block-verse"><strong>Achtung</strong>! Die IFS Funktion ist <strong>nur im Excel-Kontext</strong> <strong>als Formel </strong>vorhanden! Die dazu <strong>benötigte Excel </strong>Version findet man auf <strong>Windows &amp; Mac</strong>, wenn man <strong>mind. Office 2019</strong>, oder ein <strong>Microsoft 365 Abonnement </strong>hat.</pre>



<h2 class="wp-block-heading">Awendungsfälle</h2>



<p><strong>Wer </strong>kennt es <strong>nicht</strong>? <strong>Man möchte </strong>durch kurze <strong>geschickte Abfragen </strong>den <strong>Ablauf </strong>des Programmes <strong>bestimmen </strong>und <strong>leiten</strong>.</p>



<p><strong>Vielleicht </strong>sind Dir auch schon derartige <strong>Konstroll</strong>&#8211; , bzw. <strong>Verzweigungs-Strukturen</strong> wie das &#8222;If-Then-Else&#8220;- &amp; das &#8222;Select-Case&#8220; <strong>bekannt</strong>.</p>



<p>Das <strong>gut bekannte </strong>&#8222;<strong>If-Then-Else</strong>&#8222;-Konstrukt wird <strong>eher für </strong>die <strong>Abarbeitung</strong>, bzw. Steuerung von <strong>verschiedenen Ausgangspunkten </strong>verwendet.</p>



<p>Ich kann <strong>prüfen</strong>, <strong>ob </strong>die <strong>Performance </strong>einer Aktie <strong>gut </strong>war, <strong>jedoch</strong> dennoch die <strong>Dividende gekürzt </strong>wurde.</p>



<p><strong>Bei </strong>dem &#8222;<strong>Select-Case</strong>&#8222;-Konstrukt hingegen, <strong>prüft </strong>man für <strong>gewöhnlich einen Ausgangspunkt</strong> – z. B. auch <strong>Bereiche </strong>dessen – und handelt je nach Ergebnis.</p>



<p>Bleiben wir bei unserem <strong>kleinen Aktien-Beispiel</strong> und verfahren je nach <strong>Dividendenrendite </strong>anders:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Dim dividendYieldPercentage As Integer = 9
Dim message As String = ""
Select Case
    Case 1 To 2
        message = "Dividend yield is okay!"
    Case 3 To 4
        message = "Woah! Nice yield!"
    Case 5 To 6
        message = "Hmm, nice but maybe too much!?"
    Case Else
        message = "Woah, this is too much to be good!"
End Case</pre>



<h2 class="wp-block-heading">In der Kürze..</h2>



<p><strong>Häufig </strong>sagt man, dass <strong>in </strong>der <strong>Kürze </strong>die bekannte <strong>Würze </strong>liegt, man möchte es also ab und zu gerne <strong>kurz und schmerzlos </strong>haben.</p>



<p><strong>Wenn man </strong>jedoch die <strong>Länge </strong>des jeweiligen <strong>Konstruktes </strong>in <strong>Augenschein </strong>nimmt, hat man ein anderes Gefühl, eher <strong>lang und wiederholend</strong>.</p>



<p><strong>Im Falle </strong>einer <strong>relativ simplen </strong>&#8222;If-<strong>Anweisung</strong>&#8220; <strong>kann </strong>man den <strong>Ausdruck </strong>natürlich auch optional <strong>auf </strong>eine <strong>Zeile reduzieren</strong>.</p>



<p><strong>Je komplexer </strong>die eben erwähnte &#8222;If-Anweisung&#8220; allerdings wird, <strong>desto unlesbarer und unmöglich </strong>wird die Anweisung.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Dim performance As Integer = 100
If performance &lt;= 20 Then MsgBox("Yay")</pre>



<p><strong>Nehmen </strong>wir <strong>allerdings </strong>das Beispiel von oben, wäre es <strong>unlesbar </strong>und teilweise auch <strong>nicht möglich</strong>, daher würde ich nur in <strong>seltenen Fällen </strong>zur <strong>Verkürzung </strong>raten.</p>



<h2 class="wp-block-heading">IFS VBA Erklärung</h2>



<p>Mit der <strong>IFS-Funktion</strong> haben wir eine <strong>weitere Kontrollstruktur</strong>, um den <strong>Ablauf </strong>des &#8222;Programmes&#8220; zu <strong>gestalten</strong>.</p>



<p>Die <strong>IFS VBA (Excel) Formel</strong> wird dabei zunächst <strong>analog </strong>zum <strong>&#8222;Einzeiligen</strong> If&#8220; formuliert, <strong>mit </strong>einem <strong>kleinen Unterschied</strong>.</p>



<p><strong>Statt </strong>weniger <strong>Ausdrücke </strong>wie im If-Beispiel, können wir nun <strong>mehrere Ausdrücke</strong> wie durch Zauberhand <strong>kombinieren</strong>.</p>



<h2 class="wp-block-heading">IFS VBA Syntax – Schreibweise</h2>



<p><strong>Schauen wir</strong> uns zum obigen Vergleich einmal die <strong>Struktur, bzw. die Syntax der IFS-Funktion</strong> an:</p>



<pre class="wp-block-code"><code>=IFS(&lt;condition 1>, &lt;value 1>, &lt;condition 2>, ....)</code></pre>



<p>Dabei stellen wir fest, dass wir <strong>innerhalb </strong>der <strong>Klammern </strong>– also durch Angabe von <strong>Parametern </strong>– verschiedene <strong>Paare an Konditionen </strong>&amp; <strong>Werten </strong>angeben können.</p>



<p>Laut offizieller Dokumentation der <strong><a href="https://support.microsoft.com/en-us/office/ifs-function-36329a26-37b2-467c-972b-4a39bd951d45" target="_blank" rel="noreferrer noopener">IFS VBA Funktion</a></strong> von Microsoft, können wir <strong>bis zu 127 verschiedene Bedingungen</strong> prüfen und auswerten.</p>



<p><strong>Natürlich </strong>sollte man das <strong>nach Möglichkeit vermeiden</strong>, <strong>wer möchte </strong>schon eine gefühlt 40000 Zeichen <strong>lange Zeile</strong> lesen..</p>



<p><strong>Neben </strong>der <strong>schier endlos </strong>langen <strong>Zeile</strong>, hat man natürlich <strong>noch</strong> ein <strong>Problem mit </strong>den einzelnen <strong>Reihenfolgen</strong>, wo man sich dann <strong>leicht irren </strong>kann.</p>



<h2 class="wp-block-heading">Beispiel – Excel Zelle anhand IFS Formel</h2>



<p>Um nun <strong>beispielsweise </strong>den <strong>Wert </strong>einer <strong>Zelle </strong>im <strong>Excel-Sheet</strong> zu setzen, könnte man <strong>analog zu oben</strong> folgendes <strong>Beispiel </strong>verwenden.</p>



<p>Wir <strong>ziehen uns </strong>die <strong>Dividendenrendite </strong>dafür nun <strong>aus </strong>einer <strong>Zelle </strong>namens &#8222;A2&#8220; und setzen den <strong>Wert der Zelle </strong>&#8222;A3&#8220; dann auf <strong>das Ergebnis</strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">=IFS(A2&lt;3, "Yield OK!", A2&lt;5, "Nice yield!", A2&lt;7, "Too much!")</pre>



<p><strong>Wenn </strong>im Beispiel der <strong>Wert </strong>in der Zelle &#8222;A2&#8220; z. B. <strong>unter 3</strong> liegt, dann <strong>gibt </strong>die Formel den Wert <strong>&#8222;Yield OK!&#8220; zurück</strong>.</p>



<p><strong>Bei </strong>einem Wert <strong>unter 5</strong> dann &#8222;<strong>Nice yield!</strong>&#8220; und und und..</p>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2021/08/VBA-IFS-Excel.png"><img loading="lazy" decoding="async" width="356" height="155" src="https://robbelroot.de/wp-content/uploads/2021/08/VBA-IFS-Excel.png" alt="VBA IFS Excel" class="wp-image-5159" title="VBA IFS Excel" srcset="https://robbelroot.de/wp-content/uploads/2021/08/VBA-IFS-Excel.png 356w, https://robbelroot.de/wp-content/uploads/2021/08/VBA-IFS-Excel-300x131.png 300w, https://robbelroot.de/wp-content/uploads/2021/08/VBA-IFS-Excel-332x145.png 332w" sizes="auto, (max-width: 356px) 100vw, 356px" /></a><figcaption>VBA IFS Excel</figcaption></figure>



<h2 class="wp-block-heading">Funktioniert übrigens auch bei Google Sheets</h2>



<p>Die <strong>IFS</strong>-Formel gibt es übrigens <strong>auch für</strong> die bekannte <strong>Cloud-Tabellen-Plattform Google Sheets</strong>.</p>



<p>Der <strong>einzige simple Unterschied </strong>ist, dass man dort <strong>statt Kommas</strong> (,) dann <strong>Semikolons</strong> (;) verwenden muss.</p>



<h2 class="wp-block-heading">Aber ich wollte IFS für VBA :(!?</h2>



<p><strong>Kein Problem</strong>! Leider wird man wie oben gesehen bei den Begriffen &#8222;<strong>IFS VBA</strong>&#8220; größtenteils nur im <strong>Bereich </strong>der <strong>Tabellen </strong>– also <strong><a href="https://de.wikipedia.org/wiki/Microsoft_Excel" target="_blank" rel="noreferrer noopener">Microsoft Excel</a></strong> &amp; <strong><a href="https://de.wikipedia.org/wiki/Google_Docs,_Sheets,_Slides_und_Forms#Tabellenkalkulation_(Sheets)" target="_blank" rel="noreferrer noopener">Google Sheets</a></strong> – fündig.</p>



<p><strong>Es gibt </strong>allerdings <strong>auch Codes </strong>wie Dieser hier (vom Stackoverflow-Nutzer &#8222;jsheeran&#8220;), <strong>Welcher </strong>eine <strong>ähnliche Implementierung </strong>im Bereich VBA darstellt:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Public Function UdfIfs(ParamArray args() As Variant) As Variant
  Dim i As Integer
  i = 0 ' or 1 if you're not using zero-based indexing
  Do Until CBool(args(i)) Or (i >= UBound(args))
    i = i + 2
  Loop
  If i &lt; UBound(args) Then
    UdfIfs = args(i + 1)
  End If
End Function</pre>
<p>Der Beitrag <a href="https://robbelroot.de/blog/ifs-vba/">IFS VBA</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/ifs-vba/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
