<?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>result Archive - Robert Skibbe</title>
	<atom:link href="https://robbelroot.de/blog/tag/result/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>alias RobbelRoot – Freelance Full Stack Developer .NET</description>
	<lastBuildDate>Sun, 08 Aug 2021 23:01:05 +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>result Archive - Robert Skibbe</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<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 fetchpriority="high" 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="(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 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="(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>
