Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Formula in macro help

Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the selected
range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to a
toolbar button.

Thanks!

Biff


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Formula in macro help

One way, if you have the range selected:

Sub Test()
With Selection
.Formula = "=ROUND(RAND()*100,0)"
.Copy
.PasteSpecial xlValues
End With
'Application.CutCopyMode = False
End Sub

Or you could just use Range("A1:A2") or equivalent insead of Selection. This
would be better as there would be no need then to select the range.

Regards,

Vasant

"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to a
toolbar button.

Thanks!

Biff



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Formula in macro help

Thanks Vasant. Perfect!

Biff

"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
One way, if you have the range selected:

Sub Test()
With Selection
.Formula = "=ROUND(RAND()*100,0)"
.Copy
.PasteSpecial xlValues
End With
'Application.CutCopyMode = False
End Sub

Or you could just use Range("A1:A2") or equivalent insead of Selection.
This would be better as there would be no need then to select the range.

Regards,

Vasant

"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to a
toolbar button.

Thanks!

Biff





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Formula in macro help

Doug's approach is more efficient, actually.

--

Vasant


"Biff" wrote in message
...
Thanks Vasant. Perfect!

Biff

"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
One way, if you have the range selected:

Sub Test()
With Selection
.Formula = "=ROUND(RAND()*100,0)"
.Copy
.PasteSpecial xlValues
End With
'Application.CutCopyMode = False
End Sub

Or you could just use Range("A1:A2") or equivalent insead of Selection.
This would be better as there would be no need then to select the range.

Regards,

Vasant

"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to
a toolbar button.

Thanks!

Biff







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Formula in macro help

Ok, appreciate the effort!

Biff

"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
Doug's approach is more efficient, actually.

--

Vasant


"Biff" wrote in message
...
Thanks Vasant. Perfect!

Biff

"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
One way, if you have the range selected:

Sub Test()
With Selection
.Formula = "=ROUND(RAND()*100,0)"
.Copy
.PasteSpecial xlValues
End With
'Application.CutCopyMode = False
End Sub

Or you could just use Range("A1:A2") or equivalent insead of Selection.
This would be better as there would be no need then to select the range.

Regards,

Vasant

"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to
a toolbar button.

Thanks!

Biff











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Formula in macro help

Biff,

Sub test()
Selection.Formula = "=ROUND(RAND()*100,0)"
Selection.Value = Selection.Value
End Sub

hth,

Doug


"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to a
toolbar button.

Thanks!

Biff



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Formula in macro help

Thanks Doug.

Man, that seemed too easy! I gotta get up to speed with VBA one of these
days.

Biff

"Doug Glancy" wrote in message
...
Biff,

Sub test()
Selection.Formula = "=ROUND(RAND()*100,0)"
Selection.Value = Selection.Value
End Sub

hth,

Doug


"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to a
toolbar button.

Thanks!

Biff





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Formula in macro help

You're welcome.

Doug

"Biff" wrote in message
...
Thanks Doug.

Man, that seemed too easy! I gotta get up to speed with VBA one of these
days.

Biff

"Doug Glancy" wrote in message
...
Biff,

Sub test()
Selection.Formula = "=ROUND(RAND()*100,0)"
Selection.Value = Selection.Value
End Sub

hth,

Doug


"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to
a toolbar button.

Thanks!

Biff







  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Formula in macro help

Just another option:

Sub Demo()
ActiveCell = [ROUND(RAND()*100,0)]
End Sub

HTH :)
--
Dana DeLouis
Win XP & Office 2003


"Biff" wrote in message
...
Thanks Doug.

Man, that seemed too easy! I gotta get up to speed with VBA one of these
days.

Biff

"Doug Glancy" wrote in message
...
Biff,

Sub test()
Selection.Formula = "=ROUND(RAND()*100,0)"
Selection.Value = Selection.Value
End Sub

hth,

Doug


"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to
a toolbar button.

Thanks!

Biff







  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Formula in macro help

Oops. That won't work. My mistake. You said a range. Didn't notice till
after hitting send. Sorry.

--
Dana


"Dana DeLouis" wrote in message
...
Just another option:

Sub Demo()
ActiveCell = [ROUND(RAND()*100,0)]
End Sub

HTH :)
--
Dana DeLouis
Win XP & Office 2003


"Biff" wrote in message
...
Thanks Doug.

Man, that seemed too easy! I gotta get up to speed with VBA one of these
days.

Biff

"Doug Glancy" wrote in message
...
Biff,

Sub test()
Selection.Formula = "=ROUND(RAND()*100,0)"
Selection.Value = Selection.Value
End Sub

hth,

Doug


"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to
a toolbar button.

Thanks!

Biff











  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Formula in macro help

Dana,

I tried something like that- are the brackets the same as Evaluate?
Anyways, since Biff wants to fill a range, I don't think thatworks - at
least when I change Activecell to Selection I get the same "random" number
in each cell.

Doug

"Dana DeLouis" wrote in message
...
Just another option:

Sub Demo()
ActiveCell = [ROUND(RAND()*100,0)]
End Sub

HTH :)
--
Dana DeLouis
Win XP & Office 2003


"Biff" wrote in message
...
Thanks Doug.

Man, that seemed too easy! I gotta get up to speed with VBA one of these
days.

Biff

"Doug Glancy" wrote in message
...
Biff,

Sub test()
Selection.Formula = "=ROUND(RAND()*100,0)"
Selection.Value = Selection.Value
End Sub

hth,

Doug


"Biff" wrote in message
...
Hi Folks!

I use this formula extensively for testing:

=ROUND(RAND()*100,0)

That simply generates random 2 digit integers.

What I would like is a macro that will insert that formula into the
selected range then do the equivalent of CopyPaste SpecialValues.

It doesn't necessarily have to "insert that formula" just so the macro
generates random 2 digit ints in the selected range.

I use this so often it makes sense to have a macro that I can attach to
a toolbar button.

Thanks!

Biff









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
Using a formula in a macro Al @ Frontier[_2_] Excel Discussion (Misc queries) 2 January 26th 10 04:00 PM
Formula or Macro A.S. Excel Discussion (Misc queries) 6 March 5th 08 01:16 AM
Need formula or Macro Help Atomic Excel Worksheet Functions 1 April 26th 07 05:38 PM
Macro Formula for Max value John Bundy Excel Worksheet Functions 0 November 30th 06 05:25 PM
formula to a macro help PLEASE Hemming Excel Discussion (Misc queries) 2 March 9th 06 03:16 PM


All times are GMT +1. The time now is 04:08 PM.

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

About Us

"It's about Microsoft Excel"