Data Transer in another Sheets

nidhipatel

Board Regular
Joined
Feb 11, 2017
Messages
52
in sheet 1 Range A2 To A6 contins Student name lke

STUDENT NAME
Kalpesh Patel
Amit Shah
Vipul Rathod
Jigar Patel
Hitesh Doshi

<colgroup><col></colgroup><tbody>
</tbody>

i wish to this data add in sheet2 range A2. and every time data add in last blank row in sheet2. this is made without copy & paste method. this is made by for loop vba only.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Errant Post
 
Last edited:
Upvote 0
Your question was a little ambiguous as it was not clear if you wanted all the student names in one cell or if you wanted the students names to be a on separate rows in column A. I have included codes to do both.

This code will run the student names down column A:

Code:
Sub MoveStudents()


    Dim stud As Variant
    Dim lRow As Long


    lRow = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
    If lRow <= 2 Then lRow = 2
    stud = Worksheets("Sheet1").Range("A2:A6")
    Worksheets("Sheet2").Range("A" & lRow).Resize(UBound(stud)) = stud
    
End Sub

This code will put the student names in a single cell in column A, starting with Cell A2. I separated the names with a comma and space.

Code:
Sub MoveStudents2()


    Dim stud As Variant
    Dim lRow As Long, x As Long
    Dim studcell As String
    
    lRow = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row + 1
    If lRow < 2 Then lRow = 2
    stud = Worksheets("Sheet1").Range("A2:A6")
    For x = LBound(stud) To UBound(stud)
        studcell = studcell & ", " & stud(x, 1)
    Next
    studcell = Mid(studcell, 3)
    Worksheets("Sheet2").Range("A" & lRow) = studcell
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,844
Members
449,193
Latest member
MikeVol

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top