+ Reply to Thread
Results 1 to 9 of 9

Macros on how to copy, paste, edit and remove empty cells

  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel Office Professional Plus 2010
    Posts
    32

    Macros on how to copy, paste, edit and remove empty cells

    Hey all,

    I need assistance with the following macros:

    As examples, the cell can be A1 but i'll change the code according to where it belongs on my spreadsheet as i'll need them in several places
    1) Copy (Ctrl + C)
    2) Paste (Ctrl + V)
    3) Edit (F2)
    4) Edit + Paste (F2 + (Ctrl+V))

    This one's a bit different:
    5) Where my cells A1 to A5 has text and then A9 to A14 has text. If I copy and paste A1 to A14 and paste into a text document, the text comes up as (for example shown below), I need a macro/script to removing the dead space between two fields so that it goes from this:
    __________________________________
    Hi
    How are you?
    This is
    A test
    Message




    This is
    How the message
    Appears when
    Loaded into a
    Text document
    __________________________________

    To this:
    __________________________________
    Hi
    How are you?
    This is
    A test
    Message
    This is
    How the message
    Appears when
    Loaded into a
    Text document
    __________________________________

    Thanks all for your help with the above 5 macros.
    Last edited by razor_raef; 01-15-2014 at 01:16 AM.

  2. #2
    Registered User
    Join Date
    06-09-2011
    Location
    Newcastle, Australia
    MS-Off Ver
    2003, 2010
    Posts
    54

    Re: Unsure on a few macros

    Hi razor_raef

    Problem #5
    Several solutions...
    Simplest, unless you have a lot of copy pasting on the same day.
    I use "Metapad" text editor, a free program -- vastly superior to "Notepad", because you can set it to be always on top.
    Unlike Notepad which is always hiding
    Metapad has a find and replace for tabs, new-lines, and backslash

    Sophisticated solution -- using VBA
    select the cells to be copied (for pasting)
    run a macro to remove the "dead spaces"
    load the result into clipboard ready for pasting

    Problems #1 to #4
    Need more information, what are you trying to do, more details please.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Unsure on a few macros

    Hi, razor_raef,

    not the best of all thread titles I must admit.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    For me it doesnīt make sense to edit the contents of a cell directly from VBA as that would block the macro until action is ended. You may consider using an Inpiutbox for that:
    Please Login or Register  to view this content.
    The last code will automaticly paste the value into the cell, you could adapt the cell where to put the value.
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Unsure on a few macros

    Please take a moment to read the forum rules and then amend your thread title to something descriptive of your problem. Once you have done this please send me a PM and I will remove this request.

    To change a Title on your post, click EDIT POST then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Registered User
    Join Date
    07-05-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel Office Professional Plus 2010
    Posts
    32

    Re: Unsure on a few macros

    Problem #5
    Can't use any other program, must be all done within excel.
    I don't know a macro how to remove the empty cells.

    Problems #1 to #4
    Trying to edit the details with macro buttons because the cell that is merged doesnt allow the clipboard data to be pasted as its not the same size and shape.

    I'm going to try upload the spreadsheet so you guys can understand where i'm coming from.

  6. #6
    Registered User
    Join Date
    07-05-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel Office Professional Plus 2010
    Posts
    32

    Re: Unsure on a few macros

    Here is the spreadsheet so it can make sense.

    I want to ultimately have the following:
    1) Edit(F2 button) + Paste macro button for each cell no: Cell I8, Cell I10, Cell K29 & Cell AF29
    2) When I click the purple macro copy button, it selects C41:C55 but removes any empty rows between
    (for example, if you select the following buttons > Monthly K17 Annual AS17 Lifetime W23 5 Age 60 AC23, you'll see a gap between the two cells at between C45-C47 and C49. I need this gap removed please)
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-05-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel Office Professional Plus 2010
    Posts
    32

    Re: Macros on how to copy, paste, edit and remove empty cells

    Hi all,

    Is anyone able to assist with my enquiry?

    Thanks
    Raef

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macros on how to copy, paste, edit and remove empty cells

    Hi, Raef,

    you didnīt mention in your posts before this problem is about merged cells - Iīm out because of this feature.

    Ciao,
    Holger

  9. #9
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Macros on how to copy, paste, edit and remove empty cells

    Hi razor -

    I have modified your VSCopy macro to something like this;
    Please Login or Register  to view this content.
    event

+ 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. unsure what to do
    By scorpio_witch in forum The Water Cooler
    Replies: 17
    Last Post: 08-01-2013, 12:49 AM
  2. unsure what to do
    By scorpio_witch in forum Excel General
    Replies: 3
    Last Post: 07-30-2013, 07:34 PM
  3. AND - Unsure how to use it
    By Strathcona in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2009, 05:53 PM
  4. Unsure of how to do this..
    By karleen77 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-23-2007, 10:23 PM
  5. Im unsure...do you know?
    By genuinegal in forum Excel General
    Replies: 6
    Last Post: 12-21-2006, 12:20 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