<?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 : Søge efter data på et andet ark, VBA</title>
  <link>https://forum.excel-regneark.dk/</link>
  <description><![CDATA[Dette er et XML Feed af; Dansk Regneark Forum : Makro og VBA : Søge efter data på et andet ark, VBA]]></description>
  <pubDate>Sat, 05 Dec 2026 15:02:09 +0000</pubDate>
  <lastBuildDate>Fri, 03 Aug 2018 20:14:12 +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=3563</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[Søge efter data på et andet ark, VBA : Hvad jeg kan l&#230;se mig frem til,...]]></title>
   <link>https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17662.html#17662</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=2259">Nervatos</a><br /><strong>Emne:</strong> 3563<br /><strong>Sendt:</strong> 03.Aug.2018 kl. 20:14<br /><br />Hvad jeg kan læse mig frem til, så må den max være 255 i længde. Så har prøvet noget som de skriver rundt omkring.<div>Dog desværre med samme fejl.</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>Const A As String = "Ark1"</div><div>Const B As String = "Hans"</div><div><br></div><div>Sub test2()</div><div>&nbsp; &nbsp; Dim y As Long</div><div>&nbsp; &nbsp; Dim formulaP1 As String</div><div>&nbsp; &nbsp; Dim formulaP2 As String</div><div>&nbsp; &nbsp; Dim formulaP3 As String</div><div>&nbsp; &nbsp; Dim formulaP4 As String</div><div>&nbsp; &nbsp; Dim formulaP5 As String</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; y = Sheets(B).Range("A" &amp; Rows.Count).End(xlUp).Row</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; formulaP1 = "=IFERROR(INDEX('" &amp; A &amp; "'!$E$2:$E$" &amp; y &amp; ",MATCH(RIGHT(CELL(""filename"",$A$1),X_X_X()"</div><div>&nbsp; &nbsp; formulaP2 = "LEN(CELL(""filename"",$A$1))-FIND(""&#093;"",CELL(""filename"",$A$1)))&amp;Y_Y_Y()"</div><div>&nbsp; &nbsp; formulaP3 = B &amp; "!D2&amp;" &amp; B &amp; "!C2,'" &amp; A &amp; "'!$C$2:$C$" &amp; y &amp; "Z_Z_Z()"</div><div>&nbsp; &nbsp; formulaP4 = "&amp;IF(SEARCH(D2,'" &amp; A &amp; "'!$D$2:$D$" &amp; y &amp; ",1)&gt;0," &amp; B &amp; "!D2,)&amp;IF(SEARCH(C2,'" &amp; A &amp; "'!$G$2:$G$" &amp; y &amp; ",1)W_W_W()"</div><div>&nbsp; &nbsp; formulaP5 = "&gt;0," &amp; B &amp; "!C2,))),"""")"</div><div><br></div><div>&nbsp; &nbsp; Sheets(B).Range("A1").Select</div><div>&nbsp; &nbsp; With Sheets(B).Range("J2:J" &amp; y)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .FormulaArray = formulaP1</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Replace What:="X_X_X()", Replacement:=formulaP2, lookat:=xlPart</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Replace What:="Y_Y_Y()", Replacement:=formulaP3, lookat:=xlPart</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Replace What:="Z_Z_Z()", Replacement:=formulaP4, lookat:=xlPart</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Replace What:="W_W_W()", Replacement:=formulaP5, lookat:=xlPart</div><div>&nbsp; &nbsp; &nbsp; &nbsp;<span style="white-space:pre">	</span>&nbsp; &nbsp; .FillDown</div><div>&nbsp; &nbsp; End With</div><div>End Sub</div></div><div></pre></td></tr></table></div>]]>
   </description>
   <pubDate>Fri, 03 Aug 2018 20:14:12 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17662.html#17662</guid>
  </item> 
  <item>
   <title><![CDATA[Søge efter data på et andet ark, VBA : Hej ExcelgaardTusind tak for forslaget....]]></title>
   <link>https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17661.html#17661</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=2259">Nervatos</a><br /><strong>Emne:</strong> 3563<br /><strong>Sendt:</strong> 03.Aug.2018 kl. 18:42<br /><br />Hej Excelgaard<div><br></div><div>Tusind tak for forslaget. Dog får jeg desværre samme fejl, har du andre idéer?</div><div><br></div>]]>
   </description>
   <pubDate>Fri, 03 Aug 2018 18:42:22 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17661.html#17661</guid>
  </item> 
  <item>
   <title><![CDATA[Søge efter data på et andet ark, VBA : &amp;#039;Cells&amp;#039; er ikke et objekt...]]></title>
   <link>https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17659.html#17659</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=732">EXCELGAARD</a><br /><strong>Emne:</strong> 3563<br /><strong>Sendt:</strong> 03.Aug.2018 kl. 13:57<br /><br /><div>'Cells' er ikke et objekt under 'Range' objektet.</div><div><br></div><div>Fjern '.Cells(1,1)', så der kun står '.FormulaArray'.<br></div>]]>
   </description>
   <pubDate>Fri, 03 Aug 2018 13:57:44 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17659.html#17659</guid>
  </item> 
  <item>
   <title><![CDATA[Søge efter data på et andet ark, VBA :  Const A As String = &amp;#034;Ark1&amp;#034;Const...]]></title>
   <link>https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17658.html#17658</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=2259">Nervatos</a><br /><strong>Emne:</strong> 3563<br /><strong>Sendt:</strong> 03.Aug.2018 kl. 13:37<br /><br /><table width="99%"><tr><td><pre class="BBcode"><div><div>Const A As String = "Ark1"</div><div>Const B As String = "Hans"</div><div><br></div><div>Sub test2()</div><div>&nbsp; &nbsp; Dim y As Long</div><div>&nbsp; &nbsp; y = Sheets(B).Range("A" &amp; Rows.Count).End(xlUp).Row</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; Sheets(B).Range("A1").Select</div><div>&nbsp; &nbsp; With Sheets(B).Range("J2:J" &amp; y)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .Cells(1, 1).FormulaArray = _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "=IFERROR(INDEX('" &amp; A &amp; "'!$E$2:$E$" &amp; y &amp; ",MATCH(RIGHT(CELL(""filename"",$A$1),LEN(CELL(""filename"",$A$1))-FIND(""&#093;"",CELL(""filename"",$A$1)))&amp;" &amp; B &amp; "!D2&amp;" &amp; B &amp; "!C2,'" &amp; A &amp; "'!$C$2:$C$" &amp; y &amp; "&amp;IF(SEARCH(D2,'" &amp; A &amp; "'!$D$2:$D$" &amp; y &amp; ",1)&gt;0," &amp; B &amp; "!D2,)&amp;IF(SEARCH(C2,'" &amp; A &amp; "'!$G$2:$G$" &amp; y &amp; ",1)&gt;0," &amp; B &amp; "!C2,))),"""")"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .FillDown</div><div>&nbsp; &nbsp; End With</div><div>End Sub</div><div></pre></td></tr></table></div></div><div><br></div><div>Får følgende fejl:</div><div>Run-time error '1004': Application-defined or object-defined error</div><div><br></div><div>Nogen som kan rette det til?</div>]]>
   </description>
   <pubDate>Fri, 03 Aug 2018 13:37:13 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17658.html#17658</guid>
  </item> 
  <item>
   <title><![CDATA[Søge efter data på et andet ark, VBA : Alternativt, kan man g&#248;re s&#229; den...]]></title>
   <link>https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17651.html#17651</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=2259">Nervatos</a><br /><strong>Emne:</strong> 3563<br /><strong>Sendt:</strong> 01.Aug.2018 kl. 18:02<br /><br />Alternativt, kan man gøre så den selv tilføjer Matrix formlerne?<div><br></div><div><div>=HVIS.FEJL(INDEKS('Ark1'!$E$2:$E$31;SAMMENLIGN(HØJRE(CELLE("filename";$A$1);LÆNGDE(CELLE("filename";$A$1))-FIND("&#093;";CELLE("filename";$A$1)))&amp;Hans!D2&amp;Hans!C2;'Ark1'!$C$2:$C$31&amp;HVIS(SØG(D2;'Ark1'!$D$2:$D$31;1)&gt;0;Hans!D2;)&amp;HVIS(SØG(C2;'Ark1'!$G$2:$G$31;1)&gt;0;Hans!C2;)));"")</div><div><br></div><div>=HVIS.FEJL(INDEKS('Ark1'!$A$2:$A$31;SAMMENLIGN(HØJRE(CELLE("filename";$A$1);LÆNGDE(CELLE("filename";$A$1))-FIND("&#093;";CELLE("filename";$A$1)))&amp;Hans!D2&amp;Hans!C2;'Ark1'!$C$2:$C$31&amp;HVIS(SØG(D2;'Ark1'!$D$2:$D$31;1)&gt;0;Hans!D2;)&amp;HVIS(SØG(C2;'Ark1'!$G$2:$G$31;1)&gt;0;Hans!C2;)));"")</div></div><div><br></div><div>Har disse to Matrix formler fra anedi. Hvis det kan lade sig gøre, at få et VBA script til at køre dette igennem med&nbsp;End(xlUp) og rette alle steder med 31 til med&nbsp;End(xlUp).&nbsp;</div><div><br></div><div><br></div><div>Håber det giver mening, det ville være konge - hvis det kunne lade sig gøre :)</div>]]>
   </description>
   <pubDate>Wed, 01 Aug 2018 18:02:45 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17651.html#17651</guid>
  </item> 
  <item>
   <title><![CDATA[Søge efter data på et andet ark, VBA : Hej med Jer Sub Search()  Dim...]]></title>
   <link>https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17635.html#17635</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=2259">Nervatos</a><br /><strong>Emne:</strong> 3563<br /><strong>Sendt:</strong> 27.Jul.2018 kl. 20:18<br /><br />Hej med Jer<div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>Sub Search()</div><div>&nbsp; &nbsp; Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Ark1")</div><div>&nbsp; &nbsp; Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Ark2")</div><div>&nbsp; &nbsp; Dim fruit As Range: Set fruit = ws1.Range("G2", ws1.Cells(ws1.Rows.Count, "G").End(xlUp))</div><div>&nbsp; &nbsp; Dim fruitCode As Range: Set fruitCode = ws2.Range("C2", ws2.Cells(ws2.Rows.Count, "C").End(xlUp))</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; Dim test As Range: Set test = ws1.Range("D2", ws1.Cells(ws1.Rows.Count, "D").End(xlUp))</div><div>&nbsp; &nbsp; Dim tester As Range: Set tester = ws2.Range("D2", ws2.Cells(ws2.Rows.Count, "D").End(xlUp))</div><div>&nbsp; &nbsp; Dim f As Range, s As Range, t As Range, tt As Range</div><div>&nbsp; &nbsp;&nbsp;</div><div><br></div><div>&nbsp; &nbsp; For Each s In fruit</div><div>&nbsp; &nbsp; &nbsp; &nbsp; For Each f In fruitCode</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For Each t In test</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For Each tt In tester</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If InStr(s.Text, f.Text) &lt;&gt; 0 And InStr(t.Text, tt.Text) &lt;&gt; 0 Then</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f.Offset(0, 5).Value = s.Offset(0, -2).Value</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f.Offset(0, 6).Value = s.Offset(0, -6).Value</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'GoTo SkipTheRest</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DoEvents</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next tt</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next t</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Next f</div><div>SkipTheRest:</div><div>&nbsp; &nbsp; Next s</div><div>End Sub</div></div><div></pre></td></tr></table></div><div><br></div><div>Scriptet fungere i sig selv fint nok, men der er to problemer.&nbsp;</div><div><br></div><div>Jeg får flere tilføjet det samme data ned igennem de samme uger, hvis der er flere uger. Det er selvom der er forskellige varenumre.</div><div><br></div><div>Ark1, G kolonne er uger</div><div>Ark2, C kolonne er uger</div><div><br></div><div>Ark1, D er varenummer</div><div>Ark2, D er varenummer.</div><div><br></div><div>Disse skal matche, før den skal give output. Så uge 32 = uge 32, varenummer 123 = 123 - giver output. Lige nu kan uge 32 = uge 32, varenummer 123 = 321 også give output.&nbsp;</div><div><br></div><div>Har også prøvet at have SkipTheRest til, men så tager den første kun og de andre får ikke data.</div><div><br></div><div>Håber én kan hjælpe mig igennem dette.</div><div>Anedi fra eksperten, ref:&nbsp;<a href="https://www.computerworld.dk/eksperten/spm/1024478" target="_blank" rel="nofollow">https://www.computerworld.dk/eksperten/spm/1024478</a> har lavet en Matrix formel, så faktisk gør hvad den skal. Jeg ønsker blot at få det lavet i VBA i stedet for.</div><div><br></div><div>MATRIX:</div><div>=INDEKS('Ark1'!$F$2:$F$31;SAMMENLIGN(HØJRE(CELLE("filename";$A$1);LÆNGDE(CELLE("filename";$A$1))-FIND("&#093;";CELLE("filename";$A$1)))&amp;Ark2!D2&amp;Ark2!C2;'Ark1'!$C$2:$C$31&amp;'Ark1'!$D$2:$D$31&amp;'Ark1'!$H$2:$H$31;0);1)</div><div><br></div><div>=INDEKS('Ark1'!$A$2:$A$31;SAMMENLIGN(HØJRE(CELLE("filename";$A$1);LÆNGDE(CELLE("filename";$A$1))-FIND("&#093;";CELLE("filename";$A$1)))&amp;Ark2!D4&amp;Ark2!C4;'Ark1'!$C$2:$C$31&amp;'Ark1'!$D$2:$D$31&amp;'Ark1'!$H$2:$H$31;0);1)</div><div><br>PFT. :)</div><div><br></div>]]>
   </description>
   <pubDate>Fri, 27 Jul 2018 20:18:12 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/sge-efter-data-pa-et-andet-ark-vba_topic3563_post17635.html#17635</guid>
  </item> 
 </channel>
</rss>