Using the AUTOFILL Function

G

Guest

I am trying to define a range for autofill with 2 textboxes on a userform.

This code is in the from module

Private Sub CommandButton1_Click()
ActiveCell = "C8"
ActiveCell.FormulaR1C1 = Me.TextBox2.Value
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = Me.TextBox2 + 1
Range("C8:C9").Select
Selection.AutoFill Destination:=Range(Cells("8,C"),
Cells("me.TextBox2.Value = TextBox3.Value,C")), _
Type:=xlFillDefault

End Sub

This returns a type mismatch

Could anyone suggest why.

Thanks in in advance for any help
 
G

Guest

I made some changes to the code and it runs. Not sure if it does exactly
what is is suppose to do, but I fixed the run time errors. The .cells()
wants numberical values not a string "8,c". Should be 8,3

Private Sub CommandButton1_Click()

ActiveCell = "C8"
ActiveCell.FormulaR1C1 = Me.TextBox2.Value
ActiveCell.Offset(1, 0).Activate
ActiveCell = Me.TextBox2 + 1
Range("C8:C9").Select
Selection.AutoFill Destination:=Range(Cells(8, 3), _
Cells(TextBox3.Value, 3)), _
Type:=xlFillDefault
Me.TextBox2.Value = TextBox3
End Sub
 
G

Guest

Thanks, that works a treat

Mark

Joel said:
I made some changes to the code and it runs. Not sure if it does exactly
what is is suppose to do, but I fixed the run time errors. The .cells()
wants numberical values not a string "8,c". Should be 8,3

Private Sub CommandButton1_Click()

ActiveCell = "C8"
ActiveCell.FormulaR1C1 = Me.TextBox2.Value
ActiveCell.Offset(1, 0).Activate
ActiveCell = Me.TextBox2 + 1
Range("C8:C9").Select
Selection.AutoFill Destination:=Range(Cells(8, 3), _
Cells(TextBox3.Value, 3)), _
Type:=xlFillDefault
Me.TextBox2.Value = TextBox3
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top