Results 1 to 2 of 2

Excel VBA Kopierern durch .Workbooks. .. oder .Windows. .. OOP

Threaded View

  1. #1
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Excel VBA Kopierern durch .Workbooks. .. oder .Windows. .. OOP

    . Hello Leute. … ---o00o---`(_)`---o00o---
    .
    . Ich bin eine Neuling zu Excel VBA und versuche die Theorie etwas besser zu verstehe.
    .
    . Ich wollte an einfach Direkt Methode um die Werte aus einer Cell in eine Excel Mappe (Mappe2) zu kopieren in eine andere Excel Mappe (Mappe 1). Ich wollte die Code selber schreiben durch eine verstand von VBA, statt einfach beim benutzen Makro aufzeichnen
    .
    . Das ist (soll) ja etwas einfach und ich hab es geschafft. Allerdings ich verstehe nicht warum manche Methode die ich probiere nicht funktioniere. Es liegt wahrscheinlisch in die Objekt/Klasse/Orientiren Konzept das ich noch nicht ganz verstehe.
    . (Oder ist es so das man kann nur eine Value geben oder nehmen von eine Mappe das nicht activated ist, mit die Windows .Aktive cell Methode? Man kann also nicht angreifen an cells wenn eine Mappe nicht Aktivieret ist?)
    .
    . Eventuelle kann eine Profi mir Hilfen:-

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. Danke.--6StringJazzer
    .
    '.    Die folgenden 4 Codes sind eine versuche an an einfach direkt Methode.
    '.    Allerdings nur die vierte scheint bei mir zu funktionieren!
    '.
    '‚……………     ……….---o00o---`(_)`---o00o---
    '.------
    Sub WorkbooksCellsMethodDirekt()
    Excel.Application.Workbooks("Mappe1.xlsm").Application.Cells(1, 1).Range("a1").Value _
    = Excel.Application.Workbooks("Mappe2.xlsm").Application.Cells(1, 2).Range("a1").Value
    End Sub
    '.
    '. ------------------------------------------------------------
    '.
    Sub WorkbooksActiveCellMethodDirekt()
    Excel.Application.Workbooks("Mappe1.xlsm").Application.ActiveCell.Range("a1").Value _
    = Excel.Application.Workbooks("Mappe2.xlsm").Application.ActiveCell.Range("a1").Value
    End Sub
    '.
    '. ------------------------
    '.
    Sub WindowsCellsMethodDirekt()
    Excel.Application.Windows("Mappe1.xlsm").Application.Cells(1, 1).Range("a1").Value _
    = Excel.Application.Windows("Mappe2.xlsm").Application.Cells(1, 2).Range("a1").Value
    End Sub
    '.
    '. ---------------------------------------
    '.
    Sub WindowsActiveCellMethodDirekt()
    Excel.Application.Windows("Mappe1.xlsm").Activate
    Excel.Application.Windows("Mappe1.xlsm").ActiveCell.Range("a1").Value _
    = Excel.Application.Windows("Mappe2.xlsm").ActiveCell.Range("a1").Value
    End Sub
    '.
    '. ----------------------------------------
    '.
    '.   Es sieht also als ob nur die Windows "Objekt" hat eine extra Activecell
    '. statt nur Application.Activecell zu verfugen. Irgendwie macht das die unterscheid!!!.
    '.
    ' (Bzw.     Workbooks hat .Application.Cells  und  .Application.ActiveCell.
    '.       Windows hat auch dieses .Application.Cells und .Application.ActiveCell,
    '.    allerdings Windows hat  an extra  .ActiveCell das Workbooks nicht hat!?!?)
    '.
    '.  Kann jemand erkläre das mir!!?!
    '.
    'Danke, Alan Elston.
    '. Hof,Bayern   den 22.05.2014
    '. Email   DocAElstein@t-online.de
    '.............
    '.
    '.   P.s. Eine mehr komplizieret Methode mit eine zwischen Lager funktionieret bei
    '.     jede 4 Methode. Bzw. Die folgenden 4 Codes funktionieren alles Einbahn frei!!
    '.
    '.-----------
    Sub WorkbooksCellsMethodMitZwischenLager()
    Dim ZwischenLager As Double
    
    Excel.Application.Workbooks("Mappe2.xlsm").Activate
    
    Let ZwischenLager _
    = Excel.Application.Workbooks("Mappe2.xlsm").Application.Cells(1, 2).Range("a1").Value
    
    Excel.Application.Workbooks("Mappe1.xlsm").Activate
    
    Excel.Application.Workbooks("Mappe1.xlsm").Application.Cells(1, 1).Range("a1").Value _
    = ZwischenLager
    End Sub
    '.
    '. -------------------------------------------       ---o00o---`(_)`---o00o---
    '.
    
    Sub WorkbooksActiveCellMethodMitZwischenLager()
    Dim ZwischenLager As Double
    
    Excel.Application.Workbooks("Mappe2.xlsm").Activate
    
    Let ZwischenLager _
    = Excel.Application.Workbooks("Mappe2.xlsm").Application.ActiveCell.Range("a1").Value
    
    Excel.Application.Workbooks("Mappe1.xlsm").Activate
    
    Excel.Application.Workbooks("Mappe1.xlsm").Application.ActiveCell.Range("a1").Value _
    = ZwischenLager
    End Sub
    '.
    '. ----------------------------------------
    '.
    Sub WindowsCellsMethodMitZwischenLager()
    Dim ZwischenLager As Double
    
    Excel.Application.Windows("Mappe2.xlsm").Activate
    
    Let ZwischenLager _
    = Excel.Application.Windows("Mappe2.xlsm").Application.Cells(1, 2).Range("a1").Value
    
    Excel.Application.Windows("Mappe1.xlsm").Activate
    
    Excel.Application.Windows("Mappe1.xlsm").Application.Cells(1, 1).Range("a1").Value _
    = ZwischenLager
    End Sub
    '.
    '. -------------------------------------------
    '.
    Sub WindowsActiveCellMethodMitZwischenLager()
    Dim ZwischenLager As Double
    
    Excel.Application.Windows("Mappe2.xlsm").Activate
    
    Let ZwischenLager _
    = Excel.Application.Windows("Mappe2.xlsm").Application.ActiveCell.Range("a1").Value
    
    Excel.Application.Windows("Mappe1.xlsm").Activate
    
    Excel.Application.Windows("Mappe1.xlsm").Application.ActiveCell.Range("a1").Value _
    = ZwischenLager
    End Sub
    '. -------------------------------------------------
    '
    Moderator's note: Moved from Excel Programming / VBA / Macros --6StringJazzer
    Last edited by 6StringJazzer; 05-23-2014 at 09:00 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] how do I open multiple excel workbooks in seperate windows?
    By rverdery in forum Excel General
    Replies: 2
    Last Post: 06-12-2006, 10:20 PM
  2. [SOLVED] Opening Excel workbooks from Windows Explorer
    By R Ormerod in forum Excel General
    Replies: 2
    Last Post: 04-01-2006, 07:50 AM
  3. Replies: 2
    Last Post: 06-03-2005, 12:05 PM
  4. [SOLVED] Excel workbooks in different windows & Fill color?
    By RR in forum Excel General
    Replies: 1
    Last Post: 04-05-2005, 07:06 PM
  5. How can I get existing Excel workbooks to open in separate windows
    By Christy99 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2005, 09:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1