Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

new to vba programing

  Asked By: Nancy    Date: Feb 04    Category: MS Office    Views: 646
  

I wonder if someone can give me the best techniques to achieve the
following.

I am building my first vba / excel app and have created a worksheet
to hold variables

I have used names to identify cells.

I have called the worksheet which stores the variables wsVars
On the worksheet there will be cells like

WorksheetName (the data for this cell would be wsVars)
VatRate (the data for this cell would be 1.175)
etc

I trying to avoid globals and have the ability to change the
operation by chaning the variables

Also items like vatrate will usually never change but the ability to
have an admin screen later on to change the control variables is why
i look upon coding this way

So how do i set this in my code and how do i refer it when i then
want to access cells to put data in and out.

I orginally set up a function to get the worksheet name but thought
this was silly ... ok it works but it calls the function every
couples of code.

If people have a tutorials, links, examples or an explanation of
techniques or structured ways of carrying it out

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Joseph Evans     Answered On: Feb 04

Yes, I like to set  things up that way too. You can use a hidden
sheet to store all the settings and variables. Once you have given
the cells  names, you can access  them using the Range method as shown
below. Using names  rather than absolute cell  addresses also allows
you to rearrange your admin  screen at will without messing up the
code.

Sub Test1()
Range("MyCell1") = 12
End Sub

Sub Test2()
MsgBox "MyCell1 = " & Range("MyCell1")
End Sub

 
Didn't find what you were looking for? Find more on new to vba programing Or get search suggestion and latest updates.




Tagged: