excel vba programming code

Page 1 of 2 12 LastLast

  1. Posts : 50
    Windows 8.1 x64
       #1

    excel vba programming code


    when i try to make an vba code in excel vba extension at the moment i added
    this line to the code of a button:

    Range("A1").End(xlDown).Offset(1, 0).Select


    it says there is an error but i did exactly what they said on this video
    https://www.youtube.com/watch?v=CzP8nO9UVvY
    its explained just after 25:12 minutes
      My Computer


  2. Posts : 1,049
    Windows 7 Pro 32
       #2

    I tried the code and it works without errors. Are you sure it's that line it complains about?

    This shorter one works to: Range("A1").End(xlDown).Select
      My Computer


  3. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #3

    Tookeri said:
    I tried the code and it works without errors. Are you sure it's that line it complains about?

    This shorter one works to: Range("A1").End(xlDown).Select

    can it be because of spaces before it intstead of langspaces (like when you use tab)

    okay with the short one it works just fine
      My Computer


  4. Posts : 1,049
    Windows 7 Pro 32
       #4

    Great! Please mark the thread as solved
      My Computer


  5. Posts : 3,371
    W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
       #5

    The short version doesn't do the same thing as the long version. The short version selects the last value in column A while the long version selects the next empty cell after the last value in column A. (This assumes there are no empty cells in column A as it will stop on the first empty cell)

    The code works for me but you have to make sure that you are running it against a sheet that has at least one value in column A. If you run it against a column that has no values in it then it will fail because it will go to the last row in column A and then try to go to 1 row down which causes it to fail.
      My Computer


  6. Posts : 1,049
    Windows 7 Pro 32
       #6

    Good points! If the short version produces a logical error, that may be even worse than a real one. Thanks!
      My Computer


  7. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #7

    Tookeri said:
    Good points! If the short version produces a logical error, that may be even worse than a real one. Thanks!
    so do i makr it as solved already or can i aks more questions in this one

    (next question is: how do i solve this error ? with the short code it does like alraedy said by someone else it goes to the verry last colmn and with the long one it does this error(shown below but when i click debug it shows me the code (Range("A1").End(xlDown).Offset(1, 0).Select) is wrong
    Attached Thumbnails Attached Thumbnails excel vba programming code-naamloos.png  
      My Computer


  8. Posts : 1,049
    Windows 7 Pro 32
       #8

    You can ask how many questions you want :)

    If you want the next empty cell you can try the shorter version that doesn't produce an error. And then move one cell down and see if that works:

    Range("A1").End(xlDown).Select
    ActiveCell.Offset(1, 0).Select 'move one cell down
      My Computer


  9. Posts : 3,371
    W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
       #9

    We would need to see what the spreadsheet looks like and what column is "Cell1".
      My Computer


  10. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #10

    Tookeri said:
    You can ask how many questions you want

    If you want the next empty cell you can try the shorter version that doesn't produce an error. And then move one cell down and see if that works:

    Range("A1").End(xlDown).Select
    ActiveCell.Offset(1, 0).Select 'move one cell down
    strollin said:
    We would need to see what the spreadsheet looks like and what column is "Cell1".
    okay now i have an error message at: ActiveCell.Offset(1, 0).Select

    + here are the screen shots of what i think are the spread sheets ( sorry i dont know engish verry well )
    Attached Thumbnails Attached Thumbnails excel vba programming code-naamloos1.png   excel vba programming code-naamloos2.png  
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:05.
Find Us