+ Reply to Thread
Results 1 to 10 of 10

Copy and Paste Cells based on Criteria

  1. #1
    Registered User
    Join Date
    04-28-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    28

    Copy and Paste Cells based on Criteria

    I have 2 columns, Column A has data and blanks in the cells.

    I need a Macro that can go down the column and when it comes across data in a cell in column A it copies and pastes the data to Column B on the same row.

    My 'Looping' does not seem to work Can any one help

    Thanks

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Copy and Paste Cells based on Criteria

    Hi,

    Do you really need code? surely =IF(A1="","",A1) in B1 copied down the length of the data would give the required result?

    If not, please post the code you have so far.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    04-28-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Copy and Paste Cells based on Criteria

    I'm trying to do it as a macro because I'm trying to do a whole load of reformating and wanted everything to run together.

    Code I have so far is but I'm struggling with it being a newbe

    Dim i As Long
    i = 1

    Do Until Trim(Cells(i, 1)) > 200


    If Cells(i, 1) > 0 Then
    Selection.Copy
    ActiveCell.Offset(0, 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    i = i + 1
    Loop

    End If

    End Sub

  4. #4
    Registered User
    Join Date
    04-28-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Copy and Paste Cells based on Criteria

    Hi

    There is one other reason I want a macro in that where there is a blank in column a there is normally a value in colomn b that I do not want overwriten

  5. #5
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Copy and Paste Cells based on Criteria

    Edit your post and tag your code, as is described here.

    Then Try this:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-28-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Copy and Paste Cells based on Criteria

    Hi,

    Thanks for your reply, I've pasted part of the table where I'm trying to test and copy the 100 and 200 into colomn b without changing any of the existing values in column b

    I did not seem to be able to get yours to work

    Column a Column b
    100
    666
    888
    200
    -
    Last edited by GBR2L; 04-28-2010 at 05:47 AM.

  7. #7
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Copy and Paste Cells based on Criteria

    hadn't understood you didn't want to overwrite column B.

    Please Login or Register  to view this content.
    With the data you've posted, the code will stop when it reaches the value 666. What are you expecting
    Please Login or Register  to view this content.
    to do?

  8. #8
    Registered User
    Join Date
    04-28-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Copy and Paste Cells based on Criteria

    Hi,

    I'd hope that it would contunue untill the 200 which would be at the last value in column a

    Guy

  9. #9
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Copy and Paste Cells based on Criteria

    Then
    Please Login or Register  to view this content.
    might be more appropriate?

  10. #10
    Registered User
    Join Date
    04-28-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Copy and Paste Cells based on Criteria

    Hi,

    All Works - Thanks for your help, Much appreciated

+ 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