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: 3
Default Help with compiler error

I have the following code which is unfortunately giving me a "Compile Error :
Expected End With" and the only End With in the code is highlighted in yellow
when I select debug.

I am not a programmer by any strech of the imagination and any help would be
appreciated.

Sub EOM()
Dim Wks As Worksheet
Dim DestCell As Range
Dim newWks As Worksheet
Dim HeadersAreDone As Boolean
Dim mySelectedSheets As Object
Dim myRngToCopy As Range
Set mySelectedSheets = ActiveWindow.SelectedSheets
If mySelectedSheets.Count < 3 Then
MsgBox "Please Group exactly 3 sheets before you run this macro!"
Exit Sub
End If
Set newWks = Workbooks.Add(1).Worksheets(1)
HeadersAreDone = False
For Each Wks In mySelectedSheets
ActiveWorkbook.Unprotect
With Wks
If HeadersAreDone = True Then
'do nothing
Else
.Rows(1).Copy _
Destination:=newWks.Range("a1")
HeadersAreDone = True
Set DestCell = newWks.Range("a2")
End If
With Worksheets("sheet1")
.Unprotect password:=""
Set myRngToCopy = .Range("a2",
..Cells.SpecialCells(xlCellTypeLastCell))
DestCell.Resize(myRngToCopy.Rows.Count,
myRngToCopy.Columns.Count).Value _
= myRngToCopy.Value
.Protect password:=""
End With
With newWks
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
'Next Wks
'delete columns you don't want.
End With
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
Compiler Error - Not an Appropriate Name pallaver Excel Discussion (Misc queries) 1 July 16th 08 02:20 AM
Compiler Error Bobzter100 Excel Discussion (Misc queries) 4 November 10th 07 11:02 AM
Compiler Error Chris Excel Programming 2 December 9th 04 05:02 PM
VBA Compiler Error Cause Excel to Crash MWE[_12_] Excel Programming 3 January 26th 04 02:22 AM
Compiler Error - Named Argument Not Found Chris Excel Programming 7 September 8th 03 10:15 PM


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