+ Reply to Thread
Results 1 to 6 of 6

problem with deleting cells

  1. #1
    Registered User
    Join Date
    02-20-2009
    Location
    La, CA
    MS-Off Ver
    Excel 2003
    Posts
    70

    problem with deleting cells

    hello everyone


    i have a table like this one :

    A B C D

    1 "Main" | value | value | value
    2 "Extra" | value | value | value
    '
    '
    n "Main" | value | value | value

    i created a macro that deletes the two cells located in column "B" and "C" and shift the value in column "D" to the left whenever in finds "Main" in range("A")
    here's the code he doesn't work properly i don't know why:

    Please Login or Register  to view this content.
    plz help

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: problem with deleting cells

    Hello mehdoush,

    I am not sure why you have the asterisks in the range. I modified the code and this should do what you want.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-20-2009
    Location
    La, CA
    MS-Off Ver
    Excel 2003
    Posts
    70

    Re: problem with deleting cells

    thank you so much Leith, i appreciate your help

  4. #4
    Registered User
    Join Date
    02-20-2009
    Location
    La, CA
    MS-Off Ver
    Excel 2003
    Posts
    70

    Re: problem with deleting cells

    hey again leith,

    the code works properley.
    i was on msdn website, i was triying to know what are these parameters that you added (in bold) :

    Please Login or Register  to view this content.
    (0,1) and (1,2)
    could you explain them to me plz?

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: problem with deleting cells

    Hello mehdoush.

    Offset will add the row and column values to the range. Resize will change the number of rows and columns for a given range.

    In your code the variable c is a single cell value in column "A". Starting with cell "A1", this what happens:

    Offset(0, 1) now points the cell in the same row and 1 column over or "B1".
    Resize(1, 2) now changes the rows and columns of "B1" to 1 row and 2 columns.

    The range pointed to is now "B1:C1"

    Offset provides a relative reference using zero based arguments. If the row or column is zero there is no change. A positive number points to the next row down or column to the right. A negative number points to the next row up or column to the left. The table below uses "B2" as the starting point. The results are shown for changing the row and column arguments by 1.
    Please Login or Register  to view this content.
    The above referencing technique is the same for Resize with the exception of using zero. Zero is indicated by a missing argument. The missing argument can be indicated by a comma or by using the argument's name.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-20-2009
    Location
    La, CA
    MS-Off Ver
    Excel 2003
    Posts
    70

    Re: problem with deleting cells

    hey Leith,

    i'm so thankful,

    regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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