<?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 : Tal i stedet for tekst</title>
  <link>https://forum.excel-regneark.dk/</link>
  <description><![CDATA[Dette er et XML Feed af; Dansk Regneark Forum : Makro og VBA : Tal i stedet for tekst]]></description>
  <pubDate>Sat, 05 Dec 2026 11:07:46 +0000</pubDate>
  <lastBuildDate>Sat, 15 Jul 2023 10:26:58 +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=4955</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[Tal i stedet for tekst : Hvor i denne VBA skal jeg f&#229; tal...]]></title>
   <link>https://forum.excel-regneark.dk/tal-i-stedet-for-tekst_topic4955_post24517.html#24517</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=1492">Soeren50</a><br /><strong>Emne:</strong> 4955<br /><strong>Sendt:</strong> 15.Jul.2023 kl. 10:26<br /><br />Hvor i denne VBA skal jeg få tal i de kolonner der skal inde holde både positive og negative tal?<div><br><div><div>Private Function findKontonavn(kontonr As Long) As String</div><div>&nbsp; &nbsp; Dim rng As Range</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'finder ud af hvor kontonr. står</div><div>&nbsp; &nbsp; Set rng = Ark2.Range("A:A").Find(What:=kontonr, lookat:=xlWhole)</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Tjekker om der rent faktisk blev fundet noget</div><div>&nbsp; &nbsp; If Not rng Is Nothing Then</div><div>&nbsp; &nbsp; &nbsp; &nbsp; 'Retunerer værdien fra cellen ved siden af (altså beskrivelsen)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; findKontonavn = rng.Offset(0, 1).Value</div><div>&nbsp; &nbsp; Else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; 'Hvis der ikke bliver fundet noget</div><div>&nbsp; &nbsp; &nbsp; &nbsp; MsgBox "Der blev ikke fundet nogen konto, med kontonr " &amp; kontonr, vbOKOnly + vbCritical, "Ingen konto fundet"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; findKontonavn = vbNullString</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Exit Function</div><div>&nbsp; &nbsp; End If</div><div>End Function</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>'Subroutinen hedder altid UserForm_Initialize uanset hvad du har navnet userformen :-)</div><div>Private Sub UserForm_Initialize()</div><div>&nbsp; &nbsp; Dim kontonr As Variant</div><div><br></div><div>&nbsp; &nbsp; 'Tilføjer Kontonummerne til Comboxen. Tilføjer alle de kontonr. som står i arket kontoPlan</div><div>&nbsp; &nbsp; For Each kontonr In Ark2.Range("d2", Ark2.Range("d2").End(xlDown))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; cmbKonto.AddItem kontonr</div><div>&nbsp; &nbsp; Next kontonr</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Sætter Standardteksterne</div><div>&nbsp; &nbsp; tbDato.Value = ""</div><div>&nbsp; &nbsp; tbTekst.Value = ""</div><div>&nbsp; &nbsp; tbUdgift.Value = ""</div><div>&nbsp; &nbsp; tbIndtaegt.Value = ""</div><div>&nbsp; &nbsp; tbloenindtaegt.Value = ""</div><div>&nbsp; &nbsp; tboverfoersel_mellem_konti.Value = ""</div><div>&nbsp; &nbsp; tbandenindtaegt.Value = ""</div><div>&nbsp; &nbsp; tbkost.Value = ""</div><div>&nbsp; &nbsp; tbapple.Value = ""</div><div>&nbsp; &nbsp; tbbyggemarkeder.Value = ""</div><div>&nbsp; &nbsp; tbtelefoni_og_rep.Value = ""</div><div>&nbsp; &nbsp; tbprofiloptik.Value = ""</div><div>&nbsp; &nbsp; tbtandlaege.Value = ""</div><div>&nbsp; &nbsp; tbplantecenter.Value = ""</div><div>&nbsp; &nbsp; tbmiljoefoder.Value = ""</div><div>&nbsp; &nbsp; tbkontant_haevninger.Value = ""</div><div>&nbsp; &nbsp; tbtv_og_aviser.Value = ""</div><div>&nbsp; &nbsp; tbauto_og_cykler.Value = ""</div><div>&nbsp; &nbsp; tbrenter_og_gebyr.Value = ""</div><div>&nbsp; &nbsp; tbmobilepay.Value = ""</div><div>&nbsp; &nbsp; tbtil_andre.Value = ""</div><div>&nbsp; &nbsp; tbbudget.Value = ""</div><div>&nbsp; &nbsp; tbtoej.Value = ""</div><div>&nbsp; &nbsp; tbmedicin.Value = ""</div><div>End Sub</div><div><br></div><div>Private Sub btnAfslut_Click()</div><div>'Afslutter UserFormen</div><div>Unload Me</div><div>End Sub</div><div><br></div><div>Private Sub cmbTilføj_Click()</div><div>&nbsp; &nbsp; Dim NuvarrendeMaksId As Integer</div><div>&nbsp; &nbsp; Dim NytId As Integer</div><div>&nbsp; &nbsp; Dim NyCelle As Range</div><div><br></div><div>&nbsp; &nbsp; 'Aktiverer Hovedarket. "shHovedArk" er arkets kodenavn, som jeg har givet det. Det gør, at du kan ændre teksten/navnet på arket som brugeren ser uden at det påvirker koden. Smart :-)</div><div>&nbsp; &nbsp; ' shHovedArk.Activate</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Lidt tjek af data inden vi fortsætter</div><div>&nbsp; &nbsp; If Not cmbKonto.ListIndex &gt; -1 Then</div><div>&nbsp; &nbsp; &nbsp; &nbsp; MsgBox "Du skal vælge en konto", vbOKOnly + vbCritical, "Fejl"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Exit Sub</div><div>&nbsp; &nbsp; End If</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; If Not IsDate(tbDato.Value) Then</div><div>&nbsp; &nbsp; &nbsp; &nbsp; MsgBox "Du skal skrive en gyldig dato. Format: dd-mm-åååå", vbOKOnly + vbCritical, "Fejl"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Exit Sub</div><div>&nbsp; &nbsp; End If</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; If Not IsNumeric(tbIndtaegt.Value) Or Not IsNumeric(tbUdgift.Value) Then</div><div>&nbsp; &nbsp; &nbsp; &nbsp; MsgBox "Indtægter og udgifter skal være tal", vbOKOnly + vbCritical, "Fejl"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Exit Sub</div><div>&nbsp; &nbsp; &nbsp;End If</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Finder ud af hvad den nuværrende maksimale værdi af ID er.</div><div>&nbsp; &nbsp; NuvarrendeMaksId = WorksheetFunction.Max(Range("A:A"))</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Sætter det nye ID</div><div>&nbsp; &nbsp; NytId = NuvarrendeMaksId + 1</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Finder ud af hvad den næste frie celle er, hvor der skal stå ID.</div><div>&nbsp; &nbsp; Set NyCelle = Range("A9999").End(xlUp).Offset(1, 0)</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Skriver værdierne. Offset-Funktionen skal læses som. Tag cellen NyCelle, og gå 0-rækker til højre og hhv. 0,1,2,3,4,5 kolonner til højre.</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 0).Value = NytId</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 1).Value = tbfaktura.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 2).Value = cmbKonto.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 3).Value = tbDato.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 4).Value = tbTekst.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 5).Value = tbUdgift.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 6).Value = tbIndtaegt.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 8).Value = Textleverinsdato.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 9).Value = Textbestillingsbeløb.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 11).Value = tbloenindtaegt.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 12).Value = tboverfoersel_mellem_konti.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 13).Value = tbandenindtaegt.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 14).Value = tbkost.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 15).Value = tbapple.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 16).Value = tbbyggemarkeder.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 17).Value = tbtelefoni_og_rep.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 18).Value = tbprofiloptik.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 19).Value = tbtandlaege.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 20).Value = tbplantecenter.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 21).Value = tbmiljoefoder.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 22).Value = tbkontant_haevninger.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 23).Value = tbtv_og_aviser.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 24).Value = tbauto_og_cykler</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 25).Value = tbrenter_og_gebyr.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 26).Value = tbmobilepay.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 27).Value = tbtil_andre.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 28).Value = tbbudget.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 29).Value = tbtoej.Value</div><div>&nbsp; &nbsp; NyCelle.Offset(0, 30).Value = tbmedicin.Value</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Til respons</div><div>&nbsp; &nbsp; MsgBox "Tilføjet ny bon", vbOKOnly + vbInformation, "Tilføjet"</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Gøres når alt overstående er gennemkørt</div><div>&nbsp; &nbsp; NulstilAlleFelter</div><div>End Sub</div><div><br></div><div>Private Sub NulstilAlleFelter()</div><div>&nbsp; &nbsp; cmbKonto.ListIndex = -1 ' Nulstiller comboboxen. Hvis sættes til 0, da vælges det første item i listen, 1 vælges det 2. item osv.</div><div><br></div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Nulstiller alle felter</div><div>&nbsp; &nbsp; tbfaktura.Value = ""</div><div>&nbsp; &nbsp; tbDato.Value = ""</div><div>&nbsp; &nbsp; tbTekst.Value = ""</div><div>&nbsp; &nbsp; tbUdgift.Value = ""</div><div>&nbsp; &nbsp; tbIndtaegt.Value = ""</div><div>&nbsp; &nbsp; ' Textleveringsdato.Value = ""</div><div>&nbsp; &nbsp; ' Textbestillingsbeløb.Value = ""</div><div>&nbsp; &nbsp; tbloenindtaegt.Value = ""</div><div>&nbsp; &nbsp; tboverfoersel_mellem_konti.Value = ""</div><div>&nbsp; &nbsp; tbandenindtaegt.Value = ""</div><div>&nbsp; &nbsp; tbkost.Value = ""</div><div>&nbsp; &nbsp; tbapple.Value = ""</div><div>&nbsp; &nbsp; tbbyggemarkeder.Value = ""</div><div>&nbsp; &nbsp; tbtelefoni_og_rep.Value = ""</div><div>&nbsp; &nbsp; tbprofiloptik.Value = ""</div><div>&nbsp; &nbsp; tbtandlaege.Value = ""</div><div>&nbsp; &nbsp; tbplantecenter.Value = ""</div><div>&nbsp; &nbsp; tbmiljoefoder.Value = ""</div><div>&nbsp; &nbsp; tbkontant_haevninger.Value = ""</div><div>&nbsp; &nbsp; tbtv_og_aviser.Value = ""</div><div>&nbsp; &nbsp; tbauto_og_cykler.Value = ""</div><div>&nbsp; &nbsp; tbrenter_og_gebyr.Value = ""</div><div>&nbsp; &nbsp; tbmobilepay.Value = ""</div><div>&nbsp; &nbsp; tbtil_andre.Value = ""</div><div>&nbsp; &nbsp; tbbudget.Value = ""</div><div>&nbsp; &nbsp; tbtoej.Value = ""</div><div>&nbsp; &nbsp; tbmedicin.Value = ""</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; End Sub</div><div>&nbsp; &nbsp;&nbsp;</div></div><div><br></div></div>]]>
   </description>
   <pubDate>Sat, 15 Jul 2023 10:26:58 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/tal-i-stedet-for-tekst_topic4955_post24517.html#24517</guid>
  </item> 
 </channel>
</rss>