+ Reply to Thread
Results 1 to 5 of 5

VBA macro for conditional copying and pasting into new sheet

  1. #1
    Registered User
    Join Date
    05-21-2017
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    14

    VBA macro for conditional copying and pasting into new sheet

    Hello,
    My VBA knowledge is very limited and this is currently beyond my scope. Any help, even if it is just a starting point that would help me figure it out on my own would be appreciated.

    Data-Column A has all of the data in it. The amount of data can range from hundreds to thousands of lines and there is no specific pattern to how the data comes to the cell. It is copied and pasted from another source en masse.

    Goal-Copy the data between cells that have "Data" and "End" in them and paste them in Sheet2. Sheet2 column A is blank.

    Sheet1
    A
    1 aaaaaaaaaaaaaaaaaaaa
    2 bbbbbbbbbbbbb
    3 Data
    4 45
    5 36
    6 17
    7 End
    8 dddddddddddd
    9 eeeeeeee
    10 Data
    11 13
    13 222
    14 End
    15 ffffffffffffffffffffffffffffffffffffff

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

    Re: VBA macro for conditional copying and pasting into new sheet

    Hi JSH,

    Here is some simple code to do what you want. See if you can understand it and apply it.
    Please Login or Register  to view this content.
    Data2End2Sheet2.xlsm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    05-21-2017
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    14

    Re: VBA macro for conditional copying and pasting into new sheet

    Quote Originally Posted by MarvinP View Post
    Hi JSH,

    Here is some simple code to do what you want. See if you can understand it and apply it.
    Please Login or Register  to view this content.
    Attachment 571186

    Hi MarvinP,
    I applied it to the data I am working with and it worked perfectly. Thank you!
    In attempt to understand more why is the "double" needed at the beginning section of the code? As stated in the OP my knowledge is limited.

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

    Re: VBA macro for conditional copying and pasting into new sheet

    Hi JHS,

    When we write VBA code we create variable names like RowCtr (my abbreviation for Row Counter). For the computer to understand how much room to leave for the variable it needs to know what kind of variable it is going to be. Is it TEXT? Is it an INTEGER? Might it be a BOOLEAN? The "DIM" statement is there to tell VBA what values are going to be kept by this variable name.

    Here is the list of variable types: http://www.informit.com/articles/art...39929&seqNum=2

    I use "Double" as it is my habit. I could have used "Long" or "Single" but if I used "Integer" it would max out at 32K and there are more rows in a worksheet than this.

    I hope this explains some of my code.

  5. #5
    Registered User
    Join Date
    05-21-2017
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    14

    Re: VBA macro for conditional copying and pasting into new sheet

    Yes it does. Thank you.

+ 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. Copying & pasting a current region to another sheet w/o actually copying.....
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2014, 09:08 PM
  2. Macro - For copying columns from one sheet onto another is pasting a picture instead
    By Thorxes1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-31-2014, 04:54 PM
  3. Replies: 9
    Last Post: 05-13-2013, 05:43 AM
  4. Help with copying and pasting conditional formatting
    By toshea4 in forum Excel General
    Replies: 6
    Last Post: 03-19-2013, 04:19 PM
  5. Using a macro to copying data from 1 sheet, and pasting into next empty cell
    By Varial in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-13-2012, 04:05 PM
  6. [SOLVED] Macro to keep conditional formatting when pasting to a new sheet
    By ezzy85 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2012, 08:48 PM
  7. [SOLVED] Macro for Finding Sheet Names, then Copying/Pasting Values
    By Joel.Nemec in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-09-2012, 01:28 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