Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
768to772
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
768to772
768to772
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Bitte Script für Arbeitsmappe anpassen

Bitte Script für Arbeitsmappe anpassen
31.05.2006 12:00:44
Nicole
Hallo
Folgendes Script sucht in den Tabellenblättern Vorbereitung und Aufmass nach den Artikelbeschreibungen, wenn ich im Blatt Rechnung in Spalte A die Passende Positionsnummer eingebe. Ich würde diese beiden Blätter jedoch gerne in eine andere Arbeitsmappe Auslagern.
Könnte mir wohl jemand das Script so anpassen, dass in der geöffneten Arbeitsmappe "Daten" in diesen genannten Blättern gesucht wird.
Wäre Euch wirklich sehr dankbar da ich von VBA keine Ahnung habe.
Nicole

Sub Aufmassdaten()
Dim wks As Worksheet
Dim rng As Range
Dim iRowL As Integer, iRow As Integer
Dim tarWks As Worksheet
Set tarWks = Worksheets("Rechnung")
For Each wks In Sheets(Array("Vorbereitung", "Aufmass"))
With wks
iRowL = tarWks.Cells(.Rows.Count, 1).End(xlUp).Row
For iRow = 8 To iRowL
If Not IsEmpty(tarWks.Cells(iRow, 1)) Then
Set rng = .Cells.Find(tarWks.Cells(iRow, 1), _
lookat:=xlWhole, LookIn:=xlValues)
If Not rng Is Nothing Then
For iSpalte = 1 To 3
tarWks.Cells(iRow, iSpalte).Value = .Cells(rng.Row, iSpalte).Value
If .Cells(rng.Row, iSpalte).Font.Bold = True Then
tarWks.Cells(iRow, iSpalte).Font.Bold = True
Else
tarWks.Cells(iRow, iSpalte).Font.Bold = False
' Fetten Text im Inhalt bestimmen und in Zielzelle formatieren
iFettStart = 0
iFettEnde = 0
i = 0
Do Until i = Len(.Cells(rng.Row, iSpalte).Value)
i = i + 1
If iFettStart = 0 And .Cells(rng.Row, iSpalte).Characters(Start:=i, Length:=1).Font.FontStyle = "Fett" Then
iFettStart = i
Else
If iFettStart > 0 And .Cells(rng.Row, iSpalte).Characters(Start:=i, Length:=1).Font.FontStyle <> "Fett" Then
iFettEnde = i
tarWks.Cells(iRow, iSpalte).Characters(Start:=iFettStart, Length:=iFettEnde - iFettStart).Font.FontStyle = "Fett"
iFettStart = 0
iFettEnde = 0
End If
End If
Loop
If iFettStart > 0 And iFettEnde = 0 Then 'Text ist bis zum Ende Fett
tarWks.Cells(iRow, iSpalte).Characters(Start:=iFettStart, Length:=i + 1 - iFettStart).Font.FontStyle = "Fett"
End If
End If
Next iSpalte
End If
End If
Next iRow
End With
Next wks
End Sub

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Bitte Script für Arbeitsmappe anpassen
HansHei
Hallo Nicole,
wenn ich es richtig verstanden habe ist die Datei Daten geöffnet. Dort willst Du aus den Tabellenblättern mit gleichen Namen die Daten ziehen. Probier mal:
Sub Aufmassdaten()
    Dim wks As Worksheet
    Dim rng As Range
    Dim iRowL As Integer, iRow As Integer
    Dim tarWks As Worksheet
    Set tarWks = Worksheets("Rechnung")
    Dim wb As Workbook, ab As Workbook
    'aktives Workbook merken
    Set ab = ActiveWorkbook
    'wenn Quelle.XLS noch nicht offen ist
    'Set wb = Application.Workbooks.Open("D:\Meine_Dateien_neu\Test\Daten.xls")
    'sonst
    Set wb = Workbooks("Daten.xls")
    ab.Activate
    For Each wks In wb.Sheets(Array("Vorbereitung""Aufmass"))
        With wks
            iRowL = tarWks.Cells(.Rows.Count, 1).End(xlUp).Row
            For iRow = 8 To iRowL
                If Not IsEmpty(tarWks.Cells(iRow, 1)) Then
                    Set rng = .Cells.Find(tarWks.Cells(iRow, 1), _
                        lookat:=xlWhole, LookIn:=xlValues)
                    If Not rng Is Nothing Then
            For iSpalte = 1 To 3
              tarWks.Cells(iRow, iSpalte).Value = .Cells(rng.Row, iSpalte).Value
              If .Cells(rng.Row, iSpalte).Font.Bold = True Then
                tarWks.Cells(iRow, iSpalte).Font.Bold = True
                Else
                tarWks.Cells(iRow, iSpalte).Font.Bold = False
                ' Fetten Text im Inhalt bestimmen und in Zielzelle formatieren
                iFettStart = 0
                iFettEnde = 0
                i = 0
                Do Until i = Len(.Cells(rng.Row, iSpalte).Value)
                  i = i + 1
                  If iFettStart = 0 And .Cells(rng.Row, iSpalte).Characters(Start:=i, Length:=1).Font.FontStyle = "Fett" Then
                    iFettStart = i
                  Else
                    If iFettStart > 0 And .Cells(rng.Row, iSpalte).Characters(Start:=i, Length:=1).Font.FontStyle <> "Fett" Then
                      iFettEnde = i
                      tarWks.Cells(iRow, iSpalte).Characters(Start:=iFettStart, Length:=iFettEnde - iFettStart).Font.FontStyle = "Fett"
                      iFettStart = 0
                      iFettEnde = 0
                    End If
                  End If
                Loop
                If iFettStart > 0 And iFettEnde = 0 Then 'Text ist bis zum Ende Fett
                  tarWks.Cells(iRow, iSpalte).Characters(Start:=iFettStart, Length:=i + 1 - iFettStart).Font.FontStyle = "Fett"
                End If
              End If
            Next iSpalte
          End If
                End If
            Next iRow
        End With
    Next wks
End Sub
Gruß
Hans
Anzeige
AW: Vielen, vielen Dank an Hans!!
31.05.2006 21:42:02
Nicole
Hallo Hans !!!
vielen Dank.
Durch Euch und Eure Kenntnisse kann man sich die altägliche Excelarbeit
wirklich erleichtern.
Gut das es Euch gibt.
Danke Nicole
freut mich, dass es klappt :-)
31.05.2006 22:27:11
HansHei
Danke für die Rückmeldung!
Hans

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige