+ Reply to Thread
Results 1 to 10 of 10

Macro to define a range of serial numbers in Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    08-10-2010
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Macro to define a range of serial numbers in Excel

    Good Day Forum Members

    I have a little query which I present to you all for a possible solution. I have an excel workbook with two sheets. First sheet is named “Data” and second is named “Deposit Slip”.

    I have a few columns in “Data” in which the details of various banking instruments are input. Column A in “Data” is of serial number whereby every new entry is given a numeric progressive serial number e.g. 5431, 5432, 5433 and so forth.

    “Deposit Slip” consists of a bank’s replica of a pay-in slip in which the information from “Data” is gathered using various formulae including VLOOKUP etc. The focal point of all this is the serial number which allows for the data sorting, selection and displaying information from “Data” to “Deposit Slip”.

    Problem:
    Now the problem is that, everyday almost 50 new entries are made in “Data” and then all the serial numbers are needed to be typed in one be one in “Deposit Slip” and print out is taken after each and every input of serial number in cell 4 of column AC of “Deposit Slip”.

    Example:
    New entries made in “Data” from serial number 5450 to serial number 5500. Now, I need to input one by one the serial number in Cell 4 of Column AC of “Deposit Slip” so that the formulae will pick up and display information in “Deposit Slip” and then I will print out the sheet. It means that I have to input 50 serial numbers and press print 50 times.

    Requirement:
    I wish to define a range of serial numbers in “Deposit Slip” like FROM 5450 TO 5500 so that I had to input the range only and all 50 different pay in slips are printed out with a single command. I wish to have macro for that. Unfortunately, I have no expertise in recording macros. Any help will be genuinely appreciated.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to define a range of serial numbers in Excel

    Attach an example workbook
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    08-10-2010
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro to define a range of serial numbers in Excel

    Hi

    I am attaching a sample file for easy reference in perusal of my earlier post.

    Regards
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-10-2010
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Angry Re: Macro to define a range of serial numbers in Excel

    Dear Forum Members

    I have also uploaded a sample worksheet and have posted my problem as well. I would appreciate help from all of you.

    Regards

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to define a range of serial numbers in Excel

    Shouldn't the account number change?

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to define a range of serial numbers in Excel

    This will change the Slip Number & print the sheet using the numbers entered in the cells named

    StartPrint
    EndWith

    See attached

    Option Explicit
    
    Private Sub CommandButton1_Click()
    Dim lSlip As Long
    Dim i As Integer
    
    lSlip = Range("StartFrom").Value
    Do Until lSlip = Range("EndWith").Value
    With Sheet2
    .Range("K2").Value = lSlip
    .PrintPreview ' <-use for checkin
    '.PrintOut     ' <- use for printing
    lSlip = lSlip + 1
    End With
    Loop
    End Sub]
    Attached Files Attached Files

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro to define a range of serial numbers in Excel

    In sheet "Data': select cells A11:A12.
    Drag down this selection further in column A, using the 'cross' on the right-undercorner of cell A12.

  8. #8
    Registered User
    Join Date
    08-10-2010
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Question Re: Macro to define a range of serial numbers in Excel

    Dear Roy

    Thank you for your help. But I fear this is not what I was hoping for. Maybe I am unable to get my point across clearly. I am attaching the modified worksheet for your perusal.

    All I require is as follows:

    a) I input a serial number that starts the range in Cell K2 of sheet named "Deposit Slip"
    b) I input a serial number that ends the range in Cell K5 of sheet named "Deposit Slip"
    c) The information in sheet named "Deposit Slip" changes when the serial number in Cell K2 changes.
    d) I require a macro that changes the serial number, one by one, in Cell K2 upto the serial number mentioned in cell K5 and subsequently prints out the sheet named "Deposit Slip" for every change in the serial number (within the range defined respectively in Cell K2 and Cell K5) all by simply running that macro. I do not wish to have a print preview.

    Hope it clarifies the matter.
    Attached Files Attached Files

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to define a range of serial numbers in Excel

    The code is what you want, you can change the cells that you enter the run in & the line of code that runs print preview is there for testing, when satisfied remove & use Printout as i said in the code

  10. #10
    Registered User
    Join Date
    08-10-2010
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro to define a range of serial numbers in Excel

    Thanks Roy for your assistance. I really appreciate it. Just one simple question more. How do I copy your macro with the command button in your file to use it with the original file? I had attached a sample worksheet. I wish to use your code in a separate worksheet that has identical sheets and almost identical data.

    Awaiting your response.
    Regards

+ 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