Consulting

Results 1 to 2 of 2

Thread: Help in VBA Coding (do while / loop until)

  1. #1

    Help in VBA Coding (do while / loop until)

    Hi All,

    Hope everyone are doing good, Am in need of your help.

    I have created a payroll application using some VBA and worksheet functions as well, everything is working fine, but I am getting struck in pay slip processing, for Payslip creation I created one sheet and used vlookup function, if I key in the employee number, all other particulars will update, and I have created a mail icon which converts that particular range to pdf and generates email, now its becoming very difficult for me to do the same action for all employees.

    So am looking where macro automatically runs and generate email for all at a time, below is the more details

    Ex:-
    Sheet name “payslip” in cell “A5” I need to update the employee number, I have the list of applicable employee numbers in sheet “Maillist” from “a2 to X (xldown / end)”, now I want to write a code where it works as
    1. Copy from sheet “Maillist” cell “a2” and paste in sheet “payslip” cell “A5” and then run the mailer code(converts in to pdf and generates email)
    2. Copy from sheet “Maillist” cell “a3” and paste in sheet “payslip” cell “A5” and then run the mailer code(generate email)
    3. Copy from sheet “Maillist” cell “a4” and paste in sheet “payslip” cell “A5” and then run the mailer code(generate email)
    .
    .
    .
    .
    .
    Copy from sheet “Maillist” cell “a100”(xldown) and paste in sheet “payslip” cell “A5” and then run the mailer code(generate email).


    I have the code which automatically convert particular range to pdf and generates email, can anyone help me to get the above code..

    Thanks in advance

    Regards,
    GV Reddy


  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    hi.

    try...

    [VBA]Dim wsMail As Worksheet, wsPSlip As Worksheet
    Dim i As Long, LastRow As Long

    Set wsMail = Worksheets("Maillist")
    Set wsPSlip = Worksheets("payslip")

    LastRow = wsMail.Range("A" & Rows.Count).End(xlUp).Row

    For i = 2 To LR
    wsPSlip.Range("A5").Value = wsMail.Range("A" & i).Value
    ' your mailing code here
    Next
    [/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •