+ Reply to Thread
Results 1 to 9 of 9

Inserting new rows VBA code

  1. #1
    Forum Contributor
    Join Date
    09-30-2010
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010
    Posts
    109

    Inserting new rows VBA code

    I am looking at this code and trying to edit it for my needs. It currently inserts new rows into three sheets. Would only need it to work with one sheet, but as I try to edit it I get errors on the (Worksheets("Sheet" & lCt).Activate) code. How could I change this to work?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Inserting new rows VBA code

    Simplest edit would be:
    Please Login or Register  to view this content.
    ...or 2 or whatever you need. That would keep you from having to rewrite the whole macro.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    09-30-2010
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010
    Posts
    109

    Re: Inserting new rows VBA code

    I'm sorry I should have noted that I'v tred that, but that why I noted that I am getting error on the code
    Worksheets("Sheet" & lCt).Activate

    so I will need to rewrite the code.

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Inserting new rows VBA code

    This will just work on the active worksheet:

    Please Login or Register  to view this content.

    Dom
    Last edited by Domski; 10-05-2010 at 10:48 AM.
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  5. #5
    Forum Contributor
    Join Date
    09-30-2010
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010
    Posts
    109

    Re: Inserting new rows VBA code

    It work great in a simple workbook but when I add it in to my completed workbook it appears to only remove data that is not a function

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Inserting new rows VBA code

    Your original code is utilizing the xlConstants method, so the suggested solution used it, too.

    If you want the entire row cleared regardless of the formulas in that row, change that line to:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-30-2010
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010
    Posts
    109

    Re: Inserting new rows VBA code

    Now it appears to clear the entire row, still not making a new row.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Inserting new rows VBA code

    I'll defer to Dom, I'm sure he'll respond soon.

  9. #9
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Inserting new rows VBA code

    I'll admit I modified the code but never tested it. Off home now and out tonight but will have a look when I get a chance.

    Dom

+ 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