+ Reply to Thread
Results 1 to 6 of 6

vba works for some sheets but not for others

  1. #1
    Registered User
    Join Date
    03-28-2020
    Location
    Maine
    MS-Off Ver
    365
    Posts
    3

    vba works for some sheets but not for others

    I keep track of my transactions in different sheets, i have a button that activates a new row along with formulas. Some sheets work fine, others don't. All run the same code.

    HTML Code: 

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: vba works for some sheets but not for others

    Hi from rainy Seattle,

    Look at the different sheets and see if:
    1. Merged cells are involved in the inserts?
    2. What cell are you in when trying to do this insert?
    3. Might you be in the middle of a table or pivot or chart?

    Are you trying to insert rows or columns? I think rows don't need the quotes while columns do.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-28-2020
    Location
    Maine
    MS-Off Ver
    365
    Posts
    3

    Re: vba works for some sheets but not for others

    Are you trying to insert rows or columns? one ROW

    There about 10 columns where the formatting is transferred to the new row but the "balance" column doesn't get the formula transferred.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: vba works for some sheets but not for others

    After reading this page:
    https://www.wallstreetmojo.com/vba-insert-row/
    it looks like what you have should work.

    What happens if you use
    Please Login or Register  to view this content.
    Does this work?

    I still think you have some merged cells somewhere you are trying to insert.

    Does it work if you remove the CopyOrigin:= .. part of the command?

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: vba works for some sheets but not for others

    Hi mainerain,

    After reading more at: https://stackoverflow.com/questions/...t-in-excel-vba
    that code tells VBA how it is supposed to format the new row you are inserting. What if the two cells have different cell formats? What is one is Bold and the other isn't but is underlined? Which should VBA use for the new row's format?? Perhaps it throws this error because there are two different formats. I also wonder by using this extra parameter, what single cell is it using for doing its "Right" and "Below". See if the activecell makes a difference when it gives an error.

  6. #6
    Registered User
    Join Date
    03-28-2020
    Location
    Maine
    MS-Off Ver
    365
    Posts
    3

    Re: vba works for some sheets but not for others

    I don't get it. I've tried different things. I see no merged cells associated with the row that is copied.

    I have one sheet that has this formula in cell H8:
    HTML Code: 

    Then when I insert the row it morphs into this:
    HTML Code: 
    I'm just a newbie. I don't know what I don't know.

+ 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. VBA defining range only works on selected sheets
    By JacquelineHall in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2018, 08:34 AM
  2. Replies: 1
    Last Post: 07-02-2018, 07:32 PM
  3. Replies: 9
    Last Post: 07-24-2015, 11:13 AM
  4. Checkbox that works on Multiple Sheets
    By idemdito in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2011, 08:31 AM
  5. Tabbing no longer works in protected sheets?
    By Gunther Maplethorpe in forum Excel General
    Replies: 5
    Last Post: 03-29-2011, 04:12 PM
  6. Give the same name to cells in different works sheets
    By Jilt in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-08-2007, 07:18 PM
  7. Macro for filter on protected workbook that works for all sheets, no matter what sheets are named?
    By StargateFanFromWork in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2006, 02:35 PM

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