There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer itunes laptop mac malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan usb virus vista vista 32-bit windows windows vista windows xp winxp wireless wmp
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Using a VBA function to place values or formulas into cells


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
mcmcman's Avatar
Junior Member with 2 posts.
 
Join Date: Sep 2003
16-Sep-2003, 02:24 PM #1
Using a VBA function to place values or formulas into cells
Hi,

I have been trying to figure out if it is possible to use a VBA function to place values and formulas into excel cells. In the past, I have done so using Macros, but for my particular application, I want to be able to do so from within a VBA function. Any ideas on how to do this?
dtech10's Avatar
Member with 55 posts.
 
Join Date: Jan 2003
05-Oct-2003, 07:45 PM #2
Formula's ect if macros
Hi
This might give you some ideas.


Sub FormulaInCells()
Dim MyRange As Range
Dim Total As Integer

'Setup Range Pointer
Set MyRange = ActiveSheet.Range("b1:b10")

'Placing Formula's in Range
With MyRange
.Formula = "=int(rand()*10)"
End With

'Using Excel Functions on a Range
MsgBox ("Sum Data & Autofit")
Total = Application.Sum(MyRange)
Range("a11").Value = "Total"
Range("b11").Value = Total
Range("b1:b11").Columns.AutoFit

'Restore Worksheet
MsgBox "Restore Worksheet"
RestoreWorksheet
End Sub
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:10 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.