ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating new entries (https://www.excelbanter.com/excel-programming/352838-creating-new-entries.html)

eclipse[_4_]

Creating new entries
 
Hi All,

I have a spreadsheet containing students' grades in this format:

M Wakefield A C D
A Sky F E B


What I would like to generate from the data above is this:


M Wakefield A
M Wakefield C
M Wakefield D
A Sky F
A Sky E
A Sky B



I have about 2000 entries, any help will be much appreciated.



Terapixels



Toppers

Creating new entries
 
Hi,
Data from Sheet1 - starting in col A, Row 2 - is copied to Sheet2:


HTH

Sub Transform()

Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastrow As Long, r As Long, i As Integer

Set ws1 = Worksheets("sheet1")
Set ws2 = Worksheets("sheet2")

rr = 2
ws2.Range("A1:B1") = Array("Student", "Grade")
With ws1
For r = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To .Cells(r, Columns.Count).End(xlToLeft).Column
.Cells(r, 1).Copy ws2.Cells(rr, 1)
.Cells(r, i).Copy ws2.Cells(rr, 2)
rr = rr + 1
Next i
Next r
End With

End Sub

"eclipse" wrote:

Hi All,

I have a spreadsheet containing students' grades in this format:

M Wakefield A C D
A Sky F E B


What I would like to generate from the data above is this:


M Wakefield A
M Wakefield C
M Wakefield D
A Sky F
A Sky E
A Sky B



I have about 2000 entries, any help will be much appreciated.



Terapixels





All times are GMT +1. The time now is 02:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com