Thread: code error
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Dev[_2_] Mark Dev[_2_] is offline
external usenet poster
 
Posts: 17
Default code error

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" wrote in message
ups.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.