+ Reply to Thread
Results 1 to 11 of 11

copy and paste code problem

  1. #1
    bigdaddy3
    Guest

    copy and paste code problem

    can somone tell me why the attached code will not work it works for the first
    range only but when others added it fails also how do you clear outline of
    copied cells, i used range ("D9").Select but no good.Could someone help
    please

    -- Private Sub Workbook_Open()
    Workbooks("Staff Details").Activate
    Range("I4:I10")("C4")("C9")("G9").Select
    Selection.Copy
    Worksheets("Payslip").Activate
    Range("B2:B8", "C11", "K11", "K12").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False

    Range("D9").Select
    End Sub
    BD3

  2. #2
    R.VENKATARAMAN
    Guest

    Re: copy and paste code problem

    if I understand correctly multicple slection cannot be copied andpasted
    only contiguous cells can be copied like this
    so one by one copy
    e.g. worksheets("staffdetails").range("I4:I10").copy
    worksheets("payslip").range("B2").pastespecial ETC ETC
    worksheets("staffdetails").range("c4").copy
    worksheets("payslip").range("C11").pastespecial ETC ETC

    simlarly other non contiguous cells.

    try this


    "bigdaddy3" <[email protected]> wrote in message
    news:[email protected]...
    > can somone tell me why the attached code will not work it works for the

    first
    > range only but when others added it fails also how do you clear outline of
    > copied cells, i used range ("D9").Select but no good.Could someone help
    > please
    >
    > -- Private Sub Workbook_Open()
    > Workbooks("Staff Details").Activate
    > Range("I4:I10")("C4")("C9")("G9").Select
    > Selection.Copy
    > Worksheets("Payslip").Activate
    > Range("B2:B8", "C11", "K11", "K12").Select
    > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > SkipBlanks _
    > :=False, Transpose:=False
    >
    > Range("D9").Select
    > End Sub
    > BD3




  3. #3
    Duke Carey
    Guest

    RE: copy and paste code problem

    Do you really mean WORKBOOKS(Staff Details")? or should that be WORKSHEETS?

    Maybe this will work for you
    Private Sub Workbook_Open()
    Dim wsDetails As Worksheet
    Dim wsSlips As Worksheet

    Set wsDetails = Worksheets("Staff Details")
    Set wsSlips = Worksheets("Payslips")

    With wsDetails
    .Range("I4:I10").Copy
    wsSlips.Range("B2:B8").PasteSpecial xlPasteValues

    .Range("C4").Copy
    wsSlips.Range("C11").PasteSpecial xlPasteValues

    .Range("C9").Copy
    wsSlips.Range("K11").PasteSpecial xlPasteValues

    .Range("G9").Copy
    wsSlips.Range("K12").PasteSpecial xlPasteValues

    End With

    End Sub


    "bigdaddy3" wrote:

    > can somone tell me why the attached code will not work it works for the first
    > range only but when others added it fails also how do you clear outline of
    > copied cells, i used range ("D9").Select but no good.Could someone help
    > please
    >
    > -- Private Sub Workbook_Open()
    > Workbooks("Staff Details").Activate
    > Range("I4:I10")("C4")("C9")("G9").Select
    > Selection.Copy
    > Worksheets("Payslip").Activate
    > Range("B2:B8", "C11", "K11", "K12").Select
    > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > SkipBlanks _
    > :=False, Transpose:=False
    >
    > Range("D9").Select
    > End Sub
    > BD3


  4. #4
    bigdaddy3
    Guest

    RE: copy and paste code problem

    Hi Duke, it was workbooks named Staff details and what about the last point i
    mentioned about clearing the outline when finished,Thanks for your reply
    --
    BD3


    "Duke Carey" wrote:

    > Do you really mean WORKBOOKS(Staff Details")? or should that be WORKSHEETS?
    >
    > Maybe this will work for you
    > Private Sub Workbook_Open()
    > Dim wsDetails As Worksheet
    > Dim wsSlips As Worksheet
    >
    > Set wsDetails = Worksheets("Staff Details")
    > Set wsSlips = Worksheets("Payslips")
    >
    > With wsDetails
    > .Range("I4:I10").Copy
    > wsSlips.Range("B2:B8").PasteSpecial xlPasteValues
    >
    > .Range("C4").Copy
    > wsSlips.Range("C11").PasteSpecial xlPasteValues
    >
    > .Range("C9").Copy
    > wsSlips.Range("K11").PasteSpecial xlPasteValues
    >
    > .Range("G9").Copy
    > wsSlips.Range("K12").PasteSpecial xlPasteValues
    >
    > End With
    >
    > End Sub
    >
    >
    > "bigdaddy3" wrote:
    >
    > > can somone tell me why the attached code will not work it works for the first
    > > range only but when others added it fails also how do you clear outline of
    > > copied cells, i used range ("D9").Select but no good.Could someone help
    > > please
    > >
    > > -- Private Sub Workbook_Open()
    > > Workbooks("Staff Details").Activate
    > > Range("I4:I10")("C4")("C9")("G9").Select
    > > Selection.Copy
    > > Worksheets("Payslip").Activate
    > > Range("B2:B8", "C11", "K11", "K12").Select
    > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > SkipBlanks _
    > > :=False, Transpose:=False
    > >
    > > Range("D9").Select
    > > End Sub
    > > BD3


  5. #5
    Duke Carey
    Guest

    RE: copy and paste code problem

    Application.CutCopyMode = False

    will get rid of the range border that indicates you have copied that range

    The code you had in your original post will copy data from whatever sheet in
    the Staff Details workbook is active when you open the workbook containing
    the code. It'd be better to set a worksheet variable to the specific sheet
    you want to use as the source, as my sample code did

    "bigdaddy3" wrote:

    > Hi Duke, it was workbooks named Staff details and what about the last point i
    > mentioned about clearing the outline when finished,Thanks for your reply
    > --
    > BD3
    >
    >
    > "Duke Carey" wrote:
    >
    > > Do you really mean WORKBOOKS(Staff Details")? or should that be WORKSHEETS?
    > >
    > > Maybe this will work for you
    > > Private Sub Workbook_Open()
    > > Dim wsDetails As Worksheet
    > > Dim wsSlips As Worksheet
    > >
    > > Set wsDetails = Worksheets("Staff Details")
    > > Set wsSlips = Worksheets("Payslips")
    > >
    > > With wsDetails
    > > .Range("I4:I10").Copy
    > > wsSlips.Range("B2:B8").PasteSpecial xlPasteValues
    > >
    > > .Range("C4").Copy
    > > wsSlips.Range("C11").PasteSpecial xlPasteValues
    > >
    > > .Range("C9").Copy
    > > wsSlips.Range("K11").PasteSpecial xlPasteValues
    > >
    > > .Range("G9").Copy
    > > wsSlips.Range("K12").PasteSpecial xlPasteValues
    > >
    > > End With
    > >
    > > End Sub
    > >
    > >
    > > "bigdaddy3" wrote:
    > >
    > > > can somone tell me why the attached code will not work it works for the first
    > > > range only but when others added it fails also how do you clear outline of
    > > > copied cells, i used range ("D9").Select but no good.Could someone help
    > > > please
    > > >
    > > > -- Private Sub Workbook_Open()
    > > > Workbooks("Staff Details").Activate
    > > > Range("I4:I10")("C4")("C9")("G9").Select
    > > > Selection.Copy
    > > > Worksheets("Payslip").Activate
    > > > Range("B2:B8", "C11", "K11", "K12").Select
    > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > SkipBlanks _
    > > > :=False, Transpose:=False
    > > >
    > > > Range("D9").Select
    > > > End Sub
    > > > BD3


  6. #6
    bigdaddy3
    Guest

    RE: copy and paste code problem

    Duke, thanks for that ill try it
    --
    BD3


    "Duke Carey" wrote:

    > Application.CutCopyMode = False
    >
    > will get rid of the range border that indicates you have copied that range
    >
    > The code you had in your original post will copy data from whatever sheet in
    > the Staff Details workbook is active when you open the workbook containing
    > the code. It'd be better to set a worksheet variable to the specific sheet
    > you want to use as the source, as my sample code did
    >
    > "bigdaddy3" wrote:
    >
    > > Hi Duke, it was workbooks named Staff details and what about the last point i
    > > mentioned about clearing the outline when finished,Thanks for your reply
    > > --
    > > BD3
    > >
    > >
    > > "Duke Carey" wrote:
    > >
    > > > Do you really mean WORKBOOKS(Staff Details")? or should that be WORKSHEETS?
    > > >
    > > > Maybe this will work for you
    > > > Private Sub Workbook_Open()
    > > > Dim wsDetails As Worksheet
    > > > Dim wsSlips As Worksheet
    > > >
    > > > Set wsDetails = Worksheets("Staff Details")
    > > > Set wsSlips = Worksheets("Payslips")
    > > >
    > > > With wsDetails
    > > > .Range("I4:I10").Copy
    > > > wsSlips.Range("B2:B8").PasteSpecial xlPasteValues
    > > >
    > > > .Range("C4").Copy
    > > > wsSlips.Range("C11").PasteSpecial xlPasteValues
    > > >
    > > > .Range("C9").Copy
    > > > wsSlips.Range("K11").PasteSpecial xlPasteValues
    > > >
    > > > .Range("G9").Copy
    > > > wsSlips.Range("K12").PasteSpecial xlPasteValues
    > > >
    > > > End With
    > > >
    > > > End Sub
    > > >
    > > >
    > > > "bigdaddy3" wrote:
    > > >
    > > > > can somone tell me why the attached code will not work it works for the first
    > > > > range only but when others added it fails also how do you clear outline of
    > > > > copied cells, i used range ("D9").Select but no good.Could someone help
    > > > > please
    > > > >
    > > > > -- Private Sub Workbook_Open()
    > > > > Workbooks("Staff Details").Activate
    > > > > Range("I4:I10")("C4")("C9")("G9").Select
    > > > > Selection.Copy
    > > > > Worksheets("Payslip").Activate
    > > > > Range("B2:B8", "C11", "K11", "K12").Select
    > > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > > SkipBlanks _
    > > > > :=False, Transpose:=False
    > > > >
    > > > > Range("D9").Select
    > > > > End Sub
    > > > > BD3


  7. #7
    bigdaddy3
    Guest

    RE: copy and paste code problem

    Hi Duke, i tried that but it doesnt work it brings up runtime error 9
    subscript out of range ,but the 2 workbooks in question 1 is open and the
    other payslip is opened by a button calling payslip thats when your code
    copies and pastes but as i say it doesnt any toughts
    --
    BD3


    "Duke Carey" wrote:

    > Application.CutCopyMode = False
    >
    > will get rid of the range border that indicates you have copied that range
    >
    > The code you had in your original post will copy data from whatever sheet in
    > the Staff Details workbook is active when you open the workbook containing
    > the code. It'd be better to set a worksheet variable to the specific sheet
    > you want to use as the source, as my sample code did
    >
    > "bigdaddy3" wrote:
    >
    > > Hi Duke, it was workbooks named Staff details and what about the last point i
    > > mentioned about clearing the outline when finished,Thanks for your reply
    > > --
    > > BD3
    > >
    > >
    > > "Duke Carey" wrote:
    > >
    > > > Do you really mean WORKBOOKS(Staff Details")? or should that be WORKSHEETS?
    > > >
    > > > Maybe this will work for you
    > > > Private Sub Workbook_Open()
    > > > Dim wsDetails As Worksheet
    > > > Dim wsSlips As Worksheet
    > > >
    > > > Set wsDetails = Worksheets("Staff Details")
    > > > Set wsSlips = Worksheets("Payslips")
    > > >
    > > > With wsDetails
    > > > .Range("I4:I10").Copy
    > > > wsSlips.Range("B2:B8").PasteSpecial xlPasteValues
    > > >
    > > > .Range("C4").Copy
    > > > wsSlips.Range("C11").PasteSpecial xlPasteValues
    > > >
    > > > .Range("C9").Copy
    > > > wsSlips.Range("K11").PasteSpecial xlPasteValues
    > > >
    > > > .Range("G9").Copy
    > > > wsSlips.Range("K12").PasteSpecial xlPasteValues
    > > >
    > > > End With
    > > >
    > > > End Sub
    > > >
    > > >
    > > > "bigdaddy3" wrote:
    > > >
    > > > > can somone tell me why the attached code will not work it works for the first
    > > > > range only but when others added it fails also how do you clear outline of
    > > > > copied cells, i used range ("D9").Select but no good.Could someone help
    > > > > please
    > > > >
    > > > > -- Private Sub Workbook_Open()
    > > > > Workbooks("Staff Details").Activate
    > > > > Range("I4:I10")("C4")("C9")("G9").Select
    > > > > Selection.Copy
    > > > > Worksheets("Payslip").Activate
    > > > > Range("B2:B8", "C11", "K11", "K12").Select
    > > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > > SkipBlanks _
    > > > > :=False, Transpose:=False
    > > > >
    > > > > Range("D9").Select
    > > > > End Sub
    > > > > BD3


  8. #8
    Duke Carey
    Guest

    RE: copy and paste code problem

    What did you try? It isn't at all clear.

    Perhaps posting a description of what you are trying to accomplish, along
    with the code that doesn't work, would allow somebody to help you without so
    much guesswork involved.

    "bigdaddy3" wrote:

    > Hi Duke, i tried that but it doesnt work it brings up runtime error 9
    > subscript out of range ,but the 2 workbooks in question 1 is open and the
    > other payslip is opened by a button calling payslip thats when your code
    > copies and pastes but as i say it doesnt any toughts
    > --
    > BD3
    >
    >
    > "Duke Carey" wrote:
    >
    > > Application.CutCopyMode = False
    > >
    > > will get rid of the range border that indicates you have copied that range
    > >
    > > The code you had in your original post will copy data from whatever sheet in
    > > the Staff Details workbook is active when you open the workbook containing
    > > the code. It'd be better to set a worksheet variable to the specific sheet
    > > you want to use as the source, as my sample code did
    > >
    > > "bigdaddy3" wrote:
    > >
    > > > Hi Duke, it was workbooks named Staff details and what about the last point i
    > > > mentioned about clearing the outline when finished,Thanks for your reply
    > > > --
    > > > BD3
    > > >
    > > >
    > > > "Duke Carey" wrote:
    > > >
    > > > > Do you really mean WORKBOOKS(Staff Details")? or should that be WORKSHEETS?
    > > > >
    > > > > Maybe this will work for you
    > > > > Private Sub Workbook_Open()
    > > > > Dim wsDetails As Worksheet
    > > > > Dim wsSlips As Worksheet
    > > > >
    > > > > Set wsDetails = Worksheets("Staff Details")
    > > > > Set wsSlips = Worksheets("Payslips")
    > > > >
    > > > > With wsDetails
    > > > > .Range("I4:I10").Copy
    > > > > wsSlips.Range("B2:B8").PasteSpecial xlPasteValues
    > > > >
    > > > > .Range("C4").Copy
    > > > > wsSlips.Range("C11").PasteSpecial xlPasteValues
    > > > >
    > > > > .Range("C9").Copy
    > > > > wsSlips.Range("K11").PasteSpecial xlPasteValues
    > > > >
    > > > > .Range("G9").Copy
    > > > > wsSlips.Range("K12").PasteSpecial xlPasteValues
    > > > >
    > > > > End With
    > > > >
    > > > > End Sub
    > > > >
    > > > >
    > > > > "bigdaddy3" wrote:
    > > > >
    > > > > > can somone tell me why the attached code will not work it works for the first
    > > > > > range only but when others added it fails also how do you clear outline of
    > > > > > copied cells, i used range ("D9").Select but no good.Could someone help
    > > > > > please
    > > > > >
    > > > > > -- Private Sub Workbook_Open()
    > > > > > Workbooks("Staff Details").Activate
    > > > > > Range("I4:I10")("C4")("C9")("G9").Select
    > > > > > Selection.Copy
    > > > > > Worksheets("Payslip").Activate
    > > > > > Range("B2:B8", "C11", "K11", "K12").Select
    > > > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > > > SkipBlanks _
    > > > > > :=False, Transpose:=False
    > > > > >
    > > > > > Range("D9").Select
    > > > > > End Sub
    > > > > > BD3


  9. #9
    bigdaddy3
    Guest

    RE: copy and paste code problem

    Hi Duke,hows this i have a workbook open (staff Details) on that there are
    various buttons 1 of which calls up a workbook (Wages) with an active
    worksheet (Payslip) onto which i need to copy certain details from the
    original workbook (Staff Details). the ranges to be copied from are (I4:I10)
    ("C4") ("C9") ("G9") they then have to be pasted to("B2:B8", "C11", "K11",
    "K12") in that order they are all seperate items,does that make more sense
    --
    BD3
    Private Sub Workbook_Open()
    Workbooks("Staff Details").Activate
    Range("I4:I10")("C4")("C9")("G9").Select
    Selection.Copy
    Worksheets("Payslip").Activate
    Range("B2:B8", "C11", "K11", "K12").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False

    Range("D9").Select
    End Sub



    "Duke Carey" wrote:

    > What did you try? It isn't at all clear.
    >
    > Perhaps posting a description of what you are trying to accomplish, along
    > with the code that doesn't work, would allow somebody to help you without so
    > much guesswork involved.
    >
    > "bigdaddy3" wrote:
    >
    > > Hi Duke, i tried that but it doesnt work it brings up runtime error 9
    > > subscript out of range ,but the 2 workbooks in question 1 is open and the
    > > other payslip is opened by a button calling payslip thats when your code
    > > copies and pastes but as i say it doesnt any toughts
    > > --
    > > BD3
    > >
    > >
    > > "Duke Carey" wrote:
    > >
    > > > Application.CutCopyMode = False
    > > >
    > > > will get rid of the range border that indicates you have copied that range
    > > >
    > > > The code you had in your original post will copy data from whatever sheet in
    > > > the Staff Details workbook is active when you open the workbook containing
    > > > the code. It'd be better to set a worksheet variable to the specific sheet
    > > > you want to use as the source, as my sample code did
    > > >
    > > > "bigdaddy3" wrote:
    > > >
    > > > > Hi Duke, it was workbooks named Staff details and what about the last point i
    > > > > mentioned about clearing the outline when finished,Thanks for your reply
    > > > > --
    > > > > BD3
    > > > >
    > > > >
    > > > > "Duke Carey" wrote:
    > > > >
    > > > > > Do you really mean WORKBOOKS(Staff Details")? or should that be WORKSHEETS?
    > > > > >
    > > > > > Maybe this will work for you
    > > > > > Private Sub Workbook_Open()
    > > > > > Dim wsDetails As Worksheet
    > > > > > Dim wsSlips As Worksheet
    > > > > >
    > > > > > Set wsDetails = Worksheets("Staff Details")
    > > > > > Set wsSlips = Worksheets("Payslips")
    > > > > >
    > > > > > With wsDetails
    > > > > > .Range("I4:I10").Copy
    > > > > > wsSlips.Range("B2:B8").PasteSpecial xlPasteValues
    > > > > >
    > > > > > .Range("C4").Copy
    > > > > > wsSlips.Range("C11").PasteSpecial xlPasteValues
    > > > > >
    > > > > > .Range("C9").Copy
    > > > > > wsSlips.Range("K11").PasteSpecial xlPasteValues
    > > > > >
    > > > > > .Range("G9").Copy
    > > > > > wsSlips.Range("K12").PasteSpecial xlPasteValues
    > > > > >
    > > > > > End With
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > >
    > > > > > "bigdaddy3" wrote:
    > > > > >
    > > > > > > can somone tell me why the attached code will not work it works for the first
    > > > > > > range only but when others added it fails also how do you clear outline of
    > > > > > > copied cells, i used range ("D9").Select but no good.Could someone help
    > > > > > > please
    > > > > > >
    > > > > > > -- Private Sub Workbook_Open()
    > > > > > > Workbooks("Staff Details").Activate
    > > > > > > Range("I4:I10")("C4")("C9")("G9").Select
    > > > > > > Selection.Copy
    > > > > > > Worksheets("Payslip").Activate
    > > > > > > Range("B2:B8", "C11", "K11", "K12").Select
    > > > > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > > > > SkipBlanks _
    > > > > > > :=False, Transpose:=False
    > > > > > >
    > > > > > > Range("D9").Select
    > > > > > > End Sub
    > > > > > > BD3


  10. #10
    Duke Carey
    Guest

    RE: copy and paste code problem

    Put this in your Staff Details workbook & attach it to a button that you
    click on after you've opened the wages.xls file

    Sub CopyPayslipData()
    Dim wsDetails As Worksheet
    Dim wsSlips As Worksheet

    Set wsDetails = activesheet
    Set wsSlips = workbooks("Wages.xls").Worksheets("Payslips")

    With wsDetails
    ..Range("I4:I10").Copy
    wsSlips.Range("B2:B8").PasteSpecial xlPasteValues

    ..Range("C4").Copy
    wsSlips.Range("C11").PasteSpecial xlPasteValues

    ..Range("C9").Copy
    wsSlips.Range("K11").PasteSpecial xlPasteValues

    ..Range("G9").Copy
    wsSlips.Range("K12").PasteSpecial xlPasteValues

    End With

    End Sub

    "bigdaddy3" wrote:

    > Hi Duke,hows this i have a workbook open (staff Details) on that there are
    > various buttons 1 of which calls up a workbook (Wages) with an active
    > worksheet (Payslip) onto which i need to copy certain details from the
    > original workbook (Staff Details). the ranges to be copied from are (I4:I10)
    > ("C4") ("C9") ("G9") they then have to be pasted to("B2:B8", "C11", "K11",
    > "K12") in that order they are all seperate items,does that make more sense
    > --
    > BD3
    > Private Sub Workbook_Open()
    > Workbooks("Staff Details").Activate
    > Range("I4:I10")("C4")("C9")("G9").Select
    > Selection.Copy
    > Worksheets("Payslip").Activate
    > Range("B2:B8", "C11", "K11", "K12").Select
    > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > SkipBlanks _
    > :=False, Transpose:=False
    >
    > Range("D9").Select
    > End Sub
    >


  11. #11
    bigdaddy3
    Guest

    RE: copy and paste code problem

    Hi Duke,since i last spoke i have used the attached code nd it all copied
    perfect when the payslip workbook opened but it seemed to blink 4 times am i
    on the right track as i would rather not use another button but could i use
    your code with a macro in the open event or can my code be simplified as far
    as just one event


    Workbooks("Staff Details").Activate
    Range("I4:I10").Select
    Selection.Copy
    Worksheets("Payslip").Activate
    Range("B2:B8").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False

    Workbooks("Staff Details").Activate
    Range("C4").Select
    Selection.Copy
    Worksheets("Payslip").Activate
    Range("C11").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False

    Workbooks("Staff Details").Activate
    Range("C9").Select
    Selection.Copy
    Worksheets("Payslip").Activate
    Range("K11").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False

    Workbooks("Staff Details").Activate
    Range("G9").Select
    Selection.Copy
    Worksheets("Payslip").Activate
    Range("K12").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False

    --
    BD3


    "Duke Carey" wrote:

    > Put this in your Staff Details workbook & attach it to a button that you
    > click on after you've opened the wages.xls file
    >
    > Sub CopyPayslipData()
    > Dim wsDetails As Worksheet
    > Dim wsSlips As Worksheet
    >
    > Set wsDetails = activesheet
    > Set wsSlips = workbooks("Wages.xls").Worksheets("Payslips")
    >
    > With wsDetails
    > .Range("I4:I10").Copy
    > wsSlips.Range("B2:B8").PasteSpecial xlPasteValues
    >
    > .Range("C4").Copy
    > wsSlips.Range("C11").PasteSpecial xlPasteValues
    >
    > .Range("C9").Copy
    > wsSlips.Range("K11").PasteSpecial xlPasteValues
    >
    > .Range("G9").Copy
    > wsSlips.Range("K12").PasteSpecial xlPasteValues
    >
    > End With
    >
    > End Sub
    >
    > "bigdaddy3" wrote:
    >
    > > Hi Duke,hows this i have a workbook open (staff Details) on that there are
    > > various buttons 1 of which calls up a workbook (Wages) with an active
    > > worksheet (Payslip) onto which i need to copy certain details from the
    > > original workbook (Staff Details). the ranges to be copied from are (I4:I10)
    > > ("C4") ("C9") ("G9") they then have to be pasted to("B2:B8", "C11", "K11",
    > > "K12") in that order they are all seperate items,does that make more sense
    > > --
    > > BD3
    > > Private Sub Workbook_Open()
    > > Workbooks("Staff Details").Activate
    > > Range("I4:I10")("C4")("C9")("G9").Select
    > > Selection.Copy
    > > Worksheets("Payslip").Activate
    > > Range("B2:B8", "C11", "K11", "K12").Select
    > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > SkipBlanks _
    > > :=False, Transpose:=False
    > >
    > > Range("D9").Select
    > > End Sub
    > >


+ 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