Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Simple For Each Next code


Uzytkownik "jacqui" napisal w wiadomosci
...
I'm trying to write a simple For Each statement to loop
through each worksheet in the active workbook. I should
know how to do this but for some reason I'm having a bit
of trouble. Can anyone help? The code I've written so
far is below. I'm getting a VBA error though on the shts
() = Sheets(iCnt) line where Excel says 'Can't assign to
array'.
I'm sure it could also be simpler too, so if there's a
much neater way, I'd be very grateful for any other
suggestions.
Many thanks
Jacqui

Dim iCnt As Integer

Dim sRTitle As String
Dim sht() As Worksheet


It isn't an array

Dim sht As Worksheet


ActiveWindow.SelectedSheets.Copy

ActiveWindow.Caption = "ERS-Formula to value"
Application.StatusBar = "Converting formula to
values"

iCnt = Worksheets.Count

delete this line sht() = Sheets(iCnt)



For Each sht In Worksheets

EndRow = Range("A65000").End(xlUp).Row + 1
iCCount = Range("IV7").End(xlToLeft).Column

Range("A1", Cells(EndRow, iCCount)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

delete this line iCnt = iCnt + 1

Next sht




MS




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
COUNTIF TO BUILD SIMPLE CODE Eddy Stan Excel Worksheet Functions 6 August 26th 07 11:06 PM
Simple code for shifting N.F[_2_] Excel Discussion (Misc queries) 1 July 6th 07 10:38 PM
Help with some simple code Angeline Excel Discussion (Misc queries) 4 October 12th 06 09:06 AM
Simple Code, I think... [email protected] Excel Worksheet Functions 1 August 2nd 06 08:09 PM
Simple Checkbox Message Code nemadrias Excel Discussion (Misc queries) 10 June 21st 06 08:59 PM


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