<?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>Tiposaurus &#187; VBA / Excel</title>
	<atom:link href="http://tiposaurus.co.uk/category/vba-excel/feed/" rel="self" type="application/rss+xml" />
	<link>http://tiposaurus.co.uk</link>
	<description>Rawrr.</description>
	<lastBuildDate>Sun, 05 Feb 2012 23:32:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How To: Get the Weekday as Text in Excel VBA</title>
		<link>http://tiposaurus.co.uk/2009/06/how-to-get-the-weekday-as-text-in-excel-vba/</link>
		<comments>http://tiposaurus.co.uk/2009/06/how-to-get-the-weekday-as-text-in-excel-vba/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 20:38:53 +0000</pubDate>
		<dc:creator>Tiposaurus</dc:creator>
				<category><![CDATA[VBA / Excel]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[weekday]]></category>

		<guid isPermaLink="false">http://tiposaurus.co.uk/2009/06/how-to-get-the-weekday-as-text-in-excel-vba/</guid>
		<description><![CDATA[I often want to know what day of the week a date is. Excel has a function for this, but unfortunately it only returns an integer, for example the function: =WEEKDAY("01/02/2009") returns 1 (which represents Sunday). This can be a bit confusing with a list of dates, so I wrote the following quick VBA function [...]]]></description>
			<content:encoded><![CDATA[<p>I often want to know what day of the week a date is. Excel has a function for this, but unfortunately it only returns an integer, for example the function:<br />
<code>=WEEKDAY("01/02/2009")</code><br />
returns 1 (which represents Sunday).</p>
<p>This can be a bit confusing with a list of dates, so I wrote the following quick VBA function to get the day of the week as text, e.g. Sunday, Monday, etc.</p>
<p>The function (possibly not the most elegant method possible) is:</p>
<pre><code>' function to return a text representation of the weekday of a given date
' returns the full text, which can be shortened by left(), etc
Function dayText(d As Date) As String
If Weekday(d) = 1 Then dayText = "Sunday"
If Weekday(d) = 2 Then dayText = "Monday"
If Weekday(d) = 3 Then dayText = "Tuesday"
If Weekday(d) = 4 Then dayText = "Wednesday"
If Weekday(d) = 5 Then dayText = "Thursday"
If Weekday(d) = 6 Then dayText = "Friday"
If Weekday(d) = 7 Then dayText = "Saturday"
End Function</code></pre>
<p>(Enter this via the VBA Editor - press Alt+F11, then insert -&gt; module and paste this code in).</p>
<p>It can then be called by:<br />
<code>=DAYTEXT("01/02/2009")</code><br />
which returns Sunday.</p>
<p>This can then be shortened to one or three letters via the left() function, for example:<br />
<code>=LEFT(DAYTEXT("01/02/2009"),3)</code><br />
returns Sun.</p>
<p>If you want to avoid macros, an alternative method is to use the (slightly messy) formula consisting of nested IFs, for a spreadsheet with a date in cell A1:<br />
<code>=IF(WEEKDAY(A1)=1, "Sunday", IF(WEEKDAY(A1)=2,"Monday",IF(WEEKDAY(A1)=3, "Tuesday", IF(WEEKDAY(A1)=4, "Wednesday", IF(WEEKDAY(A1)=5, "Thursday", IF(WEEKDAY(A1)=6, "Friday", "Saturday"))))))</code></p>
]]></content:encoded>
			<wfw:commentRss>http://tiposaurus.co.uk/2009/06/how-to-get-the-weekday-as-text-in-excel-vba/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

