Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Copy a row down a column for the same number of rows of data in another workshee

I am importing a file that varies in length from month to month into
Worksheet1. In worksheet2, I need to copy the formulas in Row A10 down the
same number of rows in Worksheet1. I do not want a formula in Worksheet 2
referencing a empty row in Worksheet1.

If there are 100 rows of data in Worksheet1 then I want copy the formula in
100 rows in Worksheet2

This is the code I have been playing with

Sub CopyRow()
'
' CopyRow Macro
' Macro recorded 9/29/2006 by dfredrik
'

'
Dim rng As Range
Dim CurCell As Object
Dim RowNum As Integer
Dim CellsToLoop
Dim Counter As Integer
With Worksheets("GLFBCALO")
Set rng = .Range(.Range("A2"), .Cells(Rows.Count, 1).End(xlUp))
End With
Counter = 10
For Each CellsToLoop In rng.Cells
Range("FormulaRow").Copy
'Selection.Copy
Range("FormulaRow").Copy
Set CurCell = Worksheets("Template").Cells(Counter, 1)
CurCell.Paste
ActiveSheet.Paste
Counter = Counter + 1
Next

End Sub

In the above code the Worksheet1 is GLFBCALO and Worksheet2 is Template.

Any help would be appreciated

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200609/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Copy a row down a column for the same number of rows of data in an

Hi Fredriksson. i would do it this way:

Sub CopyRow()
Dim t
Sheets("GLFBCALO").Select
For t = 10 To Cells(65536, 1).End(xlUp).Row
Cells(t, 1).Copy Destination:=Sheets("Template").Cells(t, 1)
Next
End Sub




"Fredriksson via OfficeKB.com" skrev:

I am importing a file that varies in length from month to month into
Worksheet1. In worksheet2, I need to copy the formulas in Row A10 down the
same number of rows in Worksheet1. I do not want a formula in Worksheet 2
referencing a empty row in Worksheet1.

If there are 100 rows of data in Worksheet1 then I want copy the formula in
100 rows in Worksheet2

This is the code I have been playing with

Sub CopyRow()
'
' CopyRow Macro
' Macro recorded 9/29/2006 by dfredrik
'

'
Dim rng As Range
Dim CurCell As Object
Dim RowNum As Integer
Dim CellsToLoop
Dim Counter As Integer
With Worksheets("GLFBCALO")
Set rng = .Range(.Range("A2"), .Cells(Rows.Count, 1).End(xlUp))
End With
Counter = 10
For Each CellsToLoop In rng.Cells
Range("FormulaRow").Copy
'Selection.Copy
Range("FormulaRow").Copy
Set CurCell = Worksheets("Template").Cells(Counter, 1)
CurCell.Paste
ActiveSheet.Paste
Counter = Counter + 1
Next

End Sub

In the above code the Worksheet1 is GLFBCALO and Worksheet2 is Template.

Any help would be appreciated

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200609/1


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
copy formulas from one worksheet to an entirely different workshee mgonzalez Excel Discussion (Misc queries) 2 December 27th 08 05:03 PM
How can I put an apostrophy next to a number on my Excel workshee. Rabbit Excel Discussion (Misc queries) 5 August 26th 06 08:22 PM
Provide a feature to increase the number of columns in a workshee. Exceller Excel Discussion (Misc queries) 3 December 13th 05 04:57 PM
Data from a number of rows and columns to one column mark_h82 Excel Discussion (Misc queries) 2 January 15th 05 03:02 AM
Copy Formula loop based on number of rows w/ data in a col B. Bernie Deitrick Excel Programming 1 August 20th 04 10:17 PM


All times are GMT +1. The time now is 09:51 AM.

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"