+ Reply to Thread
Results 1 to 8 of 8

What is wrong with my syntax? Trying to delete variable range of cells and shift up....

  1. #1
    Registered User
    Join Date
    04-28-2004
    Posts
    49

    What is wrong with my syntax? Trying to delete variable range of cells and shift up....

    All,

    I keep getting the application/object defined error at this piece of my code.

    Please Login or Register  to view this content.
    The larger code is below.

    Please Login or Register  to view this content.
    X is just a counter and it works fine until its time to delete, in which case the error is thrown... Any ideas where I went wrong?

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: What is wrong with my syntax? Trying to delete variable range of cells and shift up...

    I don't seem to get an error when I run this on data that I made up.....

    can you upload some data with confidential stuff removed?....

    Have you stepped through the code to look at the variables and possibly see what is causing the issue?...
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: What is wrong with my syntax? Trying to delete variable range of cells and shift up...

    In this,

    Please Login or Register  to view this content.
    ... the two Cells references are to the active worksheet, which will fail if it's not DataPages.

    You could use

    Please Login or Register  to view this content.
    The dot before Range isn't necessary unless the first cell reference is a literal string, but it doesn't hurt.

    But my preference would be

    Please Login or Register  to view this content.
    Last edited by shg; 06-03-2015 at 06:15 PM.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    04-28-2004
    Posts
    49

    Re: What is wrong with my syntax? Trying to delete variable range of cells and shift up...

    Thanks all for the replies. shg, your last preferred code, how does it not delete row 1 in "s:y"? I see you made the row X which is what I want but I don't understand how "s1:y1" works...

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: What is wrong with my syntax? Trying to delete variable range of cells and shift up...

    In row 5, range("S1:Y1") is S5:Y5.

  6. #6
    Registered User
    Join Date
    04-28-2004
    Posts
    49

    Re: What is wrong with my syntax? Trying to delete variable range of cells and shift up...

    Ok great, I will try this code when I get back to the computer in a few and post back, thanks again.

  7. #7
    Registered User
    Join Date
    04-28-2004
    Posts
    49

    Re: What is wrong with my syntax? Trying to delete variable range of cells and shift up...

    Thanks again shg, this worked great!

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: What is wrong with my syntax? Trying to delete variable range of cells and shift up...

    You're welcome.

+ 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. go through a range and delete, shift cells left if contain no data.
    By 13lack13lade in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2014, 09:50 PM
  2. [SOLVED] If criteria met: delete cell and shift to the left but shift only over a certain range
    By olivierpbeland in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2013, 07:44 AM
  3. VBA Delete range and shift cells up
    By jbmerrel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2013, 06:14 PM
  4. Delete first value and shift cells up when new cell gets added in a range (column)
    By nlazarov in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2013, 08:34 AM
  5. Delete first value and shift cells up when new cell gets added in a range (column)
    By nlazarov in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2013, 07:53 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