Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
"Is there some VBA code with which could I autofill the column B with
some formula exactly with the same size in A while this could be variable among the sheets?" I have used the code: Sub Macro1() Range("B1").Select ActiveCell.FormulaR1C1 = "Random 1" Selection.AutoFill Destination:=Range("B1:B20") End Sub But in this case I have the fills with the words Random 1, Random 2, Random 3,... Random 20. The problem is that in other situations the random numbers could be 1000 or more and I would not like to do that manually. |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
Is this what you mean
Sub Macro1() Range("B1:B20").Value = "Random 1" End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "paulinoluciano" wrote in message ups.com... "Is there some VBA code with which could I autofill the column B with some formula exactly with the same size in A while this could be variable among the sheets?" I have used the code: Sub Macro1() Range("B1").Select ActiveCell.FormulaR1C1 = "Random 1" Selection.AutoFill Destination:=Range("B1:B20") End Sub But in this case I have the fills with the words Random 1, Random 2, Random 3,... Random 20. The problem is that in other situations the random numbers could be 1000 or more and I would not like to do that manually. |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
Hi,
No, it is not! I would like to autofill the column B with Random 1, Random 2, Random 3, Random 5,.... Random n. However this autofill would need to be of the same size of the column A. Example: If column A has cells containing data until row 20 thus the macro should add the name random until there on column B. If column B has cells containing data until row 1323 thus it should has the name rando until B1323... |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
Maybe...
Sub Macro1() Dim LastRow as long dim wks as worksheet for each wks in activeworkbook.worksheets with wks lastrow = .cells(.rows.count,"A").end(xlup).row .range("b1:b" & lastrow).formular1c1 = "Random 1" 'or ???? .range("B1:b" & lastrow).formula = "=Rand()" end with next wks End Sub paulinoluciano wrote: Hi, No, it is not! I would like to autofill the column B with Random 1, Random 2, Random 3, Random 5,.... Random n. However this autofill would need to be of the same size of the column A. Example: If column A has cells containing data until row 20 thus the macro should add the name random until there on column B. If column B has cells containing data until row 1323 thus it should has the name rando until B1323... -- Dave Peterson |
#5
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
Yes, it is almost the first trend... However instead exhibit always
"Random 1" I have to exhibit Random 1, Random 2, Random 3.... |
#6
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
based on what?
Option Explicit Sub Macro1() Dim LastRow As Long Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets With wks LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row With .Range("B1:B" & LastRow) .Formula = "=""Random "" & Row()" .Value = .Value End With End With Next wks End Sub paulinoluciano wrote: Yes, it is almost the first trend... However instead exhibit always "Random 1" I have to exhibit Random 1, Random 2, Random 3.... -- Dave Peterson |
#7
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
Based on starting as Random 1 and finishing progressively until the
last cell containing data in A column. |
#8
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
Didn't that last suggestion do that?
paulinoluciano wrote: Based on starting as Random 1 and finishing progressively until the last cell containing data in A column. -- Dave Peterson |
#9
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Autofill
Thank you Dave Peterson!
It did exactly that... Luciano |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
autofill | Excel Discussion (Misc queries) | |||
Autofill | Excel Worksheet Functions | |||
More- AutoFill with Non-Seqeuntial Cell References ? | Excel Worksheet Functions | |||
Autofill: Need to autofill one week block, (5) weekday only into cells. | Excel Discussion (Misc queries) | |||
AutoFill Visible Cells with Months | New Users to Excel |