ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using object Range dynamic??? (https://www.excelbanter.com/excel-programming/279861-using-object-range-dynamic.html)

Peter[_32_]

Using object Range dynamic???
 
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

Chrissy[_4_]

Using object Range dynamic???
 
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'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




Peter[_32_]

Using object Range dynamic???
 
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





-----Original Message-----
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
.


Chrissy[_4_]

Using object Range dynamic???
 
Did you try what I posted?

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





All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com