Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default set code to ALL sheets in workbook ?

Sub SentenceCase()
For Each cell In Range("a8:A30,A7:Q7")
s = cell.Value
Start = True
For i = 1 To Len(s)
ch = Mid(s, i, 1)
Select Case ch
Case "."
Start = True
Case "?"
Start = True
Case "a" To "z"
If Start Then ch = UCase(ch): Start = False
Case "A" To "Z"
If Start Then Start = False Else ch = LCase(ch)
End Select
Mid(s, i, 1) = ch
Next
cell.Value = s
Next
End Sub

The above code changes the font case to Sentance Case.
I placed this in a MODULE, but how can i get it to do this across ALL worksheets in the workbook?

Corey....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default set code to ALL sheets in workbook ?

One way is to set a loop.
Dim sh as Sheets

For sh = 1 to Sheets.Count
sh.activate
' Do your tasks
Next sh

I am not sure if selecting all sheets will accomplish this.

--
Best wishes,

Jim


"Corey" wrote:

Sub SentenceCase()
For Each cell In Range("a8:A30,A7:Q7")
s = cell.Value
Start = True
For i = 1 To Len(s)
ch = Mid(s, i, 1)
Select Case ch
Case "."
Start = True
Case "?"
Start = True
Case "a" To "z"
If Start Then ch = UCase(ch): Start = False
Case "A" To "Z"
If Start Then Start = False Else ch = LCase(ch)
End Select
Mid(s, i, 1) = ch
Next
cell.Value = s
Next
End Sub

The above code changes the font case to Sentance Case.
I placed this in a MODULE, but how can i get it to do this across ALL worksheets in the workbook?

Corey...

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default set code to ALL sheets in workbook ?

Corey,

Dim WS as Worksheet
dim cell as range

for each ws in thisworkbook.worksheets
for each cell in ws.range("a8:A30,A7:Q7")
... your code

NickHK

"Corey"
...
Sub SentenceCase()
For Each cell In Range("a8:A30,A7:Q7")
s = cell.Value
Start = True
For i = 1 To Len(s)
ch = Mid(s, i, 1)
Select Case ch
Case "."
Start = True
Case "?"
Start = True
Case "a" To "z"
If Start Then ch = UCase(ch): Start = False
Case "A" To "Z"
If Start Then Start = False Else ch = LCase(ch)
End Select
Mid(s, i, 1) = ch
Next
cell.Value = s
Next
End Sub

The above code changes the font case to Sentance Case.
I placed this in a MODULE, but how can i get it to do this across ALL
worksheets in the workbook?

Corey....


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
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
VBA Code To have a macro repeat on all sheets in a workbook carl Excel Worksheet Functions 3 November 3rd 05 07:48 PM
run code on opening workbook and apply code to certain sheets Jane Excel Programming 7 August 8th 05 09:15 AM
How to hide sheets and VBA code in my Excel workbook? Rick[_13_] Excel Programming 0 August 26th 03 04:01 AM


All times are GMT +1. The time now is 08:40 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"