Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Need help editing a macro

This macro was coded from here on this site (thanks for everyones help) and
it basically takes all the information from every worksheet in the workbook
and compiles it into one long list of data.

Sub UpdateMaster()
Dim ws As Worksheet 'Utility worksheet variable
Dim Dest As Range 'The cell in Col B of Master sht in which to paste
If Range("A" & Rows.Count).End(xlUp).Row 1 Then
Range("A2", Range("B" & Rows.Count).End(xlUp).Offset(2,
-1)).Resize(, 13).ClearContents
End If
Set Dest = Range("B2")
For Each ws In ActiveWorkbook.Worksheets
If ws.Name < "Master" Then
Dest.Offset(, -1).Value = ws.Name
With ws
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 12).Copy Dest
Set Dest = Range("B" & Rows.Count).End(xlUp).Offset(2)
End With
End If
Next ws
End Sub

My question is, how do I get it to ignore the first worksheet in the
workbook? Is there some command I can give to do this in the code? Any help
is appretiated.. If this is too vague I'll try and make my question more
specific
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,311
Default Need help editing a macro

I'm sure there are other ways, but I would do it this way.

Sub UpdateMaster()
Dim ws As Worksheet 'Utility worksheet variable
Dim Dest As Range 'The cell in Col B of Master sht in which to paste
If Range("A" & Rows.Count).End(xlUp).Row 1 Then
Range("A2", Range("B" &
Rows.Count).End(xlUp).Offset(2, -1)).Resize(, 13).ClearContents
End If
Set Dest = Range("B2")

For sh = 2 To Worksheets.Count

'For Each ws In ActiveWorkbook.Worksheets
If Sheets(sh).Name < "Master" Then
Dest.Offset(, -1).Value = sheets(sh).Name
With Sheets(sh)
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 12).Copy Dest
Set Dest = Range("B" &
Rows.Count).End(xlUp).Offset(2)
End With
End If
Next sh
End Sub

Note: I've remarked statements with "ws" or changed the reference to
"Sheets(sh)".
HTH,
Paul

--

"ZBelden" wrote in message
...
This macro was coded from here on this site (thanks for everyones help)
and
it basically takes all the information from every worksheet in the
workbook
and compiles it into one long list of data.

Sub UpdateMaster()
Dim ws As Worksheet 'Utility worksheet variable
Dim Dest As Range 'The cell in Col B of Master sht in which to paste
If Range("A" & Rows.Count).End(xlUp).Row 1 Then
Range("A2", Range("B" & Rows.Count).End(xlUp).Offset(2,
-1)).Resize(, 13).ClearContents
End If
Set Dest = Range("B2")
For Each ws In ActiveWorkbook.Worksheets
If ws.Name < "Master" Then
Dest.Offset(, -1).Value = ws.Name
With ws
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 12).Copy Dest
Set Dest = Range("B" &
Rows.Count).End(xlUp).Offset(2)
End With
End If
Next ws
End Sub

My question is, how do I get it to ignore the first worksheet in the
workbook? Is there some command I can give to do this in the code? Any
help
is appretiated.. If this is too vague I'll try and make my question more
specific



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Need help editing a macro

or name the other sheet to exclude

If ws.Name < "Master" and ws.name < "Whatever" Then

Mike

"ZBelden" wrote:

This macro was coded from here on this site (thanks for everyones help) and
it basically takes all the information from every worksheet in the workbook
and compiles it into one long list of data.

Sub UpdateMaster()
Dim ws As Worksheet 'Utility worksheet variable
Dim Dest As Range 'The cell in Col B of Master sht in which to paste
If Range("A" & Rows.Count).End(xlUp).Row 1 Then
Range("A2", Range("B" & Rows.Count).End(xlUp).Offset(2,
-1)).Resize(, 13).ClearContents
End If
Set Dest = Range("B2")
For Each ws In ActiveWorkbook.Worksheets
If ws.Name < "Master" Then
Dest.Offset(, -1).Value = ws.Name
With ws
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 12).Copy Dest
Set Dest = Range("B" & Rows.Count).End(xlUp).Offset(2)
End With
End If
Next ws
End Sub

My question is, how do I get it to ignore the first worksheet in the
workbook? Is there some command I can give to do this in the code? Any help
is appretiated.. If this is too vague I'll try and make my question more
specific

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Need help editing a macro

Worked like a charm, thanks guys.

"PCLIVE" wrote:

I'm sure there are other ways, but I would do it this way.

Sub UpdateMaster()
Dim ws As Worksheet 'Utility worksheet variable
Dim Dest As Range 'The cell in Col B of Master sht in which to paste
If Range("A" & Rows.Count).End(xlUp).Row 1 Then
Range("A2", Range("B" &
Rows.Count).End(xlUp).Offset(2, -1)).Resize(, 13).ClearContents
End If
Set Dest = Range("B2")

For sh = 2 To Worksheets.Count

'For Each ws In ActiveWorkbook.Worksheets
If Sheets(sh).Name < "Master" Then
Dest.Offset(, -1).Value = sheets(sh).Name
With Sheets(sh)
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 12).Copy Dest
Set Dest = Range("B" &
Rows.Count).End(xlUp).Offset(2)
End With
End If
Next sh
End Sub

Note: I've remarked statements with "ws" or changed the reference to
"Sheets(sh)".
HTH,
Paul

--

"ZBelden" wrote in message
...
This macro was coded from here on this site (thanks for everyones help)
and
it basically takes all the information from every worksheet in the
workbook
and compiles it into one long list of data.

Sub UpdateMaster()
Dim ws As Worksheet 'Utility worksheet variable
Dim Dest As Range 'The cell in Col B of Master sht in which to paste
If Range("A" & Rows.Count).End(xlUp).Row 1 Then
Range("A2", Range("B" & Rows.Count).End(xlUp).Offset(2,
-1)).Resize(, 13).ClearContents
End If
Set Dest = Range("B2")
For Each ws In ActiveWorkbook.Worksheets
If ws.Name < "Master" Then
Dest.Offset(, -1).Value = ws.Name
With ws
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 12).Copy Dest
Set Dest = Range("B" &
Rows.Count).End(xlUp).Offset(2)
End With
End If
Next ws
End Sub

My question is, how do I get it to ignore the first worksheet in the
workbook? Is there some command I can give to do this in the code? Any
help
is appretiated.. If this is too vague I'll try and make my question more
specific




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
Macro editing Skeeter Excel Discussion (Misc queries) 5 August 6th 07 01:40 AM
Editing a macro pm Excel Discussion (Misc queries) 5 June 6th 07 11:33 PM
Editing a macro Dtmos01 Excel Discussion (Misc queries) 6 April 3rd 07 06:36 PM
Editing a Macro ChuckW Excel Discussion (Misc queries) 1 December 12th 06 08:45 PM
Editing Macro heitorfjr Excel Discussion (Misc queries) 1 January 15th 06 08:02 PM


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