Code veranderen

Status
Niet open voor verdere reacties.

Segers

Gebruiker
Lid geworden
29 sep 2010
Berichten
30
Beste,

In onderstaande code vraag ik om een rij te kopiëren in een reeds bestaande excel-sheet (andere dan open excel-file)
of om het te kopiëren naar een nieuw excel-sheet "mix.xls"

Maar het werkt niet goed:

HTML:
Private Sub CommandButton2_Click()

Dim Answer As String
Dim MyNote As String

Dim Gebied As String

Gebied = Range("A2:AD2").Copy


    'Place your text here
    MyNote = "Do you want to mix into an existing file?"

    'Display MessageBox
    Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "???")

    If Answer = vbNo Then
        'Code for No button Press
        Application.ScreenUpdating = False    ' Prevents screen refreshing.
        
        Workbooks.Open Filename:="C:\Stock\mix.xlsx"

        'CurrentFile = ThisWorkbook.FullName
 
        'NewFileType = "Excel Files 1997-2003 (*.xls), *.xls," & _
               '"Excel Files 2007 (*.xlsx), *.xlsx," & _
               '"All files (*.*), *.*"
 
        'NewFile = Application.GetSaveAsFilename( _
            'InitialFileName:=NewFileName, _
            'FileFilter:=NewFileType)
 
        'If NewFile <> "" And NewFile <> "False" Then
            'ActiveWorkbook.SaveAs Filename:=NewFile, _
                'FileFormat:=xlNormal, _
                'Password:="", _
                'WriteResPassword:="", _
                'ReadOnlyRecommended:=False, _
                'CreateBackup:=False
 
        'Set ActBook = ActiveWorkbook
            'Workbooks.Open CurrentFile
            'ActBook.Close
    'End If
 
    Application.ScreenUpdating = True
    Else
        'Code for Yes button Press
        MsgBox "You pressed Yes!"
        ChDrive "C:\"
        FileToOpen = Application.GetOpenFilename _
        (Title:="Please select Design Summary", _
        FileFilter:="Excel Files *.xlsm (*.xlsm),")

    If FileToOpen = False Then
        MsgBox "No file specified!", vbExclamation, "LOOK OUT !"
    
    Exit Sub

    Else
        Workbooks.Open Filename:=FileToOpen _
        , UpdateLinks:=0
    
End If

    End If

End Sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan