Using object Range dynamic???

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

I'm using a macro to fill a range of rows and columns in
Office 2000, se code below.

Range("A1:C1").Select
Selection.AutoFill Destination:=Range("A1:C22"),
Type:=xlFillDefault
Range("A1:C22").Select

What I want to do is to do the fill from cell A1 to cell
(row - input from user, column C).

Input from user is stored in an Integer.

It seams like en easy problem but I havent found the
answer.

/Peter
 
Sub MyFillDown()
Dim iRowCount As Integer

iRowCount = InputBox("How many rows do you want?", "Number of Rows", 10)
Range("A1:C" & iRowCount).FillDown
End Sub


Give a default number of 10 rows.

Chrissy.


Peter wrote
 
I have now tried a couple of different things as seen
below, but I get errors.

Try1:
Range("A1:C1").Select
Selection.AutoFill Destination:=Range("A1", Cells
(Rows.Count, 3).End(xlUp)), Type:=xlFillDefault
Range("A1", Cells(Rows.Count, 3).End(xlUp)).Select

Try2:
Dim rng As Excel.Range

With Worksheets("Sheet1")
Set rng = Range("A1", Cells(Rows.Count, 3).End(xlUp))
End With

Range("A1:C1").Select
Selection.AutoFill Destination:=Range(rng),
Type:=xlFillDefault
Range("A1:C622").Select

/Peter
 
Back
Top