+ Reply to Thread
Results 1 to 10 of 10

Formatting of pasted row via VBA

  1. #1
    Registered User
    Join Date
    09-18-2008
    Location
    Devon
    MS-Off Ver
    2002
    Posts
    71

    Formatting of pasted row via VBA

    Hi all

    I have the current code:

    Please Login or Register  to view this content.
    Where rows are inserted, can I stop them from copying the formatting from the row above??

    Also, I would like the text that is pasted into the cell A (for divrow and arearow) to be left aligned and bold.

    Can someone help?
    Last edited by HelenW; 10-13-2010 at 10:23 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: Formatting of pasted row via VBA

    Try this:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Formatting of pasted row via VBA

    As you may know, the format of a cell contains many attributes. Look at the Format->Cells... Excel menu option. When you say that you don't want to copy the format, what do you mean? Do you want to make the format something like another row on the spreadsheet? If that is the case, then you could copy that row to the clipboard and then do a PasteSpecial for format only onto the new row.

    Let us know if you need more help.
    Bob
    Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.

  4. #4
    Registered User
    Join Date
    09-18-2008
    Location
    Devon
    MS-Off Ver
    2002
    Posts
    71

    Re: Formatting of pasted row via VBA

    That's excellent romperstomper - thank you. One other minor thing I need to solve, however, is that rows 2 and 3 (the newly inserted ones) are coming in as wrapped text as this is the format of the header row. I've tried adding in a small addition to the code but it's not working...

    Please Login or Register  to view this content.
    (I've just pasted the relevant bit of the code)

  5. #5
    Registered User
    Join Date
    09-18-2008
    Location
    Devon
    MS-Off Ver
    2002
    Posts
    71

    Re: Formatting of pasted row via VBA

    Hi Bob - thanks for your ideas, however I don't want the rows to be formatted the same as any other, necessarily. I just want them to be pasted in as a "normal" row, then make them left aligned and bold which the provided code did fine. I'm stuck with the wraptext now though!

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: Formatting of pasted row via VBA

    The clearformats should remove wraptext anyway. Can you post a sample workbook showing the problem?

  7. #7
    Registered User
    Join Date
    09-18-2008
    Location
    Devon
    MS-Off Ver
    2002
    Posts
    71

    Re: Formatting of pasted row via VBA

    I'll give it a go - lots of data taken out, though, as I don't want it published on a forum - hence the big gaps! You can see what has happened when I've clicked the button on sheet 1 to run the procedures though - both rows at the top still have wrap text applied...
    Attached Files Attached Files

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: Formatting of pasted row via VBA

    Your code never processes rows 1 or 2 though?

  9. #9
    Registered User
    Join Date
    09-18-2008
    Location
    Devon
    MS-Off Ver
    2002
    Posts
    71

    Re: Formatting of pasted row via VBA

    Got it now.... thanks for pointing that out! It wasn't wrap text after all, but just plain old row height :-)

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: Formatting of pasted row via VBA

    Glad it's sorted.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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