View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Code with hidden flaw ERROR 400

Howard,
The InputBox returns a Range object, and so your code has a fully
qualified ref to each range. Sooo...

CpyRngTo.Value = CpyRngFrom.Value

..is all you need.


I just noticed a typo in the variable 'CpyRngFrm'! My bad as I tend to
use fully descriptive naming conventions...

Dim rngCopyFrom As Range, rngCopyTo As Range

OR as I mentioned already...

Dim rngSource As Range, rngTarget As Range

...where the variable 'prefix' refs the data type or, in this case,
object type. So just as...

Dim sText As String, lLastRow As Long, dteStart As Date
Dim vData As Variant, sngTimer1 As Single, dblTimer1 As Double
Dim curForeignAmount As Currency, iCount As Integer

...refs their respective data type, so should objects...

Dim wksSource As Worksheet, wksTarget As Worksheet '(or 'ws')
Dim wkbSource As Workbook, wkbTarget As Workbook '(or 'wb')
Dim appWD As Word.Application, appOL As Outlook.Application
Dim colCustomers As Collection, dicInventory As Dictionery

...use related prefixes (IMO)!

IMO what's important is to use what works for you, so long as it's
consistent and not cryptic to whomever follows after you with the job
of maintaing your projects. In the case of this code, there is no
copying happening and so making ref to that in the variable name[s]
seems inappropriate to my way of thinking. Even if copying was involved
I'd handle it like this...

rngSource.Copy Destination:=rngTarget

...because it stills explains clearly where data is coming from and
where it's going to. Similarly...

rngTarget.Value = rngSource.Value

...this clearly depicts where data is coming from and where it's going.

I'm thinking anyone (even a beginner) should be able to take over my
projects and not have any problems understanding the code. (Or, at
least, that's my hope!<g)

I'm a big fan of self-documenting code writing, but I also use comments
liberally throughout my code where needed for additional clarity (or
more detailed explanations) as to what the code is doing AND why it's
doing it a particular way.

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion