LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Adding sheets and copying data problem

I'm trying to use this code to add new sheets to a workbook and copy
information from sheet 1 "All Records" to sheet titled "GESA CC" based on
"4-$" in Col A and "GESA CC" in Col B.

The issues I"m having is for some reason only 3 page are being created then
a generic Sheet 4? Not at all sure why that is happening. Then the sort,
copy and paste is not working. Any help you can provide is certainly
appreciated. Thank you.



Sub AllRecordsSortMacros()

Call AddSheets
Call CopyData


End Sub
Sub AddSheets()

Dim NewSheets As Variant
Dim i As Long

NewSheets = Array("Confirm", "GESV CC", "GESA CC", "GESA CC", "All
Matches", "All No Matches")
For i = UBound(NewSheets) To LBound(NewSheets) Step -1
Sheets.Add after:=Sheets(1)
ActiveSheet.Name = NewSheets(i)
Next i

End Sub

Sub CopyData()
Dim rng As Range, cell As Range
Dim i As Long, sh As Worksheet
With Worksheets("All Records")
Set rng = .Range(.Cells(1, 1), _
.Cells(Rows.Count, 1).End(xlUp))
End With
i = 1
Set sh = Worksheets("All Records")
For Each cell In rng
If UCase(Trim(cell.Value)) = "4-$" And _
UCase(Trim(cell.Offset( _
0, 1).Value)) = "GESA CC" Then
cell.EntireRow.Copy sh.Cells(i, 1)
i = i + 1
End If
Next
End Sub

 
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
Tough problem adding cells from different sheets, in random order Darcy Excel Worksheet Functions 4 January 8th 09 09:41 PM
Problem with copying sheets Salut Excel Discussion (Misc queries) 0 July 11th 07 08:26 PM
Excel 2000 problem copying drawingobjects between sheets SiriS Excel Discussion (Misc queries) 0 February 8th 06 10:31 AM
Problem copying sheets ZipCurs Excel Programming 3 January 11th 06 12:26 PM
Problem copying range and pasting to multiple sheets Murphy Excel Programming 1 October 9th 03 07:13 PM


All times are GMT +1. The time now is 06:21 AM.

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"