• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy Data one sheet to another using vba

Hi,
I have try to copy data from invoices to Worksheet("Recovery Sheet"). I have another code that generate many Invoices. I would like to copy data from new generated invoice to ws one by one. Here is code for copy data but its not work. Please help me if any one know how to do this.
Code:
Dim RS as worksheet
Set RS = worksheets("Recovery Sheet")

RS.Range(cells(Rows.Count, 2).End(xlUp).Offset(1, 0)).Select
         Selection.Value = 'value = x1up cell value + 1

    'copy paste data in same row with next column cell

    RS.Range(cell.Offset(0, 1)).Value = Activesheet.Range("A8").Value
    RS.Range(cell.Offset(0, 1)).Value = Activesheet.Range("A9").Value
    RS.Range(cell.Offset(0, 1)).Value = Activesheet.Range("F12").Value
    RS.Range(cell.Offset(0, 1)).Value = Activesheet.Range("F15").Value
    RS.Range(cell.Offset(0, 1)).Value = Activesheet.Range("F16").Value
 

Oh, you're a bit strict ! :cool:

As this forum is about VBA, some technical questions may have answers
without any attachment. And I know forums without attachment !

With a crystal clear explanation, often an attachment is not needed …

This forum should be about technical VBA questions for
developers, for those writing codes whatever if not profesionals
or students and not for those asking
« do my job without I burn some neurons (and I keep money!) » …
 
Hi,
Thank for replay, here is file i hope its helpful for this.
In this file i have generate some invoices, when i use this code its may be create hundred of invoices.
 

Attachments

  • Interface.xlsm
    214.4 KB · Views: 6
Its not sheet name "Invoice" its customer billing invoices. Like, Abbas Rizvi, Abdul Rahman etc
 

Attachments

  • Interface.xlsm
    215.1 KB · Views: 2
Hi,
Thank You. It working, but just need little bit adjustment. one sheet data will be show in same row.
 

Attachments

  • Interface (1).xlsm
    190.2 KB · Views: 8
This code work Perfectly
Code:
RS.Range(cells(Rows.Count, 2).End(xlUp).Offset(1, 0)).Select
        Selection.Value = 1

    'insert the value under postcode
    ' this OFFSET refers to the cell 1 row below the "Cell"
   
    RS.Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("A8").Value
    RS.Range("D" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("A9").Value
    RS.Range("E" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("F12").Value
    RS.Range("F" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("F15").Value
    RS.Range("G" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("F16").Value
 
FaizanRoshan

Try this!

Code:
Sub Test()
    Dim ws As Worksheet
    Dim lRows As Long
    Dim i As Integer
  
    Set ws = Worksheets("Recovery Sheet")
    lRows = ws.Range("B" & Rows.Count).End(xlUp).Row
  
    For i = 2 To lRows
        ws.Range("B" & i + 1).Value = ws.Range("B" & i).Value + 1
    Next i
End Sub
Thank You very much for Help.
 
Final Code:

Code:
Dim ws as worksheet
Dim 1rows as Long
Dim i as Integer

Set ws = worksheets ("Recovery Sheet")

lRows = RS.Range("B" & Rows.Count).End(xlUp).Row
 
    For i = 5 To lRows
        RS.Range("B" & i + 1).Value = RS.Range("B" & i).Value + 1
    Next i
    RS.Range(cells(Rows.Count, 2).End(xlUp).Offset(0, 0)).Select
        'Selection.FormulaR1C1.Value = "=R[54]C+1"
    RS.Range("C" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("A8").Value
    RS.Range("D" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("A9").Value
    RS.Range("E" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("F12").Value
    RS.Range("F" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("F15").Value
    RS.Range("G" & Rows.Count).End(xlUp).Offset(0, 0).Value = Range("F16").Value
 
Back
Top