ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filling rows (https://www.excelbanter.com/excel-programming/284353-filling-rows.html)

Salim

Filling rows
 
The worksheet where the data is residing is called "Master
Employee" and I need to copy every row onto a worksheet
called "Labels". Every row copied will fill in 10 rows on
the "labels" worksheet. Both the wkshts have the same
column headings.

I have data on Master Employee and need to copy to Labels.
Master Employee!A1 to A1:A10 on Labels
Master Employee!A2 to A11:A20 on Labels
Master Employee!A3 to A21:A30 on Labels
Master Employee!A4 to A31:A40 on Labels
and so on.

Help!!


Rick[_13_]

Filling rows
 
I'm not sure exactly what you wanted. So, I created two
varieties.

I think you want the second variety. Check and see if one
of these work for you. I didn't completely check them,
but I think they're OK. Note, for these samples, the
first row is 1 and the last row is 10 in the Master
Employees sheet. Just change these variables to fit your
requirements.

The first variety allows for 10 columns (fields) of data
per row, in the Master Employee sheet. These are copied
to the Labels sheet in column A in groups of 10.

The second variety allows for only one column of data
(column A) in each row as found on the Master Employee
Sheet. This one item is copied to the Labels sheet in
groups of 10 also.

Sub EmployeeLabelsVar1()
Dim i As Long
Dim j As Byte
Dim FirstRow As Integer, LastRow As Integer
Dim S1 As Worksheet, S2 As Worksheet
Dim Count As Integer

Set S1 = Sheets("Master Employee")
Set S2 = Sheets("Labels")

FirstRow = 1
LastRow = 10

Count = 0


For i = FirstRow To LastRow
For j = 1 To 10
S2.Cells(j + Count, 1).Value = _
S1.Cells(i, j).Value
Next j
Count = Count + 10
Next i

End Sub

Sub EmployeeLabelsVar2()
Dim i As Long
Dim j As Byte
Dim FirstRow As Integer, LastRow As Integer
Dim S1 As Worksheet, S2 As Worksheet
Dim Count As Integer

Set S1 = Sheets("Master Employee")
Set S2 = Sheets("Labels")

FirstRow = 1
LastRow = 10

Count = 0


For i = FirstRow To LastRow
For j = 1 To 10
S2.Cells(j + Count, 1).Value = _
S1.Cells(i, 1).Value
Next j
Count = Count + 10
Next i

End Sub

-----Original Message-----
The worksheet where the data is residing is

called "Master
Employee" and I need to copy every row onto a worksheet
called "Labels". Every row copied will fill in 10 rows on
the "labels" worksheet. Both the wkshts have the same
column headings.

I have data on Master Employee and need to copy to

Labels.
Master Employee!A1 to A1:A10 on Labels
Master Employee!A2 to A11:A20 on Labels
Master Employee!A3 to A21:A30 on Labels
Master Employee!A4 to A31:A40 on Labels
and so on.

Help!!

.



All times are GMT +1. The time now is 11:43 PM.

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