Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Trying to repeat a procedure

Hey all!
Could someone please help me here with this code.
I would like for a range to be copied down x times, whereas x is filled in
from a userform.

This is what I did.

Private Sub Go_Click()

usrfrm_1.txtbx_Years.SetFocus

Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

ws.Cells(3, 2).Value = usrfrm_1.txtbx_Years.Value

Dim ayear As String
With Worksheets("Sheet1")

ayear = .Range("YearsInPut").Value


Range("A7:C7").Select
Selection.AutoFill Destination:=Range("A6:C" & "ayear"),
Type:=xlFillDefault
Range("A6").Select

End Sub

I think I'm screwing it up at the 3rd to last line for the range.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Trying to repeat a procedure

Tim,

Remove the quotes from 'ayear' in the following line of code:

Selection.AutoFill Destination:=Range("A6:C" & "ayear"),
Type:=xlFillDefault

should be

Selection.AutoFill Destination:=Range("A6:C" & ayear),
Type:=xlFillDefault


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"TimT" wrote in message
...
Hey all!
Could someone please help me here with this code.
I would like for a range to be copied down x times, whereas x
is filled in
from a userform.

This is what I did.

Private Sub Go_Click()

usrfrm_1.txtbx_Years.SetFocus

Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

ws.Cells(3, 2).Value = usrfrm_1.txtbx_Years.Value

Dim ayear As String
With Worksheets("Sheet1")

ayear = .Range("YearsInPut").Value


Range("A7:C7").Select
Selection.AutoFill Destination:=Range("A6:C" & "ayear"),
Type:=xlFillDefault
Range("A6").Select

End Sub

I think I'm screwing it up at the 3rd to last line for the
range.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Trying to repeat a procedure

Works like a charm.
Thanks Chip!

"TimT" wrote:

Hey all!
Could someone please help me here with this code.
I would like for a range to be copied down x times, whereas x is filled in
from a userform.

This is what I did.

Private Sub Go_Click()

usrfrm_1.txtbx_Years.SetFocus

Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

ws.Cells(3, 2).Value = usrfrm_1.txtbx_Years.Value

Dim ayear As String
With Worksheets("Sheet1")

ayear = .Range("YearsInPut").Value


Range("A7:C7").Select
Selection.AutoFill Destination:=Range("A6:C" & "ayear"),
Type:=xlFillDefault
Range("A6").Select

End Sub

I think I'm screwing it up at the 3rd to last line for the range.


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
Stop a Procedure from another procedure Ayo Excel Discussion (Misc queries) 1 October 30th 08 01:42 AM
Title Cut Off if Rows to Repeat & Columns to Repeat are Both Selec unibaby Excel Discussion (Misc queries) 2 August 24th 05 04:29 PM
Calling a procedure in a procedure Norman Jones Excel Programming 8 August 20th 04 07:53 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM


All times are GMT +1. The time now is 11:17 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"