Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stop a Procedure from another procedure | Excel Discussion (Misc queries) | |||
Title Cut Off if Rows to Repeat & Columns to Repeat are Both Selec | Excel Discussion (Misc queries) | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming |