Results 1 to 4 of 4
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Excel Macro (2003)

    Welcone to Woody's Lounge!

    You attached a Word document with your question in it, instead of a sample Excel workbook.

  2. #2
    New Lounger
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel Macro (2003)

    I am trying to create a macro to perform the following:- search for the column which has the same heading (e.g. May) as typed in to another cell (A4) which will change from month to month, then copy data from a range of cells (A5:A8) to cells in the same column as that month e.g. (J4:J7). I have attached a sample.

    Regards

    Bill
    Attached Files Attached Files

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Excel Macro (2003)

    OK, that's better. I assume that you want to copy the data in B5:B9 instead of the text in A5:A8. You can use the following macro for this:

    Sub CopyMonthData()
    Dim oCell As Range
    If Range("A4") = "" Then
    MsgBox "Please enter a month!", vbExclamation
    Exit Sub
    End If
    Set oCell = Range("G1:IV1").Find(What:=Range("A4"), _
    LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
    If oCell Is Nothing Then
    MsgBox "Month not found!", vbExclamation
    Else
    Range("B5:B9").Copy Destination:=oCell.Offset(3, 0)
    End If
    End Sub

  4. #4
    New Lounger
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel Macro (2003)

    Thanks Hans,

    It works perfectly - many thanks

    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •