[dba-Tech] OT - Excel VBA Cell Selection Syntax (x-posted)

Dan Waters dwaters at usinternet.com
Tue Aug 16 16:47:37 CDT 2005


Yahoooo!

That worked like a charm!

Also - you called this refactoring.  I've heard that term before - what does
it mean?

Dan Waters


-----Original Message-----
From: dba-tech-bounces at databaseadvisors.com
[mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Shamil
Salakhetdinov
Sent: Tuesday, August 16, 2005 3:53 PM
To: Discussion of Hardware and Software issues
Subject: Re: [dba-Tech] OT - Excel VBA Cell Selection Syntax (x-posted)

Dan,

Both work OK here with MS Excel 2003 when ("Available Items") is active
worksheet.
I think you need to refactor your code to have:

Dim wks As Excel.Worksheet
    Set wks = Worksheets("Available Items")
    wks.Select
    wks.Range(wks.Cells(2, 1), wks.Cells(123, 2)).Select

HTH,
Shamil
--
Web: http://smsconsulting.spb.ru/shamil_s

----- Original Message ----- 
From: "Dan Waters" <dwaters at usinternet.com>
To: "DBA-Tech" <dba-tech at databaseadvisors.com>; "AccessD"
<accessd at databaseadvisors.com>
Sent: Tuesday, August 16, 2005 6:47 PM
Subject: [dba-Tech] OT - Excel VBA Cell Selection Syntax (x-posted)


> Hello to All,
>
> I'm struggling with syntax for the selection of cells when trying to use
row
> and column indexes.  Below is an example:
>
> Example A:
>     Worksheets("Available Items").Range("A2:B123").Select
>
> Example B:
>     Worksheets("Available Items").Range(Cells(2, 1), Cells(123, 2)).Select
>
> Example A works fine, but B does not.  Both are from Excel Help files (see
> the Range Property).  Once this works I will substitute a variable for the
> 123 value.
>
> Thanks!
> Dan Waters
>
> _______________________________________________
> dba-Tech mailing list
> dba-Tech at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-tech
> Website: http://www.databaseadvisors.com

_______________________________________________
dba-Tech mailing list
dba-Tech at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-tech
Website: http://www.databaseadvisors.com




More information about the dba-Tech mailing list