+ Reply to Thread
Results 1 to 5 of 5

Please explain why I'm getting a syntax error?

  1. #1
    Registered User
    Join Date
    03-12-2014
    Location
    Central Texas
    MS-Off Ver
    Excel 2010
    Posts
    55

    Question Please explain why I'm getting a syntax error?

    So I'm building up this Frankenstein VBA code project from snippets I'm finding online and I have this put together:
    Please Login or Register  to view this content.
    Now, when I run it with an actual number in "columncount = 250", it works fine. But when I change it to "columncount = Application.WorksheetFunction.CountA(1:1)", I get syntax error. What have I gotten wrong in there?
    Also, I have tried "columncount = Application.WorksheetFunction.CountA("1:1")", but it only runs once through the loop and then quits.
    Can someone please point out what the VBA newbie is missing?
    Oh! I get it. I need rep--->҉

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Please explain why I'm getting a syntax error?

    Try:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-12-2014
    Location
    Central Texas
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Please explain why I'm getting a syntax error?

    Wow, that works great! But I don't have any idea what any of it means. Could you please explain it?

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Please explain why I'm getting a syntax error?

    To see what this means try this in a blank workbook.

    1) Type anything into any cell in the first row, say K1, then press enter.

    2) Hold down the control key and press the right arrow one time, then the up arrow one time. You should end un on cell XFD1.

    **XFD is the last column, number 16,384. Cells(1,columns.count) refers to this cell (columns.count = the total number of columns in the worksheet)

    3) Now that you are on cell XFD1 - press the "End" button on your keyboard one time (press and release, don't hold down).

    ** You have just put Excel into "End Mode"

    4) Press the left arrow one time - you should end up on cell K1 where you typed something. Google end mode if you've never heard of it https://blogs.office.com/2011/09/06/...sing-end-mode/


    CELLS(1,COLUMNS.COUNT).END(xlToLeft).column -> that mimics what you did on the keyboard (mimics it logically, without actually doing it) - it's a common way of finding the last column :D
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  5. #5
    Registered User
    Join Date
    03-12-2014
    Location
    Central Texas
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Please explain why I'm getting a syntax error?

    Aha, ok then. Thank you both so much.

+ 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. please explain the given syntax
    By roofi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-02-2015, 06:59 AM
  2. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  3. Problem with error handling on second error - please explain
    By rbs123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-26-2013, 03:25 AM
  4. [SOLVED] Type Mismatch error -- Can someone explain please?
    By MB_vba in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-09-2013, 07:19 PM
  5. [SOLVED] I can't explain this RIGHT error.
    By RevenantOne in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-07-2012, 07:10 PM
  6. Explain Syntax Error
    By captedgar in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-29-2010, 05:57 PM
  7. [SOLVED] please explain this syntax
    By Papa Jonah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2005, 04:06 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