Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Formatting workbook and going to first sheet

Hi All

Fairly straightforward question I think, basically I want a little
macro to format a workbook I have open. It will select "A1" in each
sheet and then return to the first sheet. This is what I have:

Dim i As Integer
wksname = ActiveSheet.Name

For i = 1 To Sheets.Count
Sheets(i).Select
Range("A1").Select

Next i

'Sheets(wksname).Activate

unfortunately I get a "run time error 1004" message saying "Select
method of workclass failed".

Can anyone shed any light?
Cheers in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Formatting workbook and going to first sheet

Hi,

This will select A1 of each sheet but you don't say what you want to do. In
any case it's highly inlikely you need to select the cell, you can format it
without selecting

This goes in a general module

Sub Dont_Select()
Dim i As Integer
wksname = Sheets(1).Name
For i = 1 To Worksheets.Count
Sheets(i).Select
Range("A1").Select
Next i
Sheets(wksname).Activate
End Sub

Mike

"Stav19" wrote:

Hi All

Fairly straightforward question I think, basically I want a little
macro to format a workbook I have open. It will select "A1" in each
sheet and then return to the first sheet. This is what I have:

Dim i As Integer
wksname = ActiveSheet.Name

For i = 1 To Sheets.Count
Sheets(i).Select
Range("A1").Select

Next i

'Sheets(wksname).Activate

unfortunately I get a "run time error 1004" message saying "Select
method of workclass failed".

Can anyone shed any light?
Cheers in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Formatting workbook and going to first sheet

Careful - this may fail if there are any Chart or Macro sheets in the
workbook.

Try

Worksheets(i).Select

instead of

Sheets(i).Select



In article ,
Mike H wrote:

Hi,

This will select A1 of each sheet but you don't say what you want to do. In
any case it's highly inlikely you need to select the cell, you can format it
without selecting

This goes in a general module

Sub Dont_Select()
Dim i As Integer
wksname = Sheets(1).Name
For i = 1 To Worksheets.Count
Sheets(i).Select
Range("A1").Select
Next i
Sheets(wksname).Activate
End Sub

Mike

"Stav19" wrote:

Hi All

Fairly straightforward question I think, basically I want a little
macro to format a workbook I have open. It will select "A1" in each
sheet and then return to the first sheet. This is what I have:

Dim i As Integer
wksname = ActiveSheet.Name

For i = 1 To Sheets.Count
Sheets(i).Select
Range("A1").Select

Next i

'Sheets(wksname).Activate

unfortunately I get a "run time error 1004" message saying "Select
method of workclass failed".

Can anyone shed any light?
Cheers in advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Formatting workbook and going to first sheet

On Jan 19, 10:27*pm, JE McGimpsey wrote:
Careful - this may fail if there are any Chart or Macro sheets in the
workbook.

Try

* *Worksheets(i).Select

instead of

* *Sheets(i).Select

In article ,
*Mike H wrote:



Hi,


This will select A1 of each sheet but you don't say what you want to do.. In
any case it's highly inlikely you need to select the cell, you can format it
without selecting


This goes in a general module


Sub Dont_Select()
Dim i As Integer
wksname = Sheets(1).Name
For i = 1 To Worksheets.Count
Sheets(i).Select
Range("A1").Select
Next i
Sheets(wksname).Activate
End Sub


Mike


"Stav19" wrote:


Hi All


Fairly straightforward question I think, basically I want a little
macro to format a workbook I have open. *It will select "A1" in each
sheet and then return to the first sheet. *This is what I have:


Dim i As Integer
wksname = ActiveSheet.Name


For i = 1 To Sheets.Count
Sheets(i).Select
Range("A1").Select


Next i


'Sheets(wksname).Activate


unfortunately I get a "run time error 1004" message saying "Select
method of workclass failed".


Can anyone shed any light?
Cheers in advance- Hide quoted text -


- Show quoted text -


cheers for your help, I'll have to give that a go!!!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Formatting workbook and going to first sheet

On Jan 19, 10:56*pm, Stav19 wrote:
On Jan 19, 10:27*pm, JE McGimpsey wrote:





Careful - this may fail if there are any Chart or Macro sheets in the
workbook.


Try


* *Worksheets(i).Select


instead of


* *Sheets(i).Select


In article ,
*Mike H wrote:


Hi,


This will select A1 of each sheet but you don't say what you want to do. In
any case it's highly inlikely you need to select the cell, you can format it
without selecting


This goes in a general module


Sub Dont_Select()
Dim i As Integer
wksname = Sheets(1).Name
For i = 1 To Worksheets.Count
Sheets(i).Select
Range("A1").Select
Next i
Sheets(wksname).Activate
End Sub


Mike


"Stav19" wrote:


Hi All


Fairly straightforward question I think, basically I want a little
macro to format a workbook I have open. *It will select "A1" in each
sheet and then return to the first sheet. *This is what I have:


Dim i As Integer
wksname = ActiveSheet.Name


For i = 1 To Sheets.Count
Sheets(i).Select
Range("A1").Select


Next i


'Sheets(wksname).Activate


unfortunately I get a "run time error 1004" message saying "Select
method of workclass failed".


Can anyone shed any light?
Cheers in advance- Hide quoted text -


- Show quoted text -


cheers for your help, I'll have to give that a go!!!- Hide quoted text -

- Show quoted text -


I tried it and it worked a treat with the "Worksheets" for "Sheets"
change, thanks for your help!


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
Color formatting issue when copying excel sheet from workbook to o Sanjeev Excel Discussion (Misc queries) 1 July 23rd 08 08:44 PM
Copy Excel Sheet to another sheet and preserve formatting? Rich Excel Programming 4 May 4th 07 06:12 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
How do I copy formatting from 1 sheet to next in same workbook? Marlene K. Excel Worksheet Functions 1 July 8th 05 04:15 PM


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

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

About Us

"It's about Microsoft Excel"