Consulting

Results 1 to 12 of 12

Thread: Print data from sheet to another one after one

  1. #1

    Question Print data from sheet to another one after one

    this code it will print the data from cells in sheet1 to cells in sheet2
    If I try nwe data in the same cells in sheet1 it will print them in the same cells in sheet2 .
    I want to print the new data that I inserted in the same cells in sheet1 belwo the last data with left a 3 rows between each new group data.

    [vba]
    Dim myRange As Range
    Dim j As Integer
    Set myRange = Range("A6:A100")
    j = 9
    For i = 6 To myRange.Rows.Count
    Sheets(2).Cells(j, 1).Value = Sheets(1).Cells(i, 1).Value
    j = j + 1
    Next i

    [/vba]

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    will sheet 1 be blank each time you do this?
    The reason I ask is that if it won't be blank then how will excel know where to put the 3 row break?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Yes it will be blank, but only sheet2 will left 3 rows between group data as it show in the pic

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    This is not exactly what you asked for but very similar. It uses a userform and multiple textboxes to enter the data....You will have to add the necessary number of textboxes.

    see attached.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    In the first thank you for help

    I Tried this code but it give me 3 rwos break between each data not each group data as I want . s owhat si the mistake in the code


     
    Dim myRange As Range
    Dim j As Integer Set myRange = Range("A6:A100")
    For i = 6 To myRange.Rows.Count
    Sheets(2).Cells(Rows.Count, 1).End(xlUp).Offset(4, 0).Value = Sheets(1).Cells(i, 1).Value Next i


  6. #6
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Quote Originally Posted by Nader
    I Tried this code but it give me 3 rwos break between each data not each group data as I want . s owhat si the mistake in the code
    How is the data group broken up? After all you asked ...

    this code it will print the data from cells in sheet1 to cells in sheet2
    If I try nwe data in the same cells in sheet1 it will print them in the same cells in sheet2 .
    I want to print the new data that I inserted in the same cells in sheet1 belwo the last data with left a 3 rows between each new group data.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  7. #7
    Take a look to the pic above.The first data I wrote Jenny ... in sheet1 then press command it will print in sheet2 in group as it show in the pic then write another group data Jhon... and press command it will prin them below he last data with left 3 broken rows as it show in the pic

  8. #8
    here is the code, and it successed with me.

    [VBA]
    Dim myRange As Range
    Dim j As Integer
    Set myRange = Sheets(1).Range("A6:A100")
    j = Sheets(2).UsedRange.Rows.Count + 3 + Sheets(2).UsedRange.Row
    myRange.Copy Sheets(2).Range("f" & j)
    [/VBA]

    How can I make this code start at sixth row of sheet2

  9. #9
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    As I understand it, your image has the names sorted into Male /Female name groups, is this right grouping? And it starts at row 9....

    That aside, I would try counting the used rows from the bottom of Sheet two to find the first blank row and then offsetting this by three to find the startng point of the next set of data.

    I'm confused with your wording in the last post. You said" here is the code, and it successed with me." Where did it place the data?

    This line doesn't make sence at all " myRange.Copy Sheets(2).Range("f" & j)". Row positions start with a number not a alphabetical character.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  10. #10
    Here is the project after finishing.

  11. #11
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Hmm..... we must be speaking two different languages here. You indicate one thing and mean something entirely different. What you have provided here as a finalised workbook, isn't what you initially asked for.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  12. #12

Posting Permissions

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