LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculation With A Macro

Just a note.

VBA is pretty forgiving. You can concatenate text with numbers and still
end up
with text.

.Range("B" & CStr(X))
could be written as:
.Range("B" & X)

(same in the =sum() portion, too.)

I like:
.cells(x,"B")
though.

I'm guessing that VB is less forgiving?????


No, actually, the guts of VBA and compiled VB are the same; so, in this
case, VB would be as forgiving. In the compiled VB world, it is considered
(and please don't take this the wrong way) poor programming practice to let
VB handle the conversions automatically when you know in advance what the
data type should be. Over there, VB's underlying data type coercions are
called "evil type coercions" and are to be avoided whenever possible. In
addition, not omitting default object properties (the Value property of a
Range being an example), expressly declaring variable types and avoiding
Variants whenever possible are also considered good programming practice as
well... three more things which seem to be laxly adhered to in the Excel
community. So, when you see me doing any of these things (such as expressly
using the CStr function as you pointed out), it will simply be a case of
"old habits die hard".

Rick

 
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
Time Calculation w/ Macro WLMPilot Excel Programming 1 January 8th 08 03:16 PM
Using a macro to do a calculation bhrosey via OfficeKB.com Excel Programming 4 September 5th 07 06:15 PM
Macro Help for a BIG Calculation Ananth Excel Discussion (Misc queries) 1 July 27th 07 09:29 AM
Product calculation macro MikeD1224 New Users to Excel 1 June 15th 07 10:36 PM
Run a macro when cell changes (due to calculation!) Tornados Excel Programming 3 December 23rd 03 04:16 PM


All times are GMT +1. The time now is 05:13 AM.

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"