Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 127
Default Macros or the Fastest way to Autofill Rows


I need a macros to autofill rows. I am working on one now but have a few
problems. I have one spreadsheet that has a row for each employee for each
payperiod. It has the employee name, check number, date, hours worked,
vacation sick, pay etc, earnings. The hours worked may be in 3 column
depending on if it is regular pay, overtime 1 pay, overtime 2 pay, and
commission - (which is an amont). I take that line and copy it in another
spreadsheet for 27 rows for one employee and one pay period. Then the I copy
the 2nd row which is another another employee and one pay period, etc etc. I
would like to design a macros so copy all the rows for a certain range, (say
column a1..j1). I have other data in columns k1..ac that will not get copy.
I am using an Index to pull that info, that is not a problem. I just need 27
rows for 1 row of data from the originaly spreadsheet.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macros or the Fastest way to Autofill Rows

So you end up with one sheet with 27 times the number of rows that you had
before?

If yes:

Option Explicit
Sub testme01()

Dim CurWks As Worksheet
Dim NewWks As Worksheet
Dim DestCell As Range
Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim HowManyCols As Long
Dim HowManyRows As Long

HowManyCols = 10
HowManyRows = 27

Set CurWks = Worksheets("sheet1")
Set NewWks = Worksheets("sheet2")

With NewWks
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp)
If IsEmpty(DestCell.Value) Then
'stay put
Else
Set DestCell = DestCell.Offset(1, 0)
End If
End With

With CurWks
FirstRow = 2 'headers in row 1???
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow
.Cells(iRow, "A").Resize(1, HowManyCols).Copy _
Destination:=DestCell.Resize(HowManyRows, 1)
Set DestCell = DestCell.Offset(HowManyRows)
Next iRow
End With
End Sub



klafert wrote:


I need a macros to autofill rows. I am working on one now but have a few
problems. I have one spreadsheet that has a row for each employee for each
payperiod. It has the employee name, check number, date, hours worked,
vacation sick, pay etc, earnings. The hours worked may be in 3 column
depending on if it is regular pay, overtime 1 pay, overtime 2 pay, and
commission - (which is an amont). I take that line and copy it in another
spreadsheet for 27 rows for one employee and one pay period. Then the I copy
the 2nd row which is another another employee and one pay period, etc etc. I
would like to design a macros so copy all the rows for a certain range, (say
column a1..j1). I have other data in columns k1..ac that will not get copy.
I am using an Index to pull that info, that is not a problem. I just need 27
rows for 1 row of data from the originaly spreadsheet.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
(Unsuccessfully!) Unhiding Rows in Excel 2003 [email protected] Excel Worksheet Functions 6 May 24th 06 08:17 PM
Expand/Collapse Rows [email protected] Excel Worksheet Functions 0 May 18th 06 09:23 AM
formula to use when number of rows changes dynamically confused Excel Worksheet Functions 3 August 17th 05 03:55 PM
What is fastest for this? The Small VBA or many Worksheet Functions...? Maria J-son Excel Worksheet Functions 0 August 10th 05 08:24 AM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM


All times are GMT +1. The time now is 04:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"