+ Reply to Thread
Results 1 to 9 of 9

Getting compile error 'Wrong number of argument or invalid property assignment'

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Getting compile error 'Wrong number of argument or invalid property assignment'

    Hi,
    I'm getting compile error 'wrong number of argument or invalid property assignment' on the first line word 'range'.
       If Not Intersect(Target, 'Range'("g:h", "m:n", "s:t", "y:z", "ae:af", "ak:al", "aq:ar", "aw:ax", "bc:bd", "bf:bg")) Is Nothing Then
    The code is:

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    'CONCATENATE SUPERSCRIPT RED
    
        Dim x As Long
        Dim rngCell As Range
        If Not Intersect(Target, Columns("b:bh")) Is Nothing Then
            For Each rngCell In Cells(Target.Row, "b").Resize(, 60).Cells
                With rngCell
                    If .Row >= 8 Then
                        If .Value Like "*[+]*" Then
                            'If .HasFormula Then .Formula = .Value
                            x = InStr(.Value, "+")
                            .Characters(x).Font.Superscript = True
                            .Characters(x).Font.ColorIndex = 3
                        End If
                    End If
                End With
            Next rngCell
        End If
        
    'CONCATENATE  AVERAGE + GRACE
    
    Dim cell As Range
    
        Application.EnableEvents = False
        
       If Not Intersect(Target, Range("g:h", "m:n", "s:t", "y:z", "ae:af", "ak:al", "aq:ar", "aw:ax", "bc:bd", "bf:bg")) Is Nothing Then
    
            For Each cell In Intersect(Target, Range("g:h", "m:n", "s:t", "y:z", "ae:af", "ak:al", "aq:ar", "aw:ax", "bc:bd", "bf:bg"))
                                               With Cells(cell.Row, "i", "o", "u", "aa", "ag", "am", "as", "ay", "be", "bh")
                        .FormulaR1C1 = _
    "=IF(RC[-2]="""","""",IF(RC[-1]="""",RC[-2],CONCATENATE(RC[-2],""+"",RC[-1])))"
                        .Value = .Value
                    End With
                           Columns.AutoFit
            Next cell
        End If
        
    Application.EnableEvents = True
    
    End Sub
    Any help will be appreciated.

    Thanking you.
    Sincerely,

    mso3

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,444

    Re: Getting compile error 'Wrong number of argument or invalid property assignment'

    should be

    If Not Intersect(Target, Range("g:h,m:n,s:t,y:z,ae:af,ak:al,aq:ar,aw:ax,bc:bd,bf:bg")) Is Nothing Then
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error 'Wrong number of argument or invalid property assignment'

    Hi Andy Pope,
    Thank you. Now the error has gone but another error 'compile error 13 time mismatch occur on line:

     with Cells(cell.Row, "i,o,u,aa,ag,am,as,ay,be,bh")
    The code is:

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    'CONCATENATE SUPERSCRIPT RED
    
        Dim x As Long
        Dim rngCell As Range
        If Not Intersect(Target, Columns("b:bh")) Is Nothing Then
            For Each rngCell In Cells(Target.Row, "b").Resize(, 60).Cells
                With rngCell
                    If .Row >= 8 Then
                        If .Value Like "*[+]*" Then
                            'If .HasFormula Then .Formula = .Value
                            x = InStr(.Value, "+")
                            .Characters(x).Font.Superscript = True
                            .Characters(x).Font.ColorIndex = 3
                        End If
                    End If
                End With
            Next rngCell
        End If
        
    'CONCATENATE  AVERAGE + GRACE
    
    Dim cell As Range
    
        Application.EnableEvents = False
        
       If Not Intersect(Target, Range("g:h,m:n,s:t,y:z,ae:af,ak:al,aq:ar,aw:ax,bc:bd,bf:bg")) Is Nothing Then
            For Each cell In Intersect(Target, Range("g:h,m:n,s:t,y:z,ae:af,ak:al,aq:ar,aw:ax,bc:bd,bf:bg"))
     with Cells(cell.Row, "i,o,u,aa,ag,am,as,ay,be,bh")
                        .FormulaR1C1 = _
    "=IF(RC[-2]="""","""",IF(RC[-1]="""",RC[-2],CONCATENATE(RC[-2],""+"",RC[-1])))"
                        .Value = .Value
                    End With
                           Columns.AutoFit
            Next cell
        End If
        
    Application.EnableEvents = True
    
    End Sub
    Solution please!

    Thank you.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,444

    Re: Getting compile error 'Wrong number of argument or invalid property assignment'

    The is just gibberish.

    You can not use multple references when using Cells object. You need to use Range object.
    Also you can not just use a single mention of a column.

     With Intersect(cell.entireRow, range("i:i,o:o,u:u,aa:aa,ag:ag,am:am,as:as,ay:ay,be:be,bh:bh"))

  5. #5
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error 'Wrong number of argument or invalid property assignment'

    Hi Andy Pope,
    Thank you for guidance. Now the error has gone. I have made necessary changes as per my knowledge.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    'CONCATENATE SUPERSCRIPT RED
    
        Dim x As Long
        Dim rngCell As Range
        If Not Intersect(Target, Columns("b:bh")) Is Nothing Then
            For Each rngCell In Cells(Target.Row, "b").Resize(, 60).Cells
                With rngCell
                    If .Row >= 8 Then
                        If .Value Like "*[+]*" Then
                            'If .HasFormula Then .Formula = .Value
                            x = InStr(.Value, "+")
                            .Characters(x).Font.Superscript = True
                            .Characters(x).Font.ColorIndex = 3
                        End If
                    End If
                End With
            Next rngCell
        End If
        
    'CONCATENATE  AVERAGE + GRACE
    
    Dim rngCell As Range
    
        Application.EnableEvents = False
        
       If Not Intersect(Target, Range("g:h,m:n,s:t,y:z,ae:af,ak:al,aq:ar,aw:ax,bc:bd,bf:bg")) Is Nothing Then
            For Each rngCell In Intersect(cell.EntireRow, Range("g:h,m:n,s:t,y:z,ae:af,ak:al,aq:ar,aw:ax,bc:bd,bf:bg"))
            With rngCell
                   Intersect(cell.EntireRow, Range("i:i,o:o,u:u,aa:aa,ag:ag,am:am,as:as,ay:ay,be:be,bh:bh"))
                        .FormulaR1C1 = _
    "=IF(RC[-2]="""","""",IF(RC[-1]="""",RC [-2],CONCATENATE(RC[-2],""+"",RC[-1])))"
                        .Value = .Value
                    End With
                           Columns.AutoFit
            Next rngCell
        End If
        
    Application.EnableEvents = True
    
    End Sub
    Please go through it and suggest me a correction.

    Thank you.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,444

    Re: Getting compile error 'Wrong number of argument or invalid property assignment'

    You changed object cell to be rngCell but have not updated that code.

    Intersect(rngCell.EntireRow, Range("i:i,o:o,u:u,aa:aa,ag:ag,am:am,as:as,ay:ay,be:be,bh:bh"))
                        .FormulaR1C1 = _
    "=IF(RC[-2]="""","""",IF(RC[-1]="""",RC [-2],CONCATENATE(RC[-2],""+"",RC[-1])))"

  7. #7
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error 'Wrong number of argument or invalid property assignment'

    Hi Andy Pope,
    Thank you. I got my mistake. Now I'm getting compile error 'syntax error' on the line:

    Intersect(rngCell.EntireRow, Range("i:i,o:o,u:u,aa:aa,ag:ag,am:am,as:as,ay:ay,be:be,bh:bh"))
    I think after this revision the problem will be solved.

    Thanking you.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,444

    Re: Getting compile error 'Wrong number of argument or invalid property assignment'

    I assume you code should be,

        With rngCell
            With Intersect(.EntireRow, Range("i:i,o:o,u:u,aa:aa,ag:ag,am:am,as:as,ay:ay,be:be,bh:bh"))
                .FormulaR1C1 = "=IF(RC[-2]="""","""",IF(RC[-1]="""",RC [-2],CONCATENATE(RC[-2],""+"",RC[-1])))"
                .Value = .Value
            End With
        Next rngCell

  9. #9
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error 'Wrong number of argument or invalid property assignment'

    Hi Andy Pope,
    Thank you. It's working fine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Compile Error: Wrong number of arguments or invalid property assignment .... help!
    By powercell99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2013, 03:30 PM
  2. [SOLVED] Compile Error: Wrong number of arguments or invalid property assignment
    By bobmaucher in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2013, 12:41 PM
  3. Replies: 3
    Last Post: 04-28-2010, 05:54 PM
  4. [SOLVED] Error: Wrong number of argument or invalid property assignment?
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2006, 01:35 PM
  5. Replies: 1
    Last Post: 02-17-2006, 12:10 PM

Tags for this Thread

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