PC Review


Reply
Thread Tools Rate Thread

Accessing ranges within sheets

 
 
Udo
Guest
Posts: n/a
 
      6th Mar 2008
Hi Ex(cel)perts,

I thought I'd have a quick solution, but Excel doesn't agree. I have
multiple sheets in one workbook and from a specific one on I would
like to copy the content of that sheet into itself, just to overwrite
the formulas.
The start of the makro is this:
Private sub Finalise_click()


I entcoutered two problems
 
Reply With Quote
 
 
 
 
Udo
Guest
Posts: n/a
 
      6th Mar 2008
On 6 Mrz., 14:08, Udo <udo.baumf...@arcor.de> wrote:
> Hi Ex(cel)perts,
>
> I thought I'd have a quick solution, but Excel doesn't agree. I have
> multiple sheets in one workbook and from a specific one on I would
> like to copy the content of that sheet into itself, just to overwrite
> the formulas.
> The start of the makro is this:
> Private sub Finalise_click()
> Dim Number as Integer ' to store the number of worksheets

Dim k as integer ' loop variable
for k=3 to Number

> *I entcoutered two problems:

When I countinue with
sheets(k).select
then I get an error, it will not recognise the sheet. If I use the
real name of the sheet like Sheets("starter").select, it works.

Second problem:
If I try another way, e.g. say
ActiveSheets.next.select
Range("A1:AB200").Select
Excel jumps to the next sheet, but it can't select that range. What is
my mistake?
How can loop through all the sheets and substitute the formulas with
the values?

Thank you in advance.
Udo

PS: sorry for the confusion and sending too early....

 
Reply With Quote
 
merjet
Guest
Posts: n/a
 
      6th Mar 2008
Try this. Change loop to suit.

Sub Macro1()
Dim iCt As Integer
For iCt = 3 To 4
Sheets(iCt).UsedRange.Copy
Sheets(iCt).UsedRange.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Next iCt
End Sub

Hth,
Merjet
 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      6th Mar 2008
For Each sht In ThisWorkbook.Sheets

sht.Cells.Copy
sht.Cells.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
Next sht

"Udo" wrote:

> On 6 Mrz., 14:08, Udo <udo.baumf...@arcor.de> wrote:
> > Hi Ex(cel)perts,
> >
> > I thought I'd have a quick solution, but Excel doesn't agree. I have
> > multiple sheets in one workbook and from a specific one on I would
> > like to copy the content of that sheet into itself, just to overwrite
> > the formulas.
> > The start of the makro is this:
> > Private sub Finalise_click()
> > Dim Number as Integer ' to store the number of worksheets

> Dim k as integer ' loop variable
> for k=3 to Number
>
> > I entcoutered two problems:

> When I countinue with
> sheets(k).select
> then I get an error, it will not recognise the sheet. If I use the
> real name of the sheet like Sheets("starter").select, it works.
>
> Second problem:
> If I try another way, e.g. say
> ActiveSheets.next.select
> Range("A1:AB200").Select
> Excel jumps to the next sheet, but it can't select that range. What is
> my mistake?
> How can loop through all the sheets and substitute the formulas with
> the values?
>
> Thank you in advance.
> Udo
>
> PS: sorry for the confusion and sending too early....
>
>

 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      6th Mar 2008
or even shorter...

sub WhatEver()
dim sht as worksheet

for each sht in thisworkbook.worksheets
sht.cells.value = sht.cells.value
next sht
End sub
--
HTH...

Jim Thomlinson


"Joel" wrote:

> For Each sht In ThisWorkbook.Sheets
>
> sht.Cells.Copy
> sht.Cells.PasteSpecial _
> Paste:=xlPasteValues, _
> Operation:=xlNone, _
> SkipBlanks:=False, _
> Transpose:=False
> Next sht
>
> "Udo" wrote:
>
> > On 6 Mrz., 14:08, Udo <udo.baumf...@arcor.de> wrote:
> > > Hi Ex(cel)perts,
> > >
> > > I thought I'd have a quick solution, but Excel doesn't agree. I have
> > > multiple sheets in one workbook and from a specific one on I would
> > > like to copy the content of that sheet into itself, just to overwrite
> > > the formulas.
> > > The start of the makro is this:
> > > Private sub Finalise_click()
> > > Dim Number as Integer ' to store the number of worksheets

> > Dim k as integer ' loop variable
> > for k=3 to Number
> >
> > > I entcoutered two problems:

> > When I countinue with
> > sheets(k).select
> > then I get an error, it will not recognise the sheet. If I use the
> > real name of the sheet like Sheets("starter").select, it works.
> >
> > Second problem:
> > If I try another way, e.g. say
> > ActiveSheets.next.select
> > Range("A1:AB200").Select
> > Excel jumps to the next sheet, but it can't select that range. What is
> > my mistake?
> > How can loop through all the sheets and substitute the formulas with
> > the values?
> >
> > Thank you in advance.
> > Udo
> >
> > PS: sorry for the confusion and sending too early....
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Two Visible Ranges (From Two Sheets) To A New Workbook (AlsoWith Two Sheets) septhemis@gmail.com Microsoft Excel Programming 3 30th Jan 2009 04:20 PM
Re: Copy Two Visible Ranges (From Two Sheets) To A New Workbook (AlsoWith Two Sheets) septhemis@gmail.com Microsoft Excel Programming 0 29th Jan 2009 01:35 PM
Referencing Ranges on other Sheets MatthewByrne Microsoft Excel Programming 3 28th Mar 2004 02:37 AM
Use same name for ranges on different sheets James Microsoft Excel Worksheet Functions 10 30th Dec 2003 11:59 PM
Get ranges from sheets interactively Filip Mateasko Microsoft Excel Programming 5 29th Sep 2003 08:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 PM.