Thema Datum  Von Nutzer Rating
Antwort
Rot Problem mit Variablen in Sverweis
29.09.2013 15:59:56 Jörg
NotSolved
29.09.2013 17:27:02 Holger
NotSolved
29.09.2013 18:00:12 Jörg
NotSolved
29.09.2013 23:45:04 Gast6677
NotSolved
30.09.2013 15:37:12 Jörg
NotSolved
30.09.2013 18:25:39 Gast71176
NotSolved
01.10.2013 13:10:50 Jörg
NotSolved
01.10.2013 14:52:16 Gast38243
NotSolved
02.10.2013 00:06:16 Jörg
NotSolved
02.10.2013 03:03:09 Gast75873
NotSolved
02.10.2013 14:20:42 Jörg
NotSolved
02.10.2013 16:46:36 Gast58115
NotSolved
02.10.2013 20:04:25 Jörg
NotSolved
02.10.2013 23:48:56 Gast12290
NotSolved
05.10.2013 14:48:47 Gast43599
NotSolved
02.10.2013 16:52:56 Gast78404
NotSolved
02.10.2013 20:05:25 Jörg
NotSolved
03.10.2013 11:48:05 Jörg
Solved
03.10.2013 12:39:17 Gast42493
NotSolved
05.10.2013 12:44:44 Jörg
NotSolved
05.10.2013 14:35:03 Gast37407
NotSolved

Ansicht des Beitrags:
Von:
Jörg
Datum:
29.09.2013 15:59:56
Views:
1590
Rating: Antwort:
  Ja
Thema:
Problem mit Variablen in Sverweis

Hallo zusammen

Bin wieder an die Grenzen meiner Programmierkunst gestossen...

Ich möchte eine sverweis-Formel mit fast ausschliesslich Variabeln erstellen. Die Werte der Variabeln sind teilweise aus einer ComboBox.

Ohne Verwendung der Variablen in der sverweis-Formel (Makro oben) funktionierts, mit den Variablen (Makro unten) leider nicht.

Habe etliche Forenbeiträge gelesen, doch leider habe ich es immer noch nicht geschaft, die Formel mit den Variablen korrekt darzustellen.

Für Eure Hilfe wäre ich sehr dankbar.

Viele Grüsse,

Jörg

 

So funktionierts:

Sub SverweisUndVergleichsformelnEinsetzen1() 'so funktionierts
 
Dim z As String
Dim Blatt1 As String
Dim Blatt2 As String
Dim BlattZiel As String
Dim azeile As String
Dim aspalte As Long
 
 
Blatt1 = ComboBox9.Value
Blatt2 = ComboBox10.Value
BlattZiel = ComboBox11.Value
 
Sheets(BlattZiel).Select
 
z = Sheets(BlattZiel).Cells(Rows.Count, 1).End(xlUp).Row
 
azeile = 1
aspalte = 2
    
    Sheets(BlattZiel).Cells(azeile, aspalte).Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(C1,'" & Blatt1 & "'!C1:C2,2,0)"           'mit dieser Formel funktionierts
        
    Selection.AutoFill Destination:=Range(Cells(azeile, aspalte), Cells(z, aspalte))
        
    aspalte = aspalte + 1
        
    Sheets(BlattZiel).Cells(azeile, aspalte).Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(C1,'" & Blatt2 & "'!C1:C2,2,0)"
    Selection.AutoFill Destination:=Range(Cells(azeile, aspalte), Cells(z, aspalte))
   
End Sub
 
 
Und so funktionierts nicht:
 
Sub SverweisUndVergleichsformelnEinsetzen()
 
Dim u As String
Dim y As String
Dim z As String
Dim Blatt1 As String
Dim Blatt2 As String
Dim BlattZiel As String
Dim azeile As String
Dim aspalte As Long
Dim VergleichsspalteBis As Long
Dim VergleichsspalteVon As Long
Dim Keyspalte As Long
 
 
Blatt1 = ComboBox9.Value
Blatt2 = ComboBox10.Value
BlattZiel = ComboBox11.Value
Keyspalte = ComboBox16.Value
VergleichsspalteVon = ComboBox14.Value
VergleichsspalteBis = ComboBox15.Value
 
 
Sheets(BlattZiel).Select
 
u = Sheets(Blatt1).Cells(Rows.Count, 1).End(xlUp).Row
y = Sheets(Blatt2).Cells(Rows.Count, 1).End(xlUp).Row   
z = Sheets(BlattZiel).Cells(Rows.Count, 1).End(xlUp).Row                        'unterste gefüllte Zeile des Zielblattes
 
azeile = 1
aspalte = 2
    
    Sheets(BlattZiel).Cells(azeile, aspalte).Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(C1,'" & Blatt1 & "'Cells(1 ,Keyspalte),cells(u, VergleichsspalteBis),VergleichsspalteVon,0)"   'hier ist der Wurm drin!
       
    Selection.AutoFill Destination:=Range(Cells(azeile, aspalte), Cells(z, aspalte))
        
    aspalte = aspalte + 1
        
    Sheets(BlattZiel).Cells(azeile, aspalte).Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(C1,'" & Blatt2 & "'!C1:C2,2,0)"
    Selection.AutoFill Destination:=Range(Cells(azeile, aspalte), Cells(z, aspalte))
       
End Sub
 

Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:

 
 

  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
Rot Problem mit Variablen in Sverweis
29.09.2013 15:59:56 Jörg
NotSolved
29.09.2013 17:27:02 Holger
NotSolved
29.09.2013 18:00:12 Jörg
NotSolved
29.09.2013 23:45:04 Gast6677
NotSolved
30.09.2013 15:37:12 Jörg
NotSolved
30.09.2013 18:25:39 Gast71176
NotSolved
01.10.2013 13:10:50 Jörg
NotSolved
01.10.2013 14:52:16 Gast38243
NotSolved
02.10.2013 00:06:16 Jörg
NotSolved
02.10.2013 03:03:09 Gast75873
NotSolved
02.10.2013 14:20:42 Jörg
NotSolved
02.10.2013 16:46:36 Gast58115
NotSolved
02.10.2013 20:04:25 Jörg
NotSolved
02.10.2013 23:48:56 Gast12290
NotSolved
05.10.2013 14:48:47 Gast43599
NotSolved
02.10.2013 16:52:56 Gast78404
NotSolved
02.10.2013 20:05:25 Jörg
NotSolved
03.10.2013 11:48:05 Jörg
Solved
03.10.2013 12:39:17 Gast42493
NotSolved
05.10.2013 12:44:44 Jörg
NotSolved
05.10.2013 14:35:03 Gast37407
NotSolved