A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Copy pages, delete certain values



 
 
Thread Tools Display Modes
  #1  
Old July 15th, 2004, 02:08 AM
zinzah
external usenet poster
 
Posts: n/a
Default Copy pages, delete certain values

Hi. Trying to create a multiple page workbook. Start with 3 pages. Pages
2 and 3 have data that does not change and is used by page 1 with
VLOOKUP. I have been successful in adding a command button called "New
Page" to copy page 1 and insert it before page 2 in the workbook, but
when trying to deleted the values in 3 different ranges ( Range1,
Range2 and Range3) that were entered in page 1 before the COPY took
place, I am consistently gettng a error, or the command button seems to
work fine, but the data in the ranges are not deleted. After deletion,
would like to make Cell A11 active.

Also looking to try making a second command button that will save the
file as a name that is pulled from Cell A3 and Cell A7 and print all
pages with the exception of the original pages 2 and 3


---
Message posted from http://www.ExcelForum.com/

  #2  
Old July 15th, 2004, 06:50 AM
Frank Kabel
external usenet poster
 
Posts: n/a
Default Copy pages, delete certain values

Hi
you may post your current code which is used after clicking the command
buttons. always easier to find your errors :-)

--
Regards
Frank Kabel
Frankfurt, Germany


Hi. Trying to create a multiple page workbook. Start with 3 pages.
Pages 2 and 3 have data that does not change and is used by page 1
with VLOOKUP. I have been successful in adding a command button
called "New Page" to copy page 1 and insert it before page 2 in the
workbook, but when trying to deleted the values in 3 different ranges
( Range1, Range2 and Range3) that were entered in page 1 before the
COPY took place, I am consistently gettng a error, or the command
button seems to work fine, but the data in the ranges are not
deleted. After deletion, would like to make Cell A11 active.

Also looking to try making a second command button that will save the
file as a name that is pulled from Cell A3 and Cell A7 and print all
pages with the exception of the original pages 2 and 3


---
Message posted from http://www.ExcelForum.com/


  #3  
Old July 16th, 2004, 01:53 AM
zinzah
external usenet poster
 
Posts: n/a
Default Copy pages, delete certain values

This is the error I get when running the command button.

Runtime error ‘1004’
Select method of range class failed

The part after the second comment about the ranges works fine when run
as a separate macro, but when included in the command button I get the
error

Private Sub NewPage_Click()

' Copy page and move it to next page

Dim Wks As Worksheet
Dim iCount As Integer

iCount = Worksheets.Count
Worksheets(iCount - 2).Copy after:=Worksheets(iCount - 2)
iCount = iCount + 1
Set Wks = Worksheets(iCount)
Worksheets(iCount - 2).Name = (iCount - 2)

' Delete Values for Game, Book and Quantity
Range("A11:E11").Select
Selection.ClearContents
Range("G11:M11").Select
Selection.ClearContents
Range("O11:R11").Select
Selection.ClearContents

Range("A11:E11").Select
Selection.Activate



End Sub


---
Message posted from http://www.ExcelForum.com/

  #4  
Old July 16th, 2004, 06:06 AM
Frank Kabel
external usenet poster
 
Posts: n/a
Default Copy pages, delete certain values

Hi
you may add the worksheet references to your code. Currently you only
use
Range(...)

try something like
with worksheets("your_sheet")
.range(....)
'...
end with

or use an object variable like your 'wks' for this


--
Regards
Frank Kabel
Frankfurt, Germany


This is the error I get when running the command button.

Runtime error ‘1004’
Select method of range class failed

The part after the second comment about the ranges works fine when

run
as a separate macro, but when included in the command button I get

the
error

Private Sub NewPage_Click()

' Copy page and move it to next page

Dim Wks As Worksheet
Dim iCount As Integer

iCount = Worksheets.Count
Worksheets(iCount - 2).Copy after:=Worksheets(iCount - 2)
iCount = iCount + 1
Set Wks = Worksheets(iCount)
Worksheets(iCount - 2).Name = (iCount - 2)

' Delete Values for Game, Book and Quantity
Range("A11:E11").Select
Selection.ClearContents
Range("G11:M11").Select
Selection.ClearContents
Range("O11:R11").Select
Selection.ClearContents

Range("A11:E11").Select
Selection.Activate



End Sub


---
Message posted from http://www.ExcelForum.com/


  #5  
Old July 22nd, 2004, 01:51 AM
zinzah
external usenet poster
 
Posts: n/a
Default Copy pages, delete certain values

Worked like a charm!! Thanks!!!


---
Message posted from http://www.ExcelForum.com/

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete / Copy files outside current db Steven Using Forms 1 June 26th, 2004 05:40 AM
Copy all values in worksheet.... IamHaxer Worksheet Functions 3 June 25th, 2004 08:44 PM
Find multiple values in excel coulumns then copy into mail merge Tom General Discussion 0 June 10th, 2004 07:54 PM
copy paste changing cell values Frank Worksheet Functions 5 January 7th, 2004 01:21 PM


All times are GMT +1. The time now is 04:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.