Code to make cell/ range a specified value :: MrExcel Message Board


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Code to make cell/ range a specified value
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

hannah_sydney
Board Regular


Joined: 16 Mar 2003
Posts: 32


Status: Offline

 Reply with quote  

Code to make cell/ range a specified value

Hi,

What code do I need to make a specified cell/ range equal a certain value everytime a workbook is opened?

Many thanks!
_________________
Cheers and Thanks!

HG

Post Mon Mar 24, 2003 1:13 am 
 View user's profile Send private message

Mr Walker
Board Master


Joined: 22 Jan 2003
Posts: 116
Location: Sydney, Australia
Flag: Australia

Status: Offline

 Reply with quote  

You need to insert this into "This workbook"

Private Sub Workbook_Open()
range("a1").value = "YOURVALUE"
end sub

Hope this helps. icon_smile.gif

Post Mon Mar 24, 2003 1:16 am 
 View user's profile Send private message Send e-mail

Barrie Davidson
MrExcel MVP


Joined: 11 Feb 2002
Posts: 1086
Location: Winnipeg
Flag: Canada

Status: Offline

 Reply with quote  

Put this in the Workbook Open event (change the range and values accordingly):

Range("A1:B10").Value = "Barrie"

Regards,
_________________
Barrie Davidson
My Excel Web Page

"You're only given a little spark of madness. You mustn't lose it." - Robin Williams

Post Mon Mar 24, 2003 1:17 am 
 View user's profile Send private message Send e-mail Visit poster's website

phantom1975
MrExcel MVP


Joined: 04 Jun 2002
Posts: 3518
Location: Glendale, Arizona
Flag: Usa

Status: Offline

 Reply with quote  

You might want to also reference the sheet too:

Sheets("Sheet1").Range("A1").Value = "Barrie's head smells like cheese."
_________________
ClickHERE for a list of Excel functions and examples.

***************** EXCEL/VB NEWBIES ARE MY FAVORITE! *****************

Post Mon Mar 24, 2003 1:52 am 
 View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.