LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Help getting next sheet

Thank You, Thank You, Thank You; you are indeed a prince. Works great!

"Per Jessen" wrote:

Hi

When you use "With wks" you have to put a dot before every statement which
should refer to "wks". I would rather skip the sheet than exit the macro if
the sheet name is Summary or Lead.

Sub GetSheets()
Application.ScreenUpdating = False
For Each wks In ActiveWorkbook.Worksheets
'With wks
wks.Select
If wks.Name < "Summary" And wks.Name < "Lead" Then
myName = ActiveSheet.Name
MsgBox myName
Range("A1").Select
For Counter = 1 To 15
If ActiveCell = "Application" Then
myRange1 = ActiveCell.Offset(0, 2)
myRange2 = ActiveCell.Offset(1, 2)
myRange3 = ActiveCell.Offset(1, 4)
myRange4 = ActiveCell.Offset(1, 6) 'activity
myRange5 = ActiveCell.Offset(2, 2)
myRange6 = ActiveCell.Offset(3, 2)
myRange7 = ActiveCell.Offset(4, 2)
Sheets("Sheet1").Select

Set SRng = ActiveSheet.Cells(Rows.Count, 1).End(xlUp)(2)
SRng.Select
ActiveCell = myName 'Sheet Name
ActiveCell.Offset(0, 1) = myRange1 'Application
ActiveCell.Offset(0, 2) = myRange2 'Business Process
ActiveCell.Offset(0, 3) = myRange3 'Sub Process
ActiveCell.Offset(0, 4) = myRange4 'Activity
ActiveCell.Offset(0, 5) = myRange5 'Sub System
ActiveCell.Offset(0, 6) = myRange6 'Test Number
ActiveCell.Offset(0, 7) = myRange7 ' Objective

Else
ActiveCell.Offset(1, 0).Select
End If
Next Counter
End If
'End With
Next wks
Application.ScreenUpdating = True
End Sub

Regards,
Per

"cottage6" skrev i meddelelsen
...
Hello,
I have many files with varying sheet names. I need to get each sheet in
the
file and copy certain data to a Summary Sheet, including the sheet name.
I
have this working kind of, but I need to ignore the Summary Sheet in the
"For
each wks" statement, and my code is not getting the next sheet after the
first one. Also, a sheet I've renamed still gives me the sheet name
"Sheet2"
for example. Tom Hutchins was kind enough to reply and from that I got the
"Exit Sub" idea. Anyway, my code is posted below if anyone can help.
This
is just really messed up. Please help; I'm near suicide.
Sub GetSheets()
For Each wks In ActiveWorkbook.Worksheets
With wks
If wks.Name = "Summary" Or wks.Name = "Lead" Then
Exit Sub
End If

myName = ActiveSheet.Name
MsgBox myName
Range("A1").Select
For Counter = 1 To 15
If ActiveCell = "Application" Then
myRange1 = ActiveCell.Offset(0, 2)
myRange2 = ActiveCell.Offset(1, 2)

myRange3 = ActiveCell.Offset(1, 4)
myRange4 = ActiveCell.Offset(1, 6) 'activity
myRange5 = ActiveCell.Offset(2, 2)
myRange6 = ActiveCell.Offset(3, 2)
myRange7 = ActiveCell.Offset(4, 2)
Sheets("Sheet1").Select
Set SRng = ActiveSheet.Cells(Rows.Count, 1).End(xlUp)(2)
SRng.Select
ActiveCell = myName 'Sheet Name
ActiveCell.Offset(0, 1) = myRange1 'Application
ActiveCell.Offset(0, 2) = myRange2 'Business Process
ActiveCell.Offset(0, 3) = myRange3 'Sub Process
ActiveCell.Offset(0, 4) = myRange4 'Activity
ActiveCell.Offset(0, 5) = myRange5 'Sub System
ActiveCell.Offset(0, 6) = myRange6 'Test Number
ActiveCell.Offset(0, 7) = myRange7 ' Objective

Else
ActiveCell.Offset(1, 0).Select
End If
Next Counter
End With
Next wks
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
excel sheet bootom half sheet goes behind top part of sheet rob Excel Worksheet Functions 2 January 17th 09 01:28 AM
Duplicate sheet, autonumber sheet, record data on another sheet des-sa[_2_] Excel Worksheet Functions 0 May 8th 08 06:56 PM
Export sheet store sheet import sheet. Robert[_33_] Excel Programming 0 December 28th 06 01:58 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM
Inserting a row in sheet A should Insert a row in sheet B, removing a row in Sheet A should remove the corresponding row in sheet B Hannes Heckner Excel Programming 1 March 5th 04 09:10 AM


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