Thread: Excel Copy
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
timrekdgorf timrekdgorf is offline
external usenet poster
 
Posts: 1
Default Excel Copy


i have a bunch of military times that a user is typing in under the W
column starting in cell 9. The user then hits a macro button that will
take all the times they punched in and copy each one 24 times under the
B column starting with cell 9.

for example:
1432 is typed into Cell W9. 1432 gets copied into cell B9-B32.
1526 is typed into Cell W10. 1526 gets copied into cell B33-B56.

Here is my macro code:

Dim copyfield
Dim pastefield1
Dim pastefield2


For counter = 9 To 200

copyfield = "W" & counter
pastefield1 = (counter - 9) * 24 + 9
pastefield2 = pastefield1 + 23
pastefield1 = "B" & pastefield1
pastefield2 = "B" & pastefield2

Worksheets("Sheet1").Range(copyfield).Copy _
Destination:=Worksheets("Sheet1").Range(pastefield 1,
pastefield2)
Next counter
End Sub

I keep getting the error "Runtime error 9. Subscript out of range"

Can anyone help me out why?

thanks for your help
-timrekdgorf


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements