+ Reply to Thread
Results 1 to 4 of 4

Compile error As "Wrong number of argument or argument or invalid Property assignment

Hybrid View

jay11 Compile error As "Wrong... 04-28-2010, 03:48 PM
romperstomper Re: Compile error As "Wrong... 04-28-2010, 05:39 PM
mdnghtsnpr Re: Compile error As "Wrong... 04-28-2010, 05:48 PM
jay11 Re: Compile error As "Wrong... 04-28-2010, 05:54 PM
  1. #1
    Forum Contributor
    Join Date
    02-12-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    134

    Compile error As "Wrong number of argument or argument or invalid Property assignment

    hi
    here i have code that give the Compile error As
    "Wrong number of argument or argument or invalid Property assignment

    Private Sub cmdOK_Click()
        Dim i As Long
        Dim NSname As Worksheet
        Dim Sheetname As String
       
      
        If Not ComboBox1.ListIndex = -1 Then
            Sheetname = ComboBox1.Value 'InputBox("Please enter new sheet name")
            
                Workbooks.Open Filename:= _
            "C:\Documents and Settings\g sheet\daily data\target.xls"
            Windows("Check In Data.xls").Activate
            Sheets("Today").Select
            Sheets("Today").Copy After:=Workbooks("target.xls").Sheets(Workbooks("target.xls").Sheets.Count)
            'Sheets("Today").Copy After:=Worksheets(Worksheets.Count)
            'Sheets("To Day").Copy after:=Workbooks("target.xls").Sheets(1)
            ActiveSheet.Name = Sheetname
            ActiveSheet.Unprotect Password:=""
            ActiveSheet.Range("A3").Value = Sheetname
            ActiveSheet.Range("L3").Value = Now()
            ActiveSheet.Protect Password:=""
         Workbooks.Close SaveChanges:=True  'here is the problem athere than  that it's work fine
            Unload Me
        Else
            Unload Me
            MsgBox "Pick a sheet!", 0, vbNullString
        End If
        
    End Sub
    actually i want to close the WB which just copy past so save the WB and close the same
    can u help me pl.
    Last edited by jay11; 04-28-2010 at 04:09 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,173

    Re: Compile error As "Wrong number of argument or argument or invalid Property assign

    You missed the workbook name:
    Workbooks("Target.xls").Close SaveChanges:=True
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    04-23-2010
    Location
    Albuquerque, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Compile error As "Wrong number of argument or argument or invalid Property assign

    Private Sub cmdOK_Click()
        Dim i As Long
        Dim NSname As Worksheet
        Dim Sheetname As String
       
        
        If Not ComboBox1.ListIndex = -1 Then
            Sheetname = ComboBox1.Value 'InputBox("Please enter new sheet name")
            
                Workbooks.Open Filename:= _
            "C:\Documents and Settings\g sheet\daily data\target.xls"
            Windows("Check In Data.xls").Activate
            Sheets("Today").Select
            Sheets("Today").Copy After:=Workbooks("target.xls").Sheets(Workbooks("target.xls").Sheets.Count)
            'Sheets("Today").Copy After:=Worksheets(Worksheets.Count)
            'Sheets("To Day").Copy after:=Workbooks("target.xls").Sheets(1)
            ActiveSheet.Name = Sheetname
            ActiveSheet.Unprotect Password:=""
            ActiveSheet.Range("A3").Value = Sheetname
            ActiveSheet.Range("L3").Value = Now()
            ActiveSheet.Protect Password:=""
         Workbooks("target.xls").Close SaveChanges:=True  'needed to insert workbook name           Unload Me
        Else
            Unload Me
            MsgBox "Pick a sheet!", 0, vbNullString
        End If
        
    End Sub
    Try this

  4. #4
    Forum Contributor
    Join Date
    02-12-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    134

    Re: Compile error As "Wrong number of argument or argument or invalid Property assign

    hi romperstomper
    thanks u save my day it long day
    i am learning the VB
    can u help me for this one it also give me headache

    Sub Rectangle5_Click()
    Dim wks As Worksheet
    Dim wb As Workbook
        
            
            Set wks = ActiveSheet("Today")
            Set wb = Workbooks(" Data.xls")
          With wb
    ThisWorkbook.Worksheets.Add.Name = "Yesterday"        
    ThisWorkbook.Worksheets("Today").Range("A1:N60").Copy _
                    After:=Worksheets(Worksheets.Count)
            wks.Range("A1:N60").Select
            Selection.PasteSpecial Paste:=xlPasteColumnWidths
            ActiveSheet.Paste
        End With
    End Sub
    here i am doing the copy past in same WB but inserting the sheet at end of all sheet

    in anther ward iwant to create the new sheet name"yesterday" is the same copy of "today" sheet and create that one after the all sheet
    and i have this button in "main"sheet.
    thanks for any help
    Last edited by jay11; 04-28-2010 at 06:13 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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