View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
EC[_2_] EC[_2_] is offline
external usenet poster
 
Posts: 4
Default VBA Code Works in 97, Not in 2002

William,

Thanks for taking the time to test the code and to respond.

Given that the code worked successfully for you, in your opinion,
could there be something in the environment/setup of the Win2000
machines that does not allow this code to exhibit the expected
behavior? Someone thought that under VBA References I might find
missing libraries... but I do not see anything that would indicate
this to be the case.

Do you (or anyone else) have something to add?

Thanks again,
Ron

================================================== =============================
================================================== =============================

"William" wrote in message ...
Hi

Your code worked for me with Windows 2000, XL2002.

This also worked.

Sub DeleteAndCopy()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim ws As Worksheet, ws1 As Worksheet, x As String
Set ws1 = Sheets("Inquiry Form ")
x = ws1.Name
Set ws = Sheets.Add
ws.Move after:=ws1
ws1.Rows("1:100").Copy ws.Range("A1")
ws1.Delete
ws.Name = x
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub


--
XL2002
Regards

William


"EC" wrote in message
m...
| With apologies to those who may have answered similar questions in the
| past... problem for me it that I just can not get this to work.
|
| Background: VBA code was developed under Win95 (yes, client still has
| Win95 machines) in Excel-97 where it seems to work just fine. On a NT
| machine with Excel-97 it seems to work but this the code is not fully
| tested on that machine. Under Win2000 with Excel 2002, the code does
| not work. It steps through certain code but make no change to the
| worksheet(s).
|
| Issue:
| Add a new worksheet, copy first 100 rows from an existing sheet, same
| workbook to the first 100 rows of new sheet, delete the original
| sheet, rename the new sheet to the old sheet name (.delete and .name
| statements do nothing).
|
| Application.Sheets.Add Type:="Worksheet"
| Application.ActiveSheet.Move after:=Worksheets("Inquiry Form ")
| Application.ActiveSheet.Name = "NewInquiryForm"
| Sheets("Inquiry Form ").Rows.("1:100").Copy
| Sheets("NewInquiryForm").Activate
| Range("A1").Select
| ActiveSheet.Paste
|
| Sheets("Inquiry Form ").Activate
| ActiveWindow.SelectedSheets.Delete
| Sheets("NewInquiryForm").Activate
| Sheets("NewInquiryForm").Name = "Inquiry Form "
|
|
| When the above .delete and .name statements did nothing, I also tried:
|
| Sheets("Inquiry Form ").Activate
| ThisWorkBook.Names("Inquiry Form ").Delete
| Sheets("NewInquiryForm").Activate
| ThisWorkBook.Names("NewInquiryForm").Name = "Inquiry Form "
|
| Any assistance would be greatly appreciated!
| Thanks,
| Ron