Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MB MB is offline
external usenet poster
 
Posts: 53
Default Do Until Loop not functioning properly

OK...my code has gone through some changes and I am almost there. With
regards to the known issue with copying worksheets, I tried using the
suggested code, and everything works just fine until the point when I save,
close and reopen. I can't get my workbook to reopen to complete the loop.
Here is the code that I am currently using:

Sheets("Data").Select
Dim iBook As Workbook
Dim iWorkSheet As Worksheet
Dim iRowCounts As Integer
Dim iRowCount As Integer

Set iBook = Application.ActiveWorkbook
Set iWorkSheet = ActiveWorkbook.ActiveSheet
iRowCounts = iWorkSheet.UsedRange.Rows.Count

For iRowCount = 2 To iRowCounts
Sheets("Sheet1").Select
Sheets("Sheet1").Copy Befo=Sheets(1)
Range("C8:D12,C15:D17,C20:D22,C25:D27,A3:H3").Sele ct
Range("A3").Activate
Selection.Replace What:="2", Replacement:=iRowCount
Range("A1").Select
ActiveSheet.Name = ActiveSheet.Range("A3").Value

If iRowCount Mod 100 = 0 Then
iBook.Close SaveChanges:=True
Set iBook = Nothing
Set iBook = Application.Workbooks.Open("c:\TEST1.xls")
End If

Next iRowCount

"Jim Thomlinson" wrote:

A couple of things I see....
1. Where do you define total. You are counting to some number called total
without defining it for us.

2. There is a known issue with copying worksheets...
http://support.microsoft.com/default...84&Product=xlw

--
HTH...

Jim Thomlinson


"MB" wrote:

I have a macro that is supposed to count how many rows are active in the
current worksheet and generate a new sheet for each record. For some reason,
it generates 55 sheets and stops. When I have 39 records, it generates too
many and when I have 307 records, it doesn't generate enough. What's up with
the 55?

Here's the code:

Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
total = Selection.Rows.Count
Range("A1").Select
counter = 1
Do Until counter = total
counter = counter + 1
Sheets("Sheet1").Select
Sheets("Sheet1").Copy Befo=Sheets(1)
Range("C8:D12,C15:D17,C20:D22,C25:D27,A3:H3").Sele ct
Range("A3").Activate
Selection.Replace What:="2", Replacement:=counter
Range("A1").Select
Loop


Please help...signed...Confused!!!

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
F2 key is not functioning properly [email protected] Excel Discussion (Misc queries) 4 May 9th 07 06:12 PM
Do Until Loop not functioning properly Gord Dibben Excel Programming 0 January 23rd 07 10:30 PM
Read Only Not Functioning Properly Shelagh Excel Discussion (Misc queries) 0 April 21st 06 10:24 AM
Excel 98 not functioning properly on formula Michael Smith Excel Programming 6 July 13th 05 01:41 AM
Workbooks.Open not functioning properly Intikhab Bashir Excel Programming 3 August 18th 04 11:55 AM


All times are GMT +1. The time now is 03:15 AM.

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"