Results 1 to 5 of 5

Macro to copy data under appropriate heading

Threaded View

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Macro to copy data under appropriate heading

    Hi,

    I've attached a spreadsheet of what I'm working on. I have 2 tabs, "Sheet 1" (which is where I want to execute the macro) and "How it should look like" (after the macro has been executed).

    I'm trying to create a macro that copies range A18:A20 under the appropriate heading date in "Sheet1". For example, if the month is September 2013, I want it to copy the cells into C2:C3.

    You might ask why I'm not using a lookup function. The reason is that this is only a small scale example of what I'm working on. At the start of every new month, cell A17 is going to change, but I still want to be able to have previous months' records. So for example, in October, cell A17 will be October 2013, but I still want to keep September's values. Like I said, this is a really simplified example of what I'm working on.

    The script I'm working on is shown below. I've just started playing around with VBA a few days ago, so this is all sort of new to me. Any assistance as to what I'm doing wrong would be appreciated.
    Sub CopyPaste()
    Dim I As Integer
    I = 1
    If Cells(1, I).Value <> Range("A17").Value Then
    I = I + 1
    ElseIf Cells(1, I).Value = Range("A17").Value Then
    Range("A18:A20").Copy
    Cells(2, I).PasteSpecial
    End If
    End Sub
    Thanks

    Sample.xlsx
    Last edited by anthony_91; 08-02-2013 at 08:38 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro help with Data list sorted by date then add a month Heading in between the sections
    By Researcher007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2013, 03:57 PM
  2. Macro to filter based on column heading then copy and paste to new sheet
    By macattackr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2012, 05:14 PM
  3. Code Problem Macro to copy specific cell based on the heading it is next to.
    By Mush1138 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-09-2011, 12:07 PM
  4. macro to find text heading then select underlying data?
    By excelRookie06 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-07-2011, 12:31 PM
  5. Copy data from different files into 1 workbook under relevant column heading.
    By novice81 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-18-2009, 01:19 AM

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