+ Reply to Thread
Results 1 to 2 of 2

Copy to another sheet fails

  1. #1
    Ole
    Guest

    Copy to another sheet fails

    Hi NG,

    I have got following code, which were originally made for a
    workbook.beforeclose, now i have
    copied it to a commandbutton and it wont work any more?, it worked in
    "beforeclose" and it works
    if the pricelist file is open, here is some of the code:

    ""Private Sub CommandButton1_Click()
    Dim bClose As Boolean
    Dim bk As Workbook
    On Error Resume Next
    Set bk = Workbooks("pricelist_DK.xls") 'sætter prisliste som til copy
    On Error GoTo 0
    If bk Is Nothing Then
    bClose = True
    Set bk = Workbooks.Open("C:\prisliste_udskrift\pricelist_DK.xls") '
    åbner
    prisliste
    End If
    Worksheets(2).Range("B20").Value = "4" ' kopier 4 farver til antal farver
    Worksheets(2).Range("N47").Value = Worksheets(2).Range("R1").Value '
    sætter
    pris pr designskift til 4 frv pris
    bk.Worksheets(2).Range("D4").Value = _
    Worksheets(2).Range("C2").Value ' kopier kunde
    bk.Worksheets(2).Range("D5").Value = _
    Worksheets(2).Range("I2").Value ' kopier opgave
    bk.Worksheets(2).Range("D7").Value = _
    Worksheets(2).Range("B11").Value & " MM " ' kopier bredde
    bk.Worksheets(2).Range("D8").Value = _
    Worksheets(2).Range("B14").Value ' kopier afsnit
    bk.Worksheets(2).Range("C11").Value = "PRIS / " & _
    Worksheets(2).Range("B8").Value ' kopier salgsenhed
    bk.Worksheets(2).Range("D26").Value = _
    Worksheets(2).Range("B38").Value ' kopier Valuta
    bk.Worksheets(2).Range("D6").Value = _
    Format(Range("B47").Value) & " / " & Format(Range("B48").Value) '
    kopier
    folietype
    bk.Worksheets(2).Range("D9").Value = _
    Worksheets(2).Range("B23").Value & "%" ' kopier farvedækning
    bk.Worksheets(2).Range("C12").Value = _
    Worksheets(2).Range("E4").Value ' kopier Antal herfra og ned""

    When i run it, it opens the pricelist and copies some of it, but not
    nearly
    enough, i hope some one have
    an idea of what's wrong.

    Ole


    --
    Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
    Den har indtil videre sparet mig for at få 24 spam-mails.
    Betalende brugere får ikke denne besked i deres e-mails.
    Hent den gratis her: www.spamfighter.dk



  2. #2
    Ole
    Guest

    Re: Copy to another sheet fails

    Havent i given enough information or isen't there anybody there can help me.

    Ole


    "Ole" <[email protected]> skrev i en meddelelse
    news:[email protected]...
    > Hi NG,
    >
    > I have got following code, which were originally made for a
    > workbook.beforeclose, now i have
    > copied it to a commandbutton and it wont work any more?, it worked in
    > "beforeclose" and it works
    > if the pricelist file is open, here is some of the code:
    >
    > ""Private Sub CommandButton1_Click()
    > Dim bClose As Boolean
    > Dim bk As Workbook
    > On Error Resume Next
    > Set bk = Workbooks("pricelist_DK.xls") 'sætter prisliste som til copy
    > On Error GoTo 0
    > If bk Is Nothing Then
    > bClose = True
    > Set bk = Workbooks.Open("C:\prisliste_udskrift\pricelist_DK.xls") '
    > åbner
    > prisliste
    > End If
    > Worksheets(2).Range("B20").Value = "4" ' kopier 4 farver til antal farver
    > Worksheets(2).Range("N47").Value = Worksheets(2).Range("R1").Value '
    > sætter
    > pris pr designskift til 4 frv pris
    > bk.Worksheets(2).Range("D4").Value = _
    > Worksheets(2).Range("C2").Value ' kopier kunde
    > bk.Worksheets(2).Range("D5").Value = _
    > Worksheets(2).Range("I2").Value ' kopier opgave
    > bk.Worksheets(2).Range("D7").Value = _
    > Worksheets(2).Range("B11").Value & " MM " ' kopier bredde
    > bk.Worksheets(2).Range("D8").Value = _
    > Worksheets(2).Range("B14").Value ' kopier afsnit
    > bk.Worksheets(2).Range("C11").Value = "PRIS / " & _
    > Worksheets(2).Range("B8").Value ' kopier salgsenhed
    > bk.Worksheets(2).Range("D26").Value = _
    > Worksheets(2).Range("B38").Value ' kopier Valuta
    > bk.Worksheets(2).Range("D6").Value = _
    > Format(Range("B47").Value) & " / " & Format(Range("B48").Value) '
    > kopier
    > folietype
    > bk.Worksheets(2).Range("D9").Value = _
    > Worksheets(2).Range("B23").Value & "%" ' kopier farvedækning
    > bk.Worksheets(2).Range("C12").Value = _
    > Worksheets(2).Range("E4").Value ' kopier Antal herfra og ned""
    >
    > When i run it, it opens the pricelist and copies some of it, but not
    > nearly
    > enough, i hope some one have
    > an idea of what's wrong.
    >
    > Ole
    >
    >
    > --
    > Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
    > Den har indtil videre sparet mig for at få 24 spam-mails.
    > Betalende brugere får ikke denne besked i deres e-mails.
    > Hent den gratis her: www.spamfighter.dk
    >
    >




+ 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