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
[TABLE="width: 105"]
<colgroup><col></colgroup><tbody>[TR]
[TD]
STUDENT NAME
[/TD]
[/TR]
[TR]
[TD]Kalpesh Patel[/TD]
[/TR]
[TR]
[TD]Amit Shah[/TD]
[/TR]
[TR]
[TD]Vipul Rathod[/TD]
[/TR]
[TR]
[TD]Jigar Patel
[/TD]
[/TR]
[TR]
[TD]Hitesh Doshi[/TD]
[/TR]
</tbody>[/TABLE]

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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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