+ Reply to Thread
Results 1 to 4 of 4

Thread: Help, Code won't work and I have no clue

  1. #1
    Lost and Looking for Help
    Guest

    Help, Code won't work and I have no clue

    I am trying to take data from from a Sheet called %Efficiency and past it
    into a sheet Called MMM11. I the problem is in my selecion of the the range
    to copy. I don't know why it won't work. The only problem that i was
    thinking it could be is that cells A1-C1 do not contain a date where as the
    rest of the row 1 does. I don't know though please help.

    Dim X As Integer, Y As Integer
    For X = 1 To 100
    If Cells(1, X) < Date Then Y = X
    Next
    Sheets("%Efficiency").Select
    Selection.Range(Cells(1, Y + 1), Cells(3, Y - 19)).Select
    Selection.Copy
    Sheets("MMM11").Select
    ActiveSheet.Range("B19").Select
    Selection.PasteSpecial (xlPasteValuesAndNumberFormats)

  2. #2
    Bob Phillips
    Guest

    Re: Help, Code won't work and I have no clue

    Not tested, but probably

    Dim X As Integer, Y As Integer
    For X = 1 To 100
    If Cells(1, X) < Date Then Y = X
    Next
    Sheets("%Efficiency").Select
    Range(Cells(1, Y + 1), Cells(3, Y - 19)).Copy
    Sheets("MMM11").Select
    ActiveSheet.Range("B19").Select
    Selection.PasteSpecial (xlPasteValuesAndNumberFormats)

    --
    HTH

    Bob Phillips

    (remove xxx from email address if mailing direct)

    "Lost and Looking for Help"
    <LostandLookingforHelp@discussions.microsoft.com> wrote in message
    news:595C9D07-D04B-42E5-BA2C-D03BE7A3B322@microsoft.com...
    > I am trying to take data from from a Sheet called %Efficiency and past it
    > into a sheet Called MMM11. I the problem is in my selecion of the the

    range
    > to copy. I don't know why it won't work. The only problem that i was
    > thinking it could be is that cells A1-C1 do not contain a date where as

    the
    > rest of the row 1 does. I don't know though please help.
    >
    > Dim X As Integer, Y As Integer
    > For X = 1 To 100
    > If Cells(1, X) < Date Then Y = X
    > Next
    > Sheets("%Efficiency").Select
    > Selection.Range(Cells(1, Y + 1), Cells(3, Y - 19)).Select
    > Selection.Copy
    > Sheets("MMM11").Select
    > ActiveSheet.Range("B19").Select
    > Selection.PasteSpecial (xlPasteValuesAndNumberFormats)




  3. #3
    Tom Ogilvy
    Guest

    RE: Help, Code won't work and I have no clue

    when you do select.Range

    then you are anchoring your range to the currently active cell and
    offsetting from there.

    so (as an example)
    Range("Z1").Select
    Selection.Range("A1:C1").copy

    would copy Z1:AB1

    I doubt that is your intent. Try:

    Dim X As Integer, Y As Integer
    With Sheets("%Efficiency")
    For X = 1 To 100
    If .Cells(1, X) < Date Then
    Y = X
    end if
    Next
    .Range(.Cells(1, Y + 1), .Cells(3, Y - 19)).Copy
    End With
    Sheets("MMM11").Range("B19").PasteSpecial _
    xlPasteValuesAndNumberFormats
    --
    Regards,
    Tom Ogilvy



    "Lost and Looking for Help" wrote:

    > I am trying to take data from from a Sheet called %Efficiency and past it
    > into a sheet Called MMM11. I the problem is in my selecion of the the range
    > to copy. I don't know why it won't work. The only problem that i was
    > thinking it could be is that cells A1-C1 do not contain a date where as the
    > rest of the row 1 does. I don't know though please help.
    >
    > Dim X As Integer, Y As Integer
    > For X = 1 To 100
    > If Cells(1, X) < Date Then Y = X
    > Next
    > Sheets("%Efficiency").Select
    > Selection.Range(Cells(1, Y + 1), Cells(3, Y - 19)).Select
    > Selection.Copy
    > Sheets("MMM11").Select
    > ActiveSheet.Range("B19").Select
    > Selection.PasteSpecial (xlPasteValuesAndNumberFormats)


  4. #4
    Don Guillett
    Guest

    Re: Help, Code won't work and I have no clue

    I don't understand this part. If on sheet %efficiency you can delete
    "Sheets("%Efficiency")."
    For X = 1 To 100
    If Cells(1, X) < Date Then Y = X
    Next
    ======maybe

    y=cells(1,256).end(xltoleft).column
    'then withOUT selections
    Sheets("%Efficiency").Range(Cells(1, Y + 1), Cells(3, Y - 19)).Copy
    Sheets("MMM11").Range("B19").PasteSpecial (xlPasteValuesAndNumberFormats)

    --
    Don Guillett
    SalesAid Software
    dguillett1@austin.rr.com
    "Lost and Looking for Help"
    <LostandLookingforHelp@discussions.microsoft.com> wrote in message
    news:595C9D07-D04B-42E5-BA2C-D03BE7A3B322@microsoft.com...
    >I am trying to take data from from a Sheet called %Efficiency and past it
    > into a sheet Called MMM11. I the problem is in my selecion of the the
    > range
    > to copy. I don't know why it won't work. The only problem that i was
    > thinking it could be is that cells A1-C1 do not contain a date where as
    > the
    > rest of the row 1 does. I don't know though please help.
    >
    > Dim X As Integer, Y As Integer
    > For X = 1 To 100
    > If Cells(1, X) < Date Then Y = X
    > Next
    > Sheets("%Efficiency").Select
    > Selection.Range(Cells(1, Y + 1), Cells(3, Y - 19)).Select
    > Selection.Copy
    > Sheets("MMM11").Select
    > ActiveSheet.Range("B19").Select
    > Selection.PasteSpecial (xlPasteValuesAndNumberFormats)




+ 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.2.0