R
ryguy7272
I am stuck on (what is probably) a simple macro. I am trying to prompt a
user to enter a month into C14 and then enter a number (let’s say 12 but it
varies) into another InputBox and then spread the months over that range.
This is what I have so far:
Sub BeginMonth()
Dim Mth As String
Dim Nbr As Long
Mth = InputBox("Please enter a beginning month.")
Range("C14").Select
ActiveCell = Mth
Nbr = InputBox("Please enter total number of months.")
Selection.AutoFill Destination:=Range("C1414"), Type:=xlFillDefault
Range("C1414").Select
ActiveCell.Offset(0, Nbr).Activate
With ActiveSheet
.Range("C14").AutoFill Destination:=.Range("C14" & Nbr)
End With
End Sub
It fails on AutoFill line.
Also, I’d like to do a simple calculation in cell C15, such as =(D10/E27).
Then, I’d like to fill right as many columns as the user enters (as mentioned
above, perhaps 12, but it will vary). Finally, in C16, I’d like to do
another simple calculation, such as =(C15*K10), and again fill right and then
shift right one column (Offset 0,1) and down one row, then right one column
and down two rows, and right one column and down 3 rows, etc., until it
reaches the final column (12 or whatever the user enters).
I’m sure it can be done and I’m taking a crack at it now. If anyone has any
suggestions, please share. If I finish it off before I hear back from anyone
I’ll post the solution here.
Regards,
Ryan--
user to enter a month into C14 and then enter a number (let’s say 12 but it
varies) into another InputBox and then spread the months over that range.
This is what I have so far:
Sub BeginMonth()
Dim Mth As String
Dim Nbr As Long
Mth = InputBox("Please enter a beginning month.")
Range("C14").Select
ActiveCell = Mth
Nbr = InputBox("Please enter total number of months.")
Selection.AutoFill Destination:=Range("C1414"), Type:=xlFillDefault
Range("C1414").Select
ActiveCell.Offset(0, Nbr).Activate
With ActiveSheet
.Range("C14").AutoFill Destination:=.Range("C14" & Nbr)
End With
End Sub
It fails on AutoFill line.
Also, I’d like to do a simple calculation in cell C15, such as =(D10/E27).
Then, I’d like to fill right as many columns as the user enters (as mentioned
above, perhaps 12, but it will vary). Finally, in C16, I’d like to do
another simple calculation, such as =(C15*K10), and again fill right and then
shift right one column (Offset 0,1) and down one row, then right one column
and down two rows, and right one column and down 3 rows, etc., until it
reaches the final column (12 or whatever the user enters).
I’m sure it can be done and I’m taking a crack at it now. If anyone has any
suggestions, please share. If I finish it off before I hear back from anyone
I’ll post the solution here.
Regards,
Ryan--