+ Reply to Thread
Results 1 to 5 of 5

Copy the last specific not null row to the next row with formulas

  1. #1
    Registered User
    Join Date
    11-05-2011
    Location
    cebu
    MS-Off Ver
    Excel 2003
    Posts
    7

    Copy the last specific not null row to the next row with formulas

    please help,
    i need a macro to copy a specific columns (A to F) and the last not null row to the next row with formulas, its like copy a1 to a2 but a1 have the value of PO.01 and i need to increment it to PO.02. while the other columns are formulas and need to be copied. attached is my sample file

    thanks,
    Attached Files Attached Files
    Last edited by nefkho; 03-20-2012 at 01:25 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: help i need a macro to copy the last specific not null row to the next row with formul

    here you go:
    It will work once you type a value in column "B".
    I have also attached the workbook with the code in it.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Kelshaer; 03-20-2012 at 11:22 AM.
    Regards,
    Khaled Elshaer
    www.BIMcentre.com

    Remember To Do the Following....
    1. Thank those who have helped you by clicking the Star below their post.
    2. Mark your post SOLVED if it has been answered satisfactorily:
    • Select Thread Tools (on top of your 1st post)
    • Select Mark this thread as Solved

  3. #3
    Registered User
    Join Date
    11-05-2011
    Location
    cebu
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: help i need a macro to copy the last specific not null row to the next row with formul

    thanks, will test later.

  4. #4
    Registered User
    Join Date
    11-05-2011
    Location
    cebu
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Copy the last specific not null row to the next row with formulas

    it works no w i need to call a procedure and inserted it before the END SUB, the procedure will copy from a hidden sheet as my template and name the sheet from the value of column A, and it doesnt work the renaming dont work. please check my code.
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Column <> 2 Then Exit Sub
    Dim p As Byte
    Dim r As Long
    Dim num As Long
    r = Target.Row
    p = VBA.InStr(1, Cells(r - 1, 1), ".")
    num = CLng(VBA.Mid(Cells(r - 1, 1), p + 1, 20)) + 1
    Cells(r, 1) = VBA.Left(Cells(r - 1, 1), p) & VBA.Format(num, "00")
    Range("C" & r - 1 & ":F" & r - 1).Copy Destination:=Range("C" & r & ":F" & r)
    Call CreateTabs3
    End Sub
    ------------
    Public Sub CreateTabs3()

    On Error Resume Next

    Sheets("POTemp").Visible = True
    Sheets("MasterSheet").Select
    ' Determine how many Names are on Data sheet
    FinalRow = Sheets("MasterSheet").Cells(Rows.Count, "A").End(xlUp).Row
    CountR = Cells(Cells(Rows.Count, "A").End(xlUp).Row + 1, "A").Select
    ' Loop through each Name on the data sheet

    For x = FinalRow To FinalRow
    LastSheet = Sheets.Count
    Sheets("MasterSheet").Select
    Name = Range("A" & x).Value

    Sheets("POTemp").Copy After:=Sheets(LastSheet)
    'rename the sheet and put name in Cell B2
    Sheets(LastSheet + 1).Name = Name
    Sheets(Name).Select
    Range("I3").Value = "=MasterSheet!B" & x
    Next x

    On Error GoTo 0
    Sheets("POTemp").Visible = False
    End Sub
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Copy the last specific not null row to the next row with formulas

    I tried your last workbook and it seems to work perfectly and renaming as well

+ 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