#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default code error

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
OnTime code error "can't execute code in break mode" tskogstrom Excel Programming 1 September 8th 06 10:29 AM
Error in Excel VBA Code (Error 91) dailem Excel Programming 1 August 25th 06 03:45 PM
How can I still go to the error-code after a On Error Goto? Michel[_3_] Excel Programming 2 May 4th 04 04:21 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 06:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"