[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

keri

12/14/2006 2:59:00 PM

I can't understand what i am doing wrong with this code. Obviously the
first part of the code is for all sheets named "cardata" & integer.
After this first part I want to select "a1" in these sheets to run the
code that follows. However my line starting Range causes an error.

Dim ws As worksheet
For Each ws In ActiveWorkbook.Worksheets
If UCase(Left(ws.Name, 7)) = "CARDATA" Then
If IsNumeric(Right(ws.Name, Len(ws.Name) - 7)) Then
Range("a1").Select

I would appreciate help but also an explanationa s to why I can't start
this line of code with Range.

Thanks.

3 Answers

Mark Dev

12/14/2006 3:07:00 PM

0

Keri,

Try activating the worksheet before performing the Select.

If IsNumeric(Right(ws.Name, Len(ws.Name) - 7)) Then
ws.Activate
ws.Range("A1").Select
End If

Regards,
Mark


"keri" <keri.dowson@diageo.com> wrote in message
news:1166108314.873124.113940@f1g2000cwa.googlegroups.com...
>I can't understand what i am doing wrong with this code. Obviously the
> first part of the code is for all sheets named "cardata" & integer.
> After this first part I want to select "a1" in these sheets to run the
> code that follows. However my line starting Range causes an error.
>
> Dim ws As worksheet
> For Each ws In ActiveWorkbook.Worksheets
> If UCase(Left(ws.Name, 7)) = "CARDATA" Then
> If IsNumeric(Right(ws.Name, Len(ws.Name) - 7)) Then
> Range("a1").Select
>
> I would appreciate help but also an explanationa s to why I can't start
> this line of code with Range.
>
> Thanks.
>


Bob Phillips

12/14/2006 3:19:00 PM

0

Qualify EVERYTHING

Dim ws As worksheet
For Each ws In ActiveWorkbook.Worksheets
If UCase(Left(ws.Name, 7)) = "CARDATA" Then
If IsNumeric(Right(ws.Name, Len(ws.Name) - 7)) Then
ws.Range("a1").Select '<====================

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"keri" <keri.dowson@diageo.com> wrote in message
news:1166108314.873124.113940@f1g2000cwa.googlegroups.com...
>I can't understand what i am doing wrong with this code. Obviously the
> first part of the code is for all sheets named "cardata" & integer.
> After this first part I want to select "a1" in these sheets to run the
> code that follows. However my line starting Range causes an error.
>
> Dim ws As worksheet
> For Each ws In ActiveWorkbook.Worksheets
> If UCase(Left(ws.Name, 7)) = "CARDATA" Then
> If IsNumeric(Right(ws.Name, Len(ws.Name) - 7)) Then
> Range("a1").Select
>
> I would appreciate help but also an explanationa s to why I can't start
> this line of code with Range.
>
> Thanks.
>


keri

12/14/2006 3:26:00 PM

0

Thanks guys. One day i'll be good at this!