0% found this document useful (0 votes)
36 views1 page

Sub TransformData Script

The provided VBA macro 'TransformData' copies data from the 'After 6 data' worksheet to 'Sheet1' in a specific format. It retrieves information such as name, email, phone, designation, organization, location, and photo from each row, starting from the second row to skip the header. The data is organized into columns in the target sheet, with each entry spaced by seven columns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Sub TransformData Script

The provided VBA macro 'TransformData' copies data from the 'After 6 data' worksheet to 'Sheet1' in a specific format. It retrieves information such as name, email, phone, designation, organization, location, and photo from each row, starting from the second row to skip the header. The data is organized into columns in the target sheet, with each entry spaced by seven columns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Sub TransformData()

Dim wsSource As Worksheet


Set wsSource = ThisWorkbook.Sheets("After 6 data")

Dim wsTarget As Worksheet


Set wsTarget = ThisWorkbook.Sheets("Sheet1")

Dim lastRow As Long


lastRow = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row

Dim outputRow As Long


outputRow = 1

Dim startRow As Long


startRow = 2 ' Start from row 2 to skip the header row

Dim col As Long


col = 1

Do While startRow <= lastRow


For i = 0 To 7
Dim name As String
Dim email As String
Dim phone As String
Dim designation As String
Dim organization As String
Dim location As String
Dim photo As String

name = wsSource.Cells(startRow, 2).Value


email = wsSource.Cells(startRow, 4).Value
phone = wsSource.Cells(startRow, 5).Value
designation = wsSource.Cells(startRow, 6).Value
organization = wsSource.Cells(startRow, 7).Value
location = wsSource.Cells(startRow, 8).Value
photo = wsSource.Cells(startRow, 9).Value

wsTarget.Cells(outputRow, col).Value = name


wsTarget.Cells(outputRow, col + 1).Value = email
wsTarget.Cells(outputRow, col + 2).Value = phone
wsTarget.Cells(outputRow, col + 3).Value = designation
wsTarget.Cells(outputRow, col + 4).Value = organization
wsTarget.Cells(outputRow, col + 5).Value = location
wsTarget.Cells(outputRow, col + 6).Value = photo

col = col + 7
startRow = startRow + 1
Next i

outputRow = outputRow + 1
col = 1
Loop
End Sub

You might also like