Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default New to VBA - What does this code mean?

Hello

I am new to VBA and have inherited a spreadsheet with to folloing code
lines: Can someone give a good idea what the mean? Where is the
best place to look this kind of stuff up -explinations of code etc.?
Thanks in advance.


LandedCost = ThisWorkbook.Names("LandedCost").RefersToRange.Val ue
landed cost is a named range but what is this code telling the
worksheet?

Dim LandedCost As Double Dim and Double are in blue as compared to
the normal black. What does Dim do?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default New to VBA - What does this code mean?

Words in blue are keywords, e.g. they mean something specific to Excel. Dim
is a declaration, which means the word that follows (which is a made-up word
of your chosing) is being declared as a particular type of data. Double is a
numeric data type with a pre-set number of digits, so your line of code is
declaring that LandedCost is numeric variable. Within the VBE (the window
where you see this code) click the help button and type in Dim or Double for
more information. I believe that the help files accessed from the VBE are
different than those accessed from within the main Excel window :)

The first statement indicates that LandedCost comes from a named range.
Within the main excel program, select insert/name/define then select the
LandedCost item. It should show a formula of some kind in the box at the
bottom. If you aren't sure what it does, copy and paste it back into a
follow-up message to this group for additional assistance. That line of code
is simply saying that it should look to see what the value of LandedCost is
(from the named range). Presumably your macro/code then uses that value for
some purpose. It isn't changing the named range or your worksheet, it is
just grabbing the value. Things to the left of the equal sign are being
assigned the value of whatever is on the right side of the equal sign.

HTH,
Keith

wrote in message
...
Hello

I am new to VBA and have inherited a spreadsheet with to folloing code
lines: Can someone give a good idea what the mean? Where is the
best place to look this kind of stuff up -explinations of code etc.?
Thanks in advance.


LandedCost = ThisWorkbook.Names("LandedCost").RefersToRange.Val ue
landed cost is a named range but what is this code telling the
worksheet?

Dim LandedCost As Double Dim and Double are in blue as compared to
the normal black. What does Dim do?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default New to VBA - What does this code mean?

Keith seems to have covered most of the bases with his response. The only
thing I would add is that declaring variables is one of the areas that new
programmers seem to mess up the most. Check out this link to develope some
good habits and a better understanding...

http://www.cpearson.com/excel/variables.htm
--
HTH...

Jim Thomlinson


"Keith R" wrote:

Words in blue are keywords, e.g. they mean something specific to Excel. Dim
is a declaration, which means the word that follows (which is a made-up word
of your chosing) is being declared as a particular type of data. Double is a
numeric data type with a pre-set number of digits, so your line of code is
declaring that LandedCost is numeric variable. Within the VBE (the window
where you see this code) click the help button and type in Dim or Double for
more information. I believe that the help files accessed from the VBE are
different than those accessed from within the main Excel window :)

The first statement indicates that LandedCost comes from a named range.
Within the main excel program, select insert/name/define then select the
LandedCost item. It should show a formula of some kind in the box at the
bottom. If you aren't sure what it does, copy and paste it back into a
follow-up message to this group for additional assistance. That line of code
is simply saying that it should look to see what the value of LandedCost is
(from the named range). Presumably your macro/code then uses that value for
some purpose. It isn't changing the named range or your worksheet, it is
just grabbing the value. Things to the left of the equal sign are being
assigned the value of whatever is on the right side of the equal sign.

HTH,
Keith

wrote in message
...
Hello

I am new to VBA and have inherited a spreadsheet with to folloing code
lines: Can someone give a good idea what the mean? Where is the
best place to look this kind of stuff up -explinations of code etc.?
Thanks in advance.


LandedCost = ThisWorkbook.Names("LandedCost").RefersToRange.Val ue
landed cost is a named range but what is this code telling the
worksheet?

Dim LandedCost As Double Dim and Double are in blue as compared to
the normal black. What does Dim do?





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default New to VBA - What does this code mean?

On Dec 10, 1:13 pm, wrote:
Hello

I am new to VBA and have inherited a spreadsheet with to folloing code
lines: Can someone give a good idea what the mean? Where is the
best place to look this kind of stuff up -explinations of code etc.?
Thanks in advance.

LandedCost = ThisWorkbook.Names("LandedCost").RefersToRange.Val ue
landed cost is a named range but what is this code telling the
worksheet?

Dim LandedCost As Double Dim and Double are in blue as compared to
the normal black. What does Dim do?


Not sure on the first one, but Dim is used to declare a variable, in
this case as a Double. You can find them described at
http://www.ozgrid.com/VBA/variables.htm

Hope this helps in your world.
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


All times are GMT +1. The time now is 05:41 PM.

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"