#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
paulinoluciano
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
paulinoluciano
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
paulinoluciano
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
paulinoluciano
 
Posts: n/a
Default Autofill

Based on starting as Random 1 and finishing progressively until the
last cell containing data in A column.

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
paulinoluciano
 
Posts: n/a
Default Autofill

Thank you Dave Peterson!
It did exactly that...
Luciano

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
autofill Anders Excel Discussion (Misc queries) 0 December 8th 05 04:03 PM
Autofill sisco98 Excel Worksheet Functions 1 June 28th 05 01:30 PM
More- AutoFill with Non-Seqeuntial Cell References ? [email protected] Excel Worksheet Functions 4 June 23rd 05 02:42 AM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
AutoFill Visible Cells with Months Elaine New Users to Excel 3 March 16th 05 10:13 PM


All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"