<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Dansk Regneark Forum : En lille &quot;ting&quot; i en klokkeslætskode</title>
  <link>https://forum.excel-regneark.dk/</link>
  <description><![CDATA[Dette er et XML Feed af; Dansk Regneark Forum : Makro og VBA : En lille &quot;ting&quot; i en klokkeslætskode]]></description>
  <pubDate>Sat, 05 Dec 2026 13:35:01 +0000</pubDate>
  <lastBuildDate>Tue, 16 Jan 2018 11:27:03 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.08</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>https://forum.excel-regneark.dk/RSS_post_feed.asp?TID=3326</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Dansk Regneark Forum]]></title>
   <url>https://forum.excel-regneark.dk/css_styles/Excel-regneark.dk/logo.png</url>
   <link>https://forum.excel-regneark.dk/</link>
  </image>
  <item>
   <title><![CDATA[En lille &quot;ting&quot; i en klokkeslætskode : Hvorfor fik jeg ikke besked om...]]></title>
   <link>https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16441.html#16441</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=1125">Ib Hansen</a><br /><strong>Emne:</strong> 3326<br /><strong>Sendt:</strong> 16.Jan.2018 kl. 11:27<br /><br />Hvorfor fik jeg ikke besked om Excelents forslag i min mailboks - Hmmm&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley7.gif" border="0" alt="Angry" title="Angry" /><br><br>Koden virker&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley20.gif" border="0" alt="Thumbs Up" title="Thumbs Up" /><div><br></div><div>Og med denne kode,&nbsp;<span style=": rgb251, 251, 253;">bliver den stående og sletter samtidigt det indtastede.</span></div><div><span style=": rgb251, 251, 253;"><i><font color="#0000ff">Range(Target.Address).Select: Selection = ""</font></i></span></div><div><span style=": rgb251, 251, 253;"><br></span></div><div><span style=": rgb251, 251, 253;">Tusind tak for hjælpen&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley41.gif" border="0" alt="Beer" title="Beer" /></span></div><div><span style=": rgb251, 251, 253;"><br></span></div><div><span style=": rgb251, 251, 253;">Ib</span></div>]]>
   </description>
   <pubDate>Tue, 16 Jan 2018 11:27:03 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16441.html#16441</guid>
  </item> 
  <item>
   <title><![CDATA[En lille &quot;ting&quot; i en klokkeslætskode : retur til samme celle :Range(Target.Address).Select...]]></title>
   <link>https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16404.html#16404</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=248">excelent</a><br /><strong>Emne:</strong> 3326<br /><strong>Sendt:</strong> 14.Jan.2018 kl. 16:25<br /><br />retur til samme celle :<br />Range(Target.Address).Select]]>
   </description>
   <pubDate>Sun, 14 Jan 2018 16:25:59 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16404.html#16404</guid>
  </item> 
  <item>
   <title><![CDATA[En lille &quot;ting&quot; i en klokkeslætskode : Target:Value = &amp;#034;&amp;#034; -...]]></title>
   <link>https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16402.html#16402</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=1125">Ib Hansen</a><br /><strong>Emne:</strong> 3326<br /><strong>Sendt:</strong> 14.Jan.2018 kl. 15:45<br /><br />Target:Value = "" - Hopper en celle ned og sletter den i stedet, når man bruger "Enter".]]>
   </description>
   <pubDate>Sun, 14 Jan 2018 15:45:19 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16402.html#16402</guid>
  </item> 
  <item>
   <title><![CDATA[En lille &quot;ting&quot; i en klokkeslætskode : Jeg pr&#248;verMen du kan altid kopiere...]]></title>
   <link>https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16401.html#16401</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=1125">Ib Hansen</a><br /><strong>Emne:</strong> 3326<br /><strong>Sendt:</strong> 14.Jan.2018 kl. 15:42<br /><br />Jeg prøver&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley2.gif" border="0" alt="Wink" title="Wink" /><br><br>Men du kan altid kopiere koden fra forum Ctrl+C og indsætte den i et ark Ctrl+V.<div>Det sparer en masse skrive arbejde.</div><div><br></div><div>Har du OnKey koden for Ctrl+Z ?<br><br></div>]]>
   </description>
   <pubDate>Sun, 14 Jan 2018 15:42:35 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16401.html#16401</guid>
  </item> 
  <item>
   <title><![CDATA[En lille &quot;ting&quot; i en klokkeslætskode : Jeg har ikke lige tid til, at...]]></title>
   <link>https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16400.html#16400</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=732">EXCELGAARD</a><br /><strong>Emne:</strong> 3326<br /><strong>Sendt:</strong> 14.Jan.2018 kl. 15:37<br /><br />Jeg har ikke lige tid til, at indtaste hele din makro, men kan du ikke bare udskifte din røde linje med:<br><br>Target.Value = ""<br><br>???<br>]]>
   </description>
   <pubDate>Sun, 14 Jan 2018 15:37:25 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16400.html#16400</guid>
  </item> 
  <item>
   <title><![CDATA[En lille &quot;ting&quot; i en klokkeslætskode : P&#229; et tidspunkt fik jeg lavet...]]></title>
   <link>https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16399.html#16399</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=1125">Ib Hansen</a><br /><strong>Emne:</strong> 3326<br /><strong>Sendt:</strong> 14.Jan.2018 kl. 14:47<br /><br /><div>På et tidspunkt fik jeg lavet en meget værdifuld koder, der konverterer et tal til et klokkeslæt, når tallet tastes i en celle.</div><div>Men hvis man taster en separator i tallet, kommer der en advarsel, at separator ikke må bruges.</div><div>Koden sørger selv for at sætte separatoren i klokkeslættet.</div><div><br></div><div>Jeg har brugt koden uanede gange i forskellige ark og den er fantastisk&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley4.gif" border="0" alt="Big smile" title="Big smile" /></div><div><table width="99%"><tr><td><pre class="BBcode">Private Sub Worksheet_Change(ByVal Target As Excel.Range)</div><div><font color="#009900">'-----------------------------------------'</font></div><div><font color="#009900">' Ændre almindeligt tal til et klokkeslæt '</font></div><div><font color="#009900">'-----------------------------------------'</font></div><div>&nbsp; &nbsp; &nbsp;Dim TimeStr As String</div><div>&nbsp; &nbsp; &nbsp;<font color="#ff0000"><b>On Error GoTo EndMacro</b></font></div><div><font color="#009900">'----------------------------------------------------------------------------'</font></div><div><font color="#009900">' Vælg område - Flere områder kan vælges - Brug Range("A1:B10, D1:E10") osv. '</font></div><div><font color="#009900">'----------------------------------------------------------------------------'</font></div><div>&nbsp; &nbsp; If Intersect(Target, Sheets("Forside").Range("J2:N200, R2:S200")) Is Nothing Then Exit Sub</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; If Target.Cells.Count &gt; 1 Then Exit Sub</div><div>&nbsp; &nbsp; If Target.Value = "" Then Exit Sub</div><div><br></div><div>&nbsp; &nbsp; Application.EnableEvents = False</div><div>&nbsp; &nbsp; With Target</div><div>&nbsp; &nbsp; If .HasFormula = False Then</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Select Case Len(.Value)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Case 1 ' e.g., 1 = 00:01 AM</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeStr = "00:0" &amp; .Value</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Case 2 ' e.g., 12 = 00:12 AM</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeStr = "00:" &amp; .Value</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Case 3 ' e.g., 735 = 7:35 AM</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeStr = Left(.Value, 1) &amp; ":" &amp; Right(.Value, 2)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Case 4 ' e.g., 1234 = 12:34</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeStr = Left(.Value, 2) &amp; ":" &amp; Right(.Value, 2)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Case 5 ' e.g., 12345 = 1:23:45 NOT 12:03:45</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeStr = Left(.Value, 1) &amp; ":" &amp; Mid(.Value, 2, 2) &amp; ":" &amp; Right(.Value, 2)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Case 6 ' e.g., 123456 = 12:34:56</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeStr = Left(.Value, 2) &amp; ":" &amp; Mid(.Value, 3, 2) &amp; ":" &amp; Right(.Value, 2)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Case Else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Err.Raise 0</div><div>&nbsp; &nbsp; &nbsp; &nbsp; End Select</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .Value = TimeValue(TimeStr)</div><div>&nbsp; &nbsp; End If</div><div>&nbsp; &nbsp; End With</div><div>&nbsp; &nbsp; Application.EnableEvents = True</div><div>&nbsp; &nbsp; Exit Sub</div><div><font color="#009900">'------------'</font></div><div><font color="#009900">' Hvis Error '</font></div><div><font color="#009900">'------------'</font></div><div><font color="#ff0000"><b>EndMacro:</b></font></div><div><font color="#ff0000"><b>&nbsp; &nbsp; ActiveCell.Offset(-1, 0).Select: Selection = ""</b></font></div><div><font color="#009900">'-------------------------'</font></div><div><font color="#009900">' Msgbox - Dialog Message '</font></div><div><font color="#009900">'-------------------------'</font></div><div>&nbsp; &nbsp; QuestionToMessageBox = "&nbsp; &nbsp;Ugyldig indtastning !" _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &amp; vbNewLine &amp; vbNewLine &amp; "&nbsp; &nbsp;Der er enten brugt separator." _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &amp; vbNewLine &amp; "&nbsp; &nbsp;Eller det er et ugyldigt klokkeslæt." _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &amp; vbNewLine &amp; vbNewLine &amp; "&nbsp; &nbsp;Skriv et korrekt klokkeslæt, som et helt tal, uden separator." _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &amp; vbNewLine &amp; "&nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; =&nbsp; &nbsp;00:01" _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &amp; vbNewLine &amp; "&nbsp; &nbsp;12&nbsp; &nbsp; &nbsp; =&nbsp; &nbsp;00:12" _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &amp; vbNewLine &amp; "&nbsp; &nbsp;123&nbsp; &nbsp; =&nbsp; &nbsp;01:23" _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &amp; vbNewLine &amp; "&nbsp; &nbsp;1234&nbsp; =&nbsp; &nbsp;12:34"</div><div><font color="#009900">'-----------------'</font></div><div><font color="#009900">' MsgBox settings '</font></div><div><font color="#009900">'-----------------'</font></div><div>&nbsp; &nbsp; YesOrNoAnswerToMessageBox = MsgBox(QuestionToMessageBox _</div><div>&nbsp; &nbsp; , vbOKOnly + vbInformation, "Ugyldig indtastning")</div><div><font color="#009900">'--------------------------------'</font></div><div><font color="#009900">' Lås ark op - Konverter til tid '</font></div><div><font color="#009900">'--------------------------------'</font></div><div>&nbsp; &nbsp; ActiveSheet.Unprotect Password:=Sheets("Indstil").Range("B1").Value</div><div>&nbsp; &nbsp; ActiveCell.NumberFormat = "hh:mm"</div><div><font color="#009900">'---------'</font></div><div><font color="#009900">' Lås ark '</font></div><div><font color="#009900">'---------'</font></div><div>&nbsp; &nbsp; ActiveSheet.Protect Password:=Sheets("Indstil").Range("B1").Value</div><div>&nbsp; &nbsp; Application.EnableEvents = True</pre></td></tr></table></div><div><br></div><div><u style="font-weight: bold;">Den har dog en lille "ting", jeg har prøvet at rette, men ikke rigtigt formår&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley30.gif" border="0" alt="Pig" title="Pig" /></u>&nbsp;Øf Øf Øf</div><div>- I starten af koden, går den til "EndMacro" On Error, hvis der f.eks. tastes en separator.</div><div>- Og "EndMacro" får den til at hoppe "Offset" en celle op og slette den.</div><div>- <i>Det er markeret med rødt i koden</i>.</div><div><br></div><div>Det er fint, hvis man bruger "Enter" når tallet med separator er tastet.<br>"Enter" hopper en celle ned og "EndMacro" hopper tilbage og sletter fejlen.</div><div><br></div><div>Men hvad hvis man f.eks. bruger piltasten til højre, for at hoppe til næste celle i rækken ?</div><div>Så virker "EndMacro" ikke og man risikerer at den hopper og sletter et forkert klokkeslæt.</div><div><br></div><div>Jeg har prøvet en masse, f.eks. en "Where Am I".</div><div>Den virker bare ikke og den vil også "huske" den forkerte celle, når "Enter" eller en piltast er brugt.<br><br><b>Koden skal nok indsættes før "On Error GoTo", men hvordan ?</b></div><div><table width="99%"><tr><td><pre class="BBcode">EndMacro:</div><div>&nbsp; &nbsp; <font color="#00cc00">'ActiveCell.Offset(-1, 0).Select: Selection = ""</font></div><div><font color="#00cc00">'------------'</font></div><div><font color="#00cc00">' Where Am I '</font></div><div><font color="#00cc00">'------------'</font></div><div>&nbsp; &nbsp; Dim WAI As String</div><div>&nbsp; &nbsp; WAI = ActiveCell.Name = ""</pre></td></tr></table></div><div><br></div><div><b><u>En anden "ting", men måske ikke så vigtigt.</u></b></div><div>Jeg bruger ofte Ctrl+Z <i>(fortryd)</i>, hvis jeg f.eks. har slettet et klokkeslæt, der skulle beholdes.</div><div>Men klokkeslæt, der fortrydes, indeholder jo en separator, der ulovligt i koden.</div><div>Når klokkeslættet er indsat med genvejen, hopper den en celle op og sletter den.</div><div><br></div><div><b>Er det muligt at Deaktivere hele klokkeslætskoden, hvis Ctrl+Z bruges ?</b></div><div><br></div><div>F.eks i starten af koden.</div><div><table width="99%"><tr><td><pre class="BBcode">If Application.OnKey "<font color="#ff0000">koden for Ctrl+Z her</font>" Then Exit Sub</pre></td></tr></table></div><div><br></div><div>Pyh ha en lang tekst, men jeg lider af "et eller andet", der gør, jeg godt vil forklare mig så godt som muligt.</div><div>Og det er endnu engang bekræftet her&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley23.gif" border="0" alt="Geek" title="Geek" /></div><div><br>Mange vil nok falde i søvn, før de når hertil&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley13.gif" border="0" alt="Disapprove" title="Disapprove" /><br>Men jeg håber at kunne få hjælp af de ihærdige, der ikke lider af læsekrampe&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley17.gif" border="0" alt="T&#111;ngue" title="T&#111;ngue" /></div><div><br></div><div>På forhånd tak&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley2.gif" border="0" alt="Wink" title="Wink" /></div><div><br></div><div>Ib</div><div><br></div>]]>
   </description>
   <pubDate>Sun, 14 Jan 2018 14:47:20 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/en-lille-ting-i-en-klokkesltskode_topic3326_post16399.html#16399</guid>
  </item> 
 </channel>
</rss>