Closed Thread
Results 1 to 3 of 3

VBA code Issue - offset

  1. #1
    Forum Contributor
    Join Date
    01-21-2010
    Location
    Glasgow
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    105

    VBA code Issue - offset

    Hi there,

    I am trying to get this to work but something is not right in the code but I don't know what can anone help?

    The code is Option Explicit
    'This also illustrates the method of referring to cells
    'by using "Shortcut Notation" where, for example,
    'Range("A1") can be written simply as [A1]
    '(Read the VBA Help files for more on this...)

    Sub PrintInvoice()
    Sheet1.[A1:J66].PrintOut
    PrintContinuation:
    Sheet7.[A1:J66].PrintOut
    Dim Response
    Response = MsgBox("Is there a continuation sheet?", _
    vbYesNo + vbQuestion, "Confirmation")
    If Response = vbNo Then
    FillSalesList
    NewInvoice
    NewContinuation
    Else
    GoTo PrintContinuation
    End If
    Sheet1.Unprotect
    'Increment the invoice number'
    [J3] = [J3] + 1
    Sheet1.Protect
    End Sub

    'This saves details of the invoice on another sheet
    Private Sub FillSalesList()
    With Sheets("Sales").Columns(1).Rows(65536).End(xlUp)
    .Offset(1, 0) = Sheet1.[J3]
    .Offset(1, 2) = Sheet1.[J5]
    .Offset(1, 3) = Sheet1.[J9]
    .Offset(1, 4) = Sheet7.[J55]
    .Offset(1, 5) = Sheet7.[J56]
    .Offset(1, 6) = Sheet7.[J57]
    .Offset(1, 7) = Sheet1.[J1]
    .Offset(1, 8) = Sheet1.[J16].Text
    End With
    End Sub

    'Clears the invoice sheet
    Sub NewInvoice()
    With Sheet1
    .Unprotect
    Cells.Locked = False
    [A19:I19, I1:I17, J3, I43:J45, I50:I54, B50:B54, J10:J14].Locked = True
    'Clear details of last sale
    [A20:J41, J5, J9, J16, B49, I49].ClearContents
    [B12].Select

    .Protect
    End With
    End Sub
    Sub NewContinuation()
    With Sheet7
    .Unprotect
    Cells.Locked = False
    [A11:J11, I1:I10, I55:J57].Locked = True
    'Clear details of last sale
    [A12:J53].ClearContents
    [B12].Select

    .Protect
    End With
    End Sub

    I've attached the spreadsheet. I want it to print the purchase oder, ask if there is a continuation sheet if yes print that sheet. Transfer PO number, Client, Supplier, Date and the totals from PO if only one sheet or contiuation sheet if there is one onto the sales sheet then clear the sheets increment the PO number

    I'm sure its not as confusing as I've made it.

    I appreciate anyones help!

    Thanks
    Libby
    Attached Files Attached Files
    Last edited by Libster78; 01-22-2010 at 01:08 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: HELP! VBA code not working

    Libster78, please note:

    a)

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.


    b)

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here


    Please amend both title & post content (tags) accordingly..... regards a) this was a point made to you on your previous thread.

    Please endeavour to familiarise yourself with the Forum Rules before posting further (and obviously adhere to them thereafter).

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VBA code Issue - offset

    Libster78, given the time passed and the fact that you've not adding tags and have now subsequently cross posted this on MrExcel I will close this thread.

    Should you choose to post here in future (we hope you do) please be sure to follow the Forum Rules to which you agree upon registration.

Closed 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