+ Reply to Thread
Results 1 to 9 of 9

What is wrong with this code? Compile error etc

  1. #1
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    What is wrong with this code? Compile error etc

    Hi there,

    I'm sure this is a really simple error, does anyone know what the problem is with the below code?

    Please Login or Register  to view this content.
    Many thanks

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: What is wrong with this code? Compile error etc

    Try the below code....

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: What is wrong with this code? Compile error etc

    Thanks again, but I don't think that will quite work. If you look closely it actually runs two different macros? One is called CopyActiveCell and the other CopyActiveCell1

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: What is wrong with this code? Compile error etc

    why are there 2 subs with the same name?

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Intersect(Target, Range("B1:B900"))>0 Then
    Call CopyActiveCell
    else
    If Intersect(Target, Range("D1:D900"))>0 Then Call CopyActiveCell1
    end if
    End Sub

  5. #5
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: What is wrong with this code? Compile error etc

    It now says else without if. Although I haven't done your '>0' bit because that bought more errors

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: What is wrong with this code? Compile error etc

    Oops... try this...

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: What is wrong with this code? Compile error etc

    Excellent perfect thank you

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

    Re: What is wrong with this code? Compile error etc

    Please Login or Register  to view this content.
    regarding the sub names I would add an underscore to avoid confusion, CopyActiveCell_1
    Cheers
    Andy
    www.andypope.info

  9. #9
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: What is wrong with this code? Compile error etc

    Thanks sorted

+ 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. [SOLVED] VBA - Compile Error - Wrong number of arguments
    By Janto724 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-28-2013, 06:04 AM
  2. 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
  3. Compile Error - Wrong number of arguments
    By freebird_wr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2013, 09:34 AM
  4. Replies: 1
    Last Post: 02-17-2006, 12:10 PM
  5. Compile Error - Wrong number of arguements or invalid property ***
    By James T in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2005, 03:50 AM

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