Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copying formula cells that really ought to be constants?

I'm trying to copy constant cells from one worksheet to another (a
horrible task in itself, who knew it would be so complicated), and I've
hit a problem. Sometimes, I'm seeing constants entered into cells as
(for example) "=12345" instead of "12345", so Excel thinks it's a
formula. Therefore, these cells aren't getting picked up by
SpecialCells(xlCellTypeConstants). Anyone have any bright ideas?
(Apart from copying a cell at a time - some of our worksheets are huge)

Cheers


Nate

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Copying formula cells that really ought to be constants?

Nate,
Copy required rangePaste Special (Values).

NickHK

"Nate" wrote in message
oups.com...
I'm trying to copy constant cells from one worksheet to another (a
horrible task in itself, who knew it would be so complicated), and I've
hit a problem. Sometimes, I'm seeing constants entered into cells as
(for example) "=12345" instead of "12345", so Excel thinks it's a
formula. Therefore, these cells aren't getting picked up by
SpecialCells(xlCellTypeConstants). Anyone have any bright ideas?
(Apart from copying a cell at a time - some of our worksheets are huge)

Cheers


Nate



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copying formula cells that really ought to be constants?

Hi Nick,

I'm not using Selection.Copy / PasteSpecial (as far as I know I can't),
as I get the error message "That command cannot be used on multiple
selections" on the Selection.Copy statement, due to the SpecialCells
range not being contiguous (I think).

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Copying formula cells that really ought to be constants?

Nate,
If you cannot take a whole contiguous, you can do it yourself with:
Private Sub CommandButton1_Click()
Dim i As Long

With Selection
For i = 1 To .Areas.Count
.Areas(i).Copy
.Areas(i).PasteSpecial (xlValues)
Next
End With
End Sub

NickHK

"Nate" wrote in message
ups.com...
Hi Nick,

I'm not using Selection.Copy / PasteSpecial (as far as I know I can't),
as I get the error message "That command cannot be used on multiple
selections" on the Selection.Copy statement, due to the SpecialCells
range not being contiguous (I think).



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Copying formula cells that really ought to be constants?

Hi Nate,

I have only one idea how to select constats entered as =12345, but it
will lead to really slow code. You can programmaticaly check each cell
for precedents, if it has no precedents, it is constant (it will
recognize as constants also =1+2 - which in fact is constant).

Regards,
Ivan



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Copying formula cells that really ought to be constants?

I don't see how PasteSpecial Values addresses the problem you stated:

Therefore, these cells aren't getting picked up by

SpecialCells(xlCellTypeConstants).

--
Regards,
Tom Ogilvy


"Nate" wrote:

Hi Nick,

I'm not using Selection.Copy / PasteSpecial (as far as I know I can't),
as I get the error message "That command cannot be used on multiple
selections" on the Selection.Copy statement, due to the SpecialCells
range not being contiguous (I think).


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copying formula cells that really ought to be constants?

Ah, that's a good point; while it may be too slow to consider here,
I'll file it away for future use - thanks!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copying formula cells that really ought to be constants?

I didn't know you could do that, many thanks!

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Copying formula cells that really ought to be constants?

Hi Nate,

there is a way how to speed it up:

You can select constants with specialcells and union this range with
second range, which is - from specialcells(xlcelltypeformulas) you
leave all with precedents.

Regards,
Ivan

Reply
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
Formula constants? Glenn L.[_2_] Excel Worksheet Functions 2 August 29th 08 01:47 PM
Copying Cells Value- Not Formula? [email protected] Excel Discussion (Misc queries) 5 August 31st 06 08:20 PM
copying adjacent cells with formula tanner Excel Worksheet Functions 4 May 15th 06 02:50 PM
How do you copy a formula without incrementing some constants? JohnT Excel Worksheet Functions 2 February 18th 05 11:09 AM
Copying formula to different cells L/P Excel Worksheet Functions 2 December 30th 04 10:37 PM


All times are GMT +1. The time now is 06:48 PM.

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"