+ Reply to Thread
Results 1 to 4 of 4

VBA that selects dates in a column and pastes the other columns in a new sheet

  1. #1
    Registered User
    Join Date
    07-26-2013
    Location
    Netherlads
    MS-Off Ver
    Excel 2007
    Posts
    2

    VBA that selects dates in a column and pastes the other columns in a new sheet

    Hi

    I am pretty new to vba and i need a code for doing this

    Sheet looks like this

    Article# in column A
    Price in Column B
    Date in Column C

    Now i need to paste Column A and B in one new sheet, only based on and grouped by the date.

    So for instance I have 10 articles with date x and 10 with Y. I want a sheet which shows the 10 articles with x and one with Y.

    The dates are not known in advance and could be multiple...............

    would be great if this is possible!!
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: VBA that selects dates in a column and pastes the other columns in a new sheet

    The code will change if you have multiple dates like you do in your attached workbook. In your question, you mentioned only have two dates (x and y).

    If you only have x and y, then:

    Sheets("Sheet1").Range("B2").Select
    Do Until ActiveCell.Value = ""
    If ActiveCell. = #8/27/2013# Then
    Range(activecell, Activecell.end(xlToLeft)).copy
    Sheets("Sheet2").Select
    ActiveSheet.Paste
    ActiveCell.Offset(1,0).Select
    Else
    Range(activecell, Activecell.end(xlToLeft)).copy
    Sheets("Sheet3").Select
    ActiveSheet.Paste
    ActiveCell.Offset(1,0).Select
    End If
    Sheets("Sheet1").Select
    ActiveCell.Offset(1,0).Select
    Loop

  3. #3
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: VBA that selects dates in a column and pastes the other columns in a new sheet

    Sorry, forgot to use the code formatting.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-26-2013
    Location
    Netherlads
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA that selects dates in a column and pastes the other columns in a new sheet

    Hi,

    First of all thanks!!

    Still some questions

    If ActiveCell. = #8/27/2013# Then turns red if I paste it in my VBA.

    Also the date isnt always the same and could be more than two dates. Is this VBA still working then?

+ 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. Replies: 4
    Last Post: 10-10-2012, 10:38 AM
  2. Code selects entire rows upto one range and same code selects only columns for other.
    By sriharigk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2012, 05:19 AM
  3. I have a script in where it copies a sheet's data, and pastes it, but over pastes...
    By Cyberpawz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2012, 02:20 AM
  4. Need macro that finds and selects blank cells in col A, pastes shape in all
    By salvator in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2011, 01:12 PM
  5. Selects and pastes data from wrong column
    By tvac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2006, 02:09 PM

Tags for this Thread

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