![]() |
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. |
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. |
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. |
All times are GMT +1. The time now is 11:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com