ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code error (https://www.excelbanter.com/excel-programming/379419-code-error.html)

keri

code error
 
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.


Mark Dev[_2_]

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.




Bob Phillips

code error
 
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" 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.




keri

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



All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com