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: 1
Default Trying to switch to a different sheet in a macro?


Here's the code I'm dealing with:


Dim varAnswer As String

varAnswer = MsgBox("This cannot be undone." & Chr(10) & Chr(10) &
"Edits to this workbook my only be entered into your Data Sheet
manually once the current data is compiled.", vbOKCancel)
If varAnswer = vbCancel Then
Exit Sub
End If
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

WITH WORKSHEETS(\"SHEET1\").ACTIVATE
END WITH

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 2
EndRow = 21
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "a").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "A").Value <= " " Then .Rows(Lrow).Delete
'This will delete the row if the cell is empty

End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

Range("A2:m21").Select
Selection.copy

With Worksheets("sheet2").Activate
End With

End Sub

The bold text is what is the problem. This macro is tied to a
commandbutton on sheet 2. The code gets throught the first message box
and then throws a Type9 error.

I want the macro to work on the data in Sheet1, but I'm stumped.
Thoughts?


--
BigDave
------------------------------------------------------------------------
BigDave's Profile: http://www.excelforum.com/member.php...fo&userid=7741
View this thread: http://www.excelforum.com/showthread...hreadid=378323

 
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
Switch lookup function to another sheet New2Macros Excel Worksheet Functions 2 January 29th 10 05:28 PM
Macro "on off" switch Larry Fitch Excel Discussion (Misc queries) 3 November 17th 09 07:04 PM
Excel: Arrows scroll sheet instead of move cursor. How to switch Turely Truely Excel Discussion (Misc queries) 2 October 31st 06 07:50 PM
Macro switch between windows question punter Excel Discussion (Misc queries) 3 June 21st 06 06:11 PM
Macro : switch between excel and word Tom Excel Programming 4 November 19th 04 09:23 AM


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